Class SnapshotBuilderImpl

Object
io.delta.kernel.internal.table.SnapshotBuilderImpl
All Implemented Interfaces:
SnapshotBuilder

public class SnapshotBuilderImpl extends Object implements SnapshotBuilder
An implementation of SnapshotBuilder.

Note: The primary responsibility of this class is to take input, validate that input, and then pass the input to the SnapshotFactory, which is then responsible for actually creating the Snapshot instance.

  • Constructor Details

    • SnapshotBuilderImpl

      public SnapshotBuilderImpl(String unresolvedPath)
  • Method Details

    • atVersion

      public SnapshotBuilderImpl atVersion(long version)
      Description copied from interface: SnapshotBuilder
      Configures the builder to resolve the table at a specific version.

      This method is mutually exclusive with SnapshotBuilder.atTimestamp(long, Snapshot). If both are called, an IllegalArgumentException will be thrown.

      Specified by:
      atVersion in interface SnapshotBuilder
      Parameters:
      version - the version number to resolve to
      Returns:
      a new builder instance configured for the specified version
    • atTimestamp

      public SnapshotBuilderImpl atTimestamp(long millisSinceEpochUTC, Snapshot latestSnapshot)
      Description copied from interface: SnapshotBuilder
      Configures the builder to resolve the table at a specific timestamp.

      This returns a Snapshot for the latest version of the table that was committed before or at the given timestamp. Specifically:

      • If a commit version exactly matches the provided timestamp, the snapshot at that version is resolved.
      • Otherwise, the latest commit version with a timestamp less than the provided one is resolved.
      • If the provided timestamp is less than the timestamp of any committed version, snapshot resolution will fail.
      • If the provided timestamp is after (strictly greater than) the timestamp of the latest version of the table, snapshot resolution will fail.

      This method is mutually exclusive with SnapshotBuilder.atVersion(long). If both are called, an IllegalArgumentException will be thrown.

      Specified by:
      atTimestamp in interface SnapshotBuilder
      Parameters:
      millisSinceEpochUTC - timestamp to resolve the snapshot for in milliseconds since the unix epoch
      Returns:
      a new builder instance configured for the specified timestamp
    • withCommitter

      public SnapshotBuilderImpl withCommitter(Committer committer)
      Description copied from interface: SnapshotBuilder
      Provides a custom committer to use at transaction commit time.

      Catalog implementations that wish to support the catalogManaged Delta table feature should provide to engines their own catalog-specific Committer implementation which may, for example, send a commit RPC to the catalog service to finalize the commit.

      If no committer is provided, a default committer will be created that only supports writing into filesystem-managed Delta tables.

      Specified by:
      withCommitter in interface SnapshotBuilder
      Parameters:
      committer - the committer to use
      Returns:
      a new builder instance with the provided committer
      See Also:
    • withLogData

      public SnapshotBuilderImpl withLogData(List<ParsedLogData> logDatas)
      Description copied from interface: SnapshotBuilder
      Provides parsed log data to optimize table resolution.

      When log data is provided, Kernel can avoid reading from the filesystem for information that is already available in the parsed data, improving performance. Currently, only ratified staged commits are supported.

      Specified by:
      withLogData in interface SnapshotBuilder
      Parameters:
      logDatas - the parsed log data to use for optimization
      Returns:
      a new builder instance with the provided log data
    • withProtocolAndMetadata

      public SnapshotBuilderImpl withProtocolAndMetadata(Protocol protocol, Metadata metadata)
      Description copied from interface: SnapshotBuilder
      Provides protocol and metadata information to optimize table resolution.

      When protocol and metadata are provided, Kernel can avoid reading this information from the filesystem, improving performance.

      Specified by:
      withProtocolAndMetadata in interface SnapshotBuilder
      Parameters:
      protocol - the protocol information
      metadata - the metadata information
      Returns:
      a new builder instance with the provided protocol and metadata
    • withMaxCatalogVersion

      public SnapshotBuilderImpl withMaxCatalogVersion(long version)
      Description copied from interface: SnapshotBuilder
      Specifies the maximum table version known by the catalog.

      This method is used by catalog implementations for catalog-managed Delta tables to indicate the latest ratified version of the table. This ensures that any snapshot resolution operations respect the catalog's view of the table state.

      Important: This method is required for catalog-managed tables and must not be used for file-system managed tables. An IllegalArgumentException will be thrown at build time if this constraint is violated.

      When specified, the following additional constraints are enforced:

      Specified by:
      withMaxCatalogVersion in interface SnapshotBuilder
      Parameters:
      version - the maximum table version known by the catalog (must be >= 0)
      Returns:
      a new builder instance with the specified max catalog version
    • build

      public SnapshotImpl build(Engine engine)
      Description copied from interface: SnapshotBuilder
      Constructs the Snapshot using the provided engine.

      This method will read any missing information from the filesystem using the provided engine to complete the snapshot resolution process.

      Specified by:
      build in interface SnapshotBuilder
      Parameters:
      engine - the engine to use for filesystem operations
      Returns:
      the resolved snapshot instance