Class BaseRewriteManifests
- java.lang.Object
- 
- org.apache.iceberg.BaseRewriteManifests
 
- 
- All Implemented Interfaces:
- PendingUpdate<Snapshot>,- RewriteManifests,- SnapshotUpdate<RewriteManifests>
 
 public class BaseRewriteManifests extends java.lang.Object implements RewriteManifests 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description RewriteManifestsaddManifest(ManifestFile manifest)Adds amanifest fileto the table.Snapshotapply()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 voidcleanAll()protected voidcleanUncommitted(java.util.Set<ManifestFile> committed)Clean up any uncommitted manifests that were created.RewriteManifestsclusterBy(java.util.function.Function<DataFile,java.lang.Object> func)Groups an existingDataFileby a cluster key produced by a function.voidcommit()Apply the pending changes and commit.protected TableMetadatacurrent()protected voiddeleteFile(java.lang.String path)RewriteManifestsdeleteManifest(ManifestFile manifest)Deletes amanifest filefrom the table.ThisTdeleteWith(java.util.function.Consumer<java.lang.String> deleteCallback)Set a callback to delete files instead of the table's default.protected OutputFilemanifestListPath()protected ManifestReader<DeleteFile>newDeleteManifestReader(ManifestFile manifest)protected ManifestWriter<DeleteFile>newDeleteManifestWriter(PartitionSpec spec)protected OutputFilenewManifestOutput()protected ManifestReader<DataFile>newManifestReader(ManifestFile manifest)protected ManifestWriter<DataFile>newManifestWriter(PartitionSpec spec)protected java.lang.Stringoperation()A string that describes the action that produced the new snapshot.protected TableMetadatarefresh()RewriteManifestsrewriteIf(java.util.function.Predicate<ManifestFile> pred)Determines which existingManifestFilefor the table should be rewritten.protected RewriteManifestsself()RewriteManifestsset(java.lang.String property, java.lang.String value)Set a summary property in the snapshot produced by this update.protected longsnapshotId()ThisTstageOnly()Called to stage a snapshot in table metadata, but not update the current snapshot id.protected java.util.Map<java.lang.String,java.lang.String>summary()protected voidvalidate(TableMetadata currentMetadata)Validate the current metadata.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.iceberg.PendingUpdateapply, commit, updateEvent
 - 
Methods inherited from interface org.apache.iceberg.SnapshotUpdatedeleteWith, stageOnly
 
- 
 
- 
- 
- 
Method Detail- 
selfprotected RewriteManifests self() 
 - 
operationprotected java.lang.String operation() A string that describes the action that produced the new snapshot.- Returns:
- a string operation
 
 - 
setpublic RewriteManifests set(java.lang.String property, java.lang.String value) Description copied from interface:SnapshotUpdateSet a summary property in the snapshot produced by this update.- Specified by:
- setin interface- SnapshotUpdate<RewriteManifests>
- Parameters:
- property- a String property name
- value- a String property value
- Returns:
- this for method chaining
 
 - 
summaryprotected java.util.Map<java.lang.String,java.lang.String> summary() 
 - 
clusterBypublic RewriteManifests clusterBy(java.util.function.Function<DataFile,java.lang.Object> func) Description copied from interface:RewriteManifestsGroups an existingDataFileby a cluster key produced by a function. The cluster key will determine which data file will be associated with a particular manifest. All data files with the same cluster key will be written to the same manifest (unless the file is large and split into multiple files). Manifests deleted viaRewriteManifests.deleteManifest(ManifestFile)or added viaRewriteManifests.addManifest(ManifestFile)are ignored during the rewrite process.- Specified by:
- clusterByin interface- RewriteManifests
- Parameters:
- func- Function used to cluster data files to manifests.
- Returns:
- this for method chaining
 
 - 
rewriteIfpublic RewriteManifests rewriteIf(java.util.function.Predicate<ManifestFile> pred) Description copied from interface:RewriteManifestsDetermines which existingManifestFilefor the table should be rewritten. Manifests that do not match the predicate are kept as-is. If this is not called and no predicate is set, then all manifests will be rewritten.- Specified by:
- rewriteIfin interface- RewriteManifests
- Parameters:
- pred- Predicate used to determine which manifests to rewrite. If true then the manifest file will be included for rewrite. If false then then manifest is kept as-is.
- Returns:
- this for method chaining
 
 - 
deleteManifestpublic RewriteManifests deleteManifest(ManifestFile manifest) Description copied from interface:RewriteManifestsDeletes amanifest filefrom the table.- Specified by:
- deleteManifestin interface- RewriteManifests
- Parameters:
- manifest- a manifest to delete
- Returns:
- this for method chaining
 
 - 
addManifestpublic RewriteManifests addManifest(ManifestFile manifest) Description copied from interface:RewriteManifestsAdds amanifest fileto the table. The added manifest cannot contain new or deleted files.By default, the manifest will be rewritten to ensure all entries have explicit snapshot IDs. In that case, it is always the responsibility of the caller to manage the lifecycle of the original manifest. If manifest entries are allowed to inherit the snapshot ID assigned on commit, the manifest should never be deleted manually if the commit succeeds as it will become part of the table metadata and will be cleaned up on expiry. If the manifest gets merged with others while preparing a new snapshot, it will be deleted automatically if this operation is successful. If the commit fails, the manifest will never be deleted and it is up to the caller whether to delete or reuse it. - Specified by:
- addManifestin interface- RewriteManifests
- Parameters:
- manifest- a manifest to add
- Returns:
- this for method chaining
 
 - 
applypublic java.util.List<ManifestFile> apply(TableMetadata base) Apply the update's changes to the base table metadata and return the new manifest list.- Parameters:
- base- the base table metadata to apply changes to
- Returns:
- a manifest list for the new snapshot.
 
 - 
cleanUncommittedprotected void cleanUncommitted(java.util.Set<ManifestFile> committed) Clean up any uncommitted manifests that were created.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. - Parameters:
- committed- a set of manifest paths that were actually committed
 
 - 
stageOnlypublic ThisT stageOnly() Description copied from interface:SnapshotUpdateCalled to stage a snapshot in table metadata, but not update the current snapshot id.- Specified by:
- stageOnlyin interface- SnapshotUpdate<ThisT>
- Returns:
- this for method chaining
 
 - 
deleteWithpublic ThisT deleteWith(java.util.function.Consumer<java.lang.String> deleteCallback) Description copied from interface:SnapshotUpdateSet a callback to delete files instead of the table's default.- Specified by:
- deleteWithin interface- SnapshotUpdate<ThisT>
- Parameters:
- deleteCallback- a String consumer used to delete locations.
- Returns:
- this for method chaining
 
 - 
validateprotected void validate(TableMetadata currentMetadata) Validate the current metadata.Child operations can override this to add custom validation. - Parameters:
- currentMetadata- current table metadata to validate
 
 - 
applypublic Snapshot apply() Description copied from interface:PendingUpdateApply the pending changes and return the uncommitted changes for validation.This does not result in a permanent update. - Specified by:
- applyin interface- PendingUpdate<ThisT>
- Returns:
- the uncommitted changes that would be committed by calling PendingUpdate.commit()
 
 - 
currentprotected TableMetadata current() 
 - 
refreshprotected TableMetadata refresh() 
 - 
commitpublic void commit() Description copied from interface:PendingUpdateApply the pending changes and commit.Changes are committed by calling the underlying table's commit method. Once the commit is successful, the updated table will be refreshed. - Specified by:
- commitin interface- PendingUpdate<ThisT>
 
 - 
cleanAllprotected void cleanAll() 
 - 
deleteFileprotected void deleteFile(java.lang.String path) 
 - 
manifestListPathprotected OutputFile manifestListPath() 
 - 
newManifestOutputprotected OutputFile newManifestOutput() 
 - 
newManifestWriterprotected ManifestWriter<DataFile> newManifestWriter(PartitionSpec spec) 
 - 
newDeleteManifestWriterprotected ManifestWriter<DeleteFile> newDeleteManifestWriter(PartitionSpec spec) 
 - 
newManifestReaderprotected ManifestReader<DataFile> newManifestReader(ManifestFile manifest) 
 - 
newDeleteManifestReaderprotected ManifestReader<DeleteFile> newDeleteManifestReader(ManifestFile manifest) 
 - 
snapshotIdprotected long snapshotId() 
 
- 
 
-