Class SnapshotManager

Object
io.delta.kernel.internal.snapshot.SnapshotManager

public class SnapshotManager extends Object
  • Constructor Details

    • SnapshotManager

      public SnapshotManager(Path tablePath)
  • Method Details

    • buildLatestSnapshot

      public SnapshotImpl buildLatestSnapshot(Engine engine, SnapshotQueryContext snapshotContext) throws TableNotFoundException
      Construct the latest snapshot for given table.
      Parameters:
      engine - Instance of Engine to use.
      Returns:
      the latest Snapshot of the table
      Throws:
      TableNotFoundException - if the table does not exist
      InvalidTableException - if the table is in an invalid state
    • getSnapshotAt

      public SnapshotImpl getSnapshotAt(Engine engine, long version, SnapshotQueryContext snapshotContext) throws TableNotFoundException
      Construct the snapshot for the given table at the version provided.
      Parameters:
      engine - Instance of Engine to use.
      version - The snapshot version to construct
      Returns:
      a Snapshot of the table at version version
      Throws:
      TableNotFoundException - if the table does not exist
      InvalidTableException - if the table is in an invalid state
    • getSnapshotForTimestamp

      public SnapshotImpl getSnapshotForTimestamp(Engine engine, SnapshotImpl latestSnapshot, long millisSinceEpochUTC, SnapshotQueryContext snapshotContext) throws TableNotFoundException
      Construct the snapshot for the given table at the provided timestamp.
      Parameters:
      engine - Instance of Engine to use.
      millisSinceEpochUTC - timestamp to fetch the snapshot for in milliseconds since the unix epoch
      Returns:
      a Snapshot of the table at the provided timestamp
      Throws:
      TableNotFoundException - if the table does not exist
      InvalidTableException - if the table is in an invalid state
    • verifyDeltaVersionsContiguous

      @VisibleForTesting public static void verifyDeltaVersionsContiguous(List<Long> versions, Path tablePath)
      Verify that a list of delta versions is contiguous.
      Throws:
      InvalidTableException - if the versions are not contiguous
    • getLogSegmentForVersion

      public LogSegment getLogSegmentForVersion(Engine engine, Optional<Long> versionToLoadOpt)
      Generates a LogSegment for the given `versionToLoadOpt`. If no `versionToLoadOpt` is provided, generates a LogSegment for the latest version of the table.

      This primarily consists of three steps:

      1. First, determine the starting checkpoint version that is at or before `versionToLoadOpt`. If no `versionToLoadOpt` is provided, will use the checkpoint pointed to by the _last_checkpoint file.
      2. Second, LIST the _delta_log for all delta and checkpoint files newer than the starting checkpoint version.
      3. Third, process and validate this list of _delta_log files to yield a LogSegment.
    • getLogSegmentForVersion

      public LogSegment getLogSegmentForVersion(Engine engine, Optional<Long> timeTravelVersionOpt, List<ParsedLogData> parsedLogDatas, Optional<Long> maxCatalogVersionOpt)
      [delta-io/delta#4765]: Right now, we only support sorted and contiguous ratified commit log data.
      Parameters:
      timeTravelVersionOpt - the version to time-travel to for a time-travel query
      parsedLogDatas - the parsed log data from the catalog
      maxCatalogVersionOpt - the maximum version ratified by the catalog for catalog managed tables. Empty for file-system managed tables.