public class OverwriteData extends java.lang.Object implements OverwriteFiles
Modifier and Type | Class and Description |
---|---|
protected static class |
org.apache.iceberg.MergingSnapshotProducer.DeleteException |
Modifier | Constructor and Description |
---|---|
protected |
OverwriteData(TableOperations ops) |
Modifier and Type | Method and Description |
---|---|
protected void |
add(DataFile file)
Add a file to the new snapshot.
|
protected void |
add(ManifestFile manifest)
Add all files in a manifest to the new snapshot.
|
protected java.util.List<DataFile> |
addedFiles() |
OverwriteFiles |
addFile(DataFile file)
Add a
DataFile to the table. |
Snapshot |
apply()
Apply the pending changes and return the uncommitted changes for validation.
|
java.util.List<ManifestFile> |
apply(TableMetadata base)
Apply the update's changes to the base table metadata and return the new manifest list.
|
protected void |
cleanAll() |
protected void |
cleanUncommitted(java.util.Set<ManifestFile> committed)
Clean up any uncommitted manifests that were created.
|
void |
commit()
Apply the pending changes and commit.
|
protected void |
delete(java.lang.CharSequence path)
Add a specific path to be deleted in the new snapshot.
|
protected void |
deleteByRowFilter(Expression expr)
Add a filter to match files to delete.
|
protected void |
deleteFile(java.lang.String path) |
ThisT |
deleteWith(java.util.function.Consumer<java.lang.String> deleteCallback)
Set a callback to delete files instead of the table's default.
|
protected void |
dropPartition(StructLike partition)
Add a partition tuple to drop from the table during the delete phase.
|
protected void |
failAnyDelete() |
protected void |
failMissingDeletePaths() |
protected OutputFile |
manifestListPath() |
protected OutputFile |
manifestPath(int manifestNumber) |
protected java.lang.String |
operation()
A string that describes the action that produced the new snapshot.
|
OverwriteFiles |
overwriteByRowFilter(Expression expr)
Delete files that match an
Expression on data rows from the table. |
protected Expression |
rowFilter() |
protected OverwriteFiles |
self() |
ThisT |
set(java.lang.String property,
java.lang.String value)
Set a summary property in the snapshot produced by this update.
|
protected long |
snapshotId() |
protected java.util.Map<java.lang.String,java.lang.String> |
summary() |
OverwriteFiles |
validateAddedFiles()
Signal that each file added to the table must match the overwrite expression.
|
protected PartitionSpec |
writeSpec() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deleteWith, set
apply, commit
protected OverwriteData(TableOperations ops)
protected OverwriteFiles self()
protected java.lang.String operation()
public OverwriteFiles overwriteByRowFilter(Expression expr)
OverwriteFiles
Expression
on data rows from the table.
A file is selected to be deleted by the expression if it could contain any rows that match the
expression (candidate files are selected using an
inclusive projection
). These candidate files are
deleted if all of the rows in the file must match the expression (the partition data matches
the expression's Projections.strict(PartitionSpec)
strict projection}). This guarantees
that files are deleted if and only if all rows in the file must match the expression.
Files that may contain some rows that match the expression and some rows that do not will
result in a ValidationException
.
overwriteByRowFilter
in interface OverwriteFiles
expr
- an expression on rows in the tablepublic OverwriteFiles addFile(DataFile file)
OverwriteFiles
DataFile
to the table.addFile
in interface OverwriteFiles
file
- a data filepublic OverwriteFiles validateAddedFiles()
OverwriteFiles
If this method is called, each added file is validated on commit to ensure that it matches the overwrite row filter. This is used to ensure that writes are idempotent: that files cannot be added during a commit that would not be removed if the operation were run a second time.
validateAddedFiles
in interface OverwriteFiles
public java.util.List<ManifestFile> apply(TableMetadata base)
base
- the base table metadata to apply changes topublic ThisT set(java.lang.String property, java.lang.String value)
SnapshotUpdate
property
- a String property namevalue
- a String property valueprotected PartitionSpec writeSpec()
protected Expression rowFilter()
protected java.util.List<DataFile> addedFiles()
protected void failAnyDelete()
protected void failMissingDeletePaths()
protected void deleteByRowFilter(Expression expr)
expr
- an expression to match rows.protected void dropPartition(StructLike partition)
protected void delete(java.lang.CharSequence path)
protected void add(DataFile file)
protected void add(ManifestFile manifest)
protected java.util.Map<java.lang.String,java.lang.String> summary()
protected void cleanUncommitted(java.util.Set<ManifestFile> committed)
Manifests may not be committed if apply is called more because a commit conflict has occurred. Implementations may keep around manifests because the same changes will be made by both apply calls. This method instructs the implementation to clean up those manifests and passes the paths of the manifests that were actually committed.
committed
- a set of manifest paths that were actually committedpublic ThisT deleteWith(java.util.function.Consumer<java.lang.String> deleteCallback)
SnapshotUpdate
deleteWith
in interface SnapshotUpdate<ThisT>
deleteCallback
- a String consumer used to delete locations.public Snapshot apply()
PendingUpdate
This does not result in a permanent update.
apply
in interface PendingUpdate<Snapshot>
PendingUpdate.commit()
public void commit()
PendingUpdate
Changes are committed by calling the underlying table's commit method.
Once the commit is successful, the updated table will be refreshed.
commit
in interface PendingUpdate<Snapshot>
protected void cleanAll()
protected void deleteFile(java.lang.String path)
protected OutputFile manifestListPath()
protected OutputFile manifestPath(int manifestNumber)
protected long snapshotId()