Class SnapshotImpl
- All Implemented Interfaces:
Snapshot
Snapshot.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.delta.kernel.Snapshot
Snapshot.ChecksumWriteMode -
Constructor Summary
ConstructorsConstructorDescriptionSnapshotImpl(Path dataPath, long version, Lazy<LogSegment> lazyLogSegment, LogReplay logReplay, Protocol protocol, Metadata metadata, Committer committer, SnapshotQueryContext snapshotContext, Optional<Long> inCommitTimestampOpt) -
Method Summary
Modifier and TypeMethodDescriptionbuildReplaceTableTransaction(StructType schema, String engineInfo) buildUpdateTableTransaction(String engineInfo, Operation operation) Get the domain metadata map from the log replay, which lazily loads and replays a history of domain metadata actions, resolving them to produce the current state of the domain metadata.getCreateCheckpointIterator(Engine engine) Returns the crc info for the current snapshot if the checksum file is readgetDomainMetadata(String domain) Returns the configuration for the provided domain if it exists in the snapshot.getLatestTransactionVersion(Engine engine, String applicationId) Get the latest transaction version for given applicationId.Get the names of the partition columns in the Delta table at this snapshot.getPath()Returns the clustering columns for this snapshot.Get all table properties for the Delta table at this snapshot.longgetTimestamp(Engine engine) Get the timestamp (in milliseconds since the Unix epoch) of the latest commit in this Snapshot.longPublishes all catalog commits at this table version.booleanReturns true if this snapshot was built as a "latest" snapshot query (i.e., no time-travel parameters were provided).voidwriteCheckpoint(Engine engine) Writes a checkpoint for the current snapshot.voidwriteChecksum(Engine engine, Snapshot.ChecksumWriteMode mode) Writes a checksum file for this snapshot using the specified mode: SIMPLE: Uses pre-computed CRC information already loaded in memory.
-
Constructor Details
-
SnapshotImpl
public SnapshotImpl(Path dataPath, long version, Lazy<LogSegment> lazyLogSegment, LogReplay logReplay, Protocol protocol, Metadata metadata, Committer committer, SnapshotQueryContext snapshotContext, Optional<Long> inCommitTimestampOpt)
-
-
Method Details
-
getPath
-
getVersion
public long getVersion()- Specified by:
getVersionin interfaceSnapshot- Returns:
- the version of this snapshot in the Delta table
-
getPartitionColumnNames
Description copied from interface:SnapshotGet the names of the partition columns in the Delta table at this snapshot.The partition column names are returned in the order they are defined in the Delta table schema. If the table does not define any partition columns, this method returns an empty list.
- Specified by:
getPartitionColumnNamesin interfaceSnapshot- Returns:
- a list of partition column names, or an empty list if the table is not partitioned.
-
getTimestamp
Get the timestamp (in milliseconds since the Unix epoch) of the latest commit in this Snapshot.When InCommitTimestampTableFeature is enabled, the timestamp is retrieved from the CommitInfo of the latest commit in this Snapshot, which can result in an IO operation.
For non-ICT tables, this is the same as the file modification time of the latest commit in this Snapshot.
- Specified by:
getTimestampin interfaceSnapshot- Parameters:
engine- the engine to use for IO operations- Returns:
- the timestamp of the latest commit
-
getSchema
-
getDomainMetadata
Description copied from interface:SnapshotReturns the configuration for the provided domain if it exists in the snapshot. Returns empty if the domain is not present in the snapshot.- Specified by:
getDomainMetadatain interfaceSnapshot- Parameters:
domain- the domain to look up- Returns:
- the domain configuration or empty
-
getTableProperties
Description copied from interface:SnapshotGet all table properties for the Delta table at this snapshot.- Specified by:
getTablePropertiesin interfaceSnapshot- Returns:
- a
Mapof table properties.
-
getStatistics
- Specified by:
getStatisticsin interfaceSnapshot- Returns:
- statistics about this snapshot
-
getScanBuilder
- Specified by:
getScanBuilderin interfaceSnapshot- Returns:
- a scan builder to construct a
Scanto read data from this snapshot
-
buildUpdateTableTransaction
public UpdateTableTransactionBuilder buildUpdateTableTransaction(String engineInfo, Operation operation) - Specified by:
buildUpdateTableTransactionin interfaceSnapshot- Returns:
- a
UpdateTableTransactionBuilderto build an update table transaction
-
publish
Description copied from interface:SnapshotPublishes all catalog commits at this table version. Applicable only to catalog-managed tables. This method is a no-op for filesystem-managed tables, if the committer doesn't support publishing, or if there's no catalog commits to publish.Publishing copies ratified catalog commits to the Delta log as published Delta files, reducing catalog storage requirements and enabling some table maintenance operations, like checkpointing.
- Specified by:
publishin interfaceSnapshot- Parameters:
engine- the engine to use for publishing commits- Returns:
- a new Snapshot reflecting the published state
- Throws:
PublishFailedException- if the publish operation fails- See Also:
-
writeChecksum
Description copied from interface:SnapshotWrites a checksum file for this snapshot using the specified mode:- SIMPLE: Uses pre-computed CRC information already loaded in memory. This is the fastest
approach but requires CRC info to be available. Throws
IllegalStateExceptionif CRC information is not available. - FULL: Computes the necessary CRC information by replaying the delta log since the latest checksum (if present). This may be expensive for large tables when CRC information is not available.
Use
SnapshotStatistics.getChecksumWriteMode()to check if writing is needed and to determine the appropriate mode.This method should only be called if a checksum file does not already exist at this version. If it already does, this method is a no-op.
If a concurrent writer creates the checksum file for this version between when this snapshot was loaded and when this method is called, the method will detect the existing checksum and return successfully without error. This ensures safe concurrent checksum writing.
- Specified by:
writeChecksumin interfaceSnapshot- Parameters:
engine- the engine to use for writing the checksum file and potentially reading the logmode- the mode specifying how to write the checksum (SIMPLE or FULL)- Throws:
IOException- if an I/O error occurs during checksum computation or writing- See Also:
- SIMPLE: Uses pre-computed CRC information already loaded in memory. This is the fastest
approach but requires CRC info to be available. Throws
-
writeCheckpoint
Description copied from interface:SnapshotWrites a checkpoint for the current snapshot.- Specified by:
writeCheckpointin interfaceSnapshot- Parameters:
engine- The execution engine used to write the checkpoint and, if necessary, read log entries required to compute it.- Throws:
IOException- If an I/O error occurs while computing or writing the checkpoint.
-
buildReplaceTableTransaction
public ReplaceTableTransactionBuilder buildReplaceTableTransaction(StructType schema, String engineInfo) -
getCommitter
-
getLogPath
-
getDataPath
-
wasBuiltAsLatest
public boolean wasBuiltAsLatest()Returns true if this snapshot was built as a "latest" snapshot query (i.e., no time-travel parameters were provided). This is intent-based - it indicates what the user requested, not whether the snapshot is actually the latest version. -
getProtocol
-
getSnapshotReport
-
getPhysicalClusteringColumns
Returns the clustering columns for this snapshot.- Optional.empty() - unclustered table (clustering is not enabled)
- Optional.of([]) - clustered table with no clustering columns (clustering is enabled)
- Optional.of([col1, col2]) - clustered table with the given physical clustering columns
- Returns:
- the physical clustering columns in this snapshot
-
getActiveDomainMetadataMap
Get the domain metadata map from the log replay, which lazily loads and replays a history of domain metadata actions, resolving them to produce the current state of the domain metadata. Only active domain metadata are included in this map.- Returns:
- A map where the keys are domain names and the values are
DomainMetadataobjects.
-
getCurrentCrcInfo
Returns the crc info for the current snapshot if the checksum file is read -
getMetadata
-
getLogSegment
-
getLazyLogSegment
-
getCreateCheckpointIterator
-
getLatestTransactionVersion
Get the latest transaction version for given applicationId. This information comes from the transactions identifiers stored in Delta transaction log. This API is not a public API. For now keep this internal to enable Flink upgrade to use Kernel.- Parameters:
applicationId- Identifier of the application that put transaction identifiers in Delta transaction log- Returns:
- Last transaction version or
Optional.empty()if no transaction identifier exists for this application.
-