Class BaseRewriteManifests

    • Method Detail

      • operation

        protected java.lang.String operation()
        A string that describes the action that produced the new snapshot.
        Returns:
        a string operation
      • set

        public RewriteManifests set​(java.lang.String property,
                                    java.lang.String value)
        Description copied from interface: SnapshotUpdate
        Set a summary property in the snapshot produced by this update.
        Specified by:
        set in interface SnapshotUpdate<RewriteManifests>
        Parameters:
        property - a String property name
        value - a String property value
        Returns:
        this for method chaining
      • summary

        protected java.util.Map<java.lang.String,​java.lang.String> summary()
      • rewriteIf

        public RewriteManifests rewriteIf​(java.util.function.Predicate<ManifestFile> pred)
        Description copied from interface: RewriteManifests
        Determines which existing ManifestFile for 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:
        rewriteIf in 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
      • addManifest

        public RewriteManifests addManifest​(ManifestFile manifest)
        Description copied from interface: RewriteManifests
        Adds a manifest file to 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:
        addManifest in interface RewriteManifests
        Parameters:
        manifest - a manifest to add
        Returns:
        this for method chaining
      • apply

        public 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.
      • cleanUncommitted

        protected 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
      • stageOnly

        public ThisT stageOnly()
        Description copied from interface: SnapshotUpdate
        Called to stage a snapshot in table metadata, but not update the current snapshot id.
        Specified by:
        stageOnly in interface SnapshotUpdate<ThisT>
        Returns:
        this for method chaining
      • deleteWith

        public ThisT deleteWith​(java.util.function.Consumer<java.lang.String> deleteCallback)
        Description copied from interface: SnapshotUpdate
        Set a callback to delete files instead of the table's default.
        Specified by:
        deleteWith in interface SnapshotUpdate<ThisT>
        Parameters:
        deleteCallback - a String consumer used to delete locations.
        Returns:
        this for method chaining
      • validate

        protected void validate​(TableMetadata currentMetadata)
        Validate the current metadata.

        Child operations can override this to add custom validation.

        Parameters:
        currentMetadata - current table metadata to validate
      • apply

        public Snapshot apply()
        Description copied from interface: PendingUpdate
        Apply the pending changes and return the uncommitted changes for validation.

        This does not result in a permanent update.

        Specified by:
        apply in interface PendingUpdate<ThisT>
        Returns:
        the uncommitted changes that would be committed by calling PendingUpdate.commit()
      • commit

        public void commit()
        Description copied from interface: PendingUpdate
        Apply 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:
        commit in interface PendingUpdate<ThisT>
      • cleanAll

        protected void cleanAll()
      • deleteFile

        protected void deleteFile​(java.lang.String path)
      • manifestListPath

        protected OutputFile manifestListPath()
      • newManifestOutput

        protected OutputFile newManifestOutput()
      • snapshotId

        protected long snapshotId()