Package io.delta.kernel.internal
Class TransactionImpl
Object
io.delta.kernel.internal.TransactionImpl
- All Implemented Interfaces:
Transaction
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionTransactionImpl
(boolean isCreateOrReplace, Path dataPath, Path logPath, SnapshotImpl readSnapshot, String engineInfo, Operation operation, Protocol protocol, Metadata metadata, Optional<SetTransaction> setTxnOpt, Optional<List<Column>> clusteringColumnsOpt, boolean shouldUpdateMetadata, boolean shouldUpdateProtocol, int maxRetries, int logCompactionInterval, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDomainMetadata
(String domain, String config) Commit the provided domain metadata as part of this transaction.void
addDomainMetadataInternal
(String domain, String config) commit
(Engine engine, CloseableIterable<Row> dataActions) Commit the transaction including the data action rows generated byTransaction.generateAppendActions(io.delta.kernel.engine.Engine, io.delta.kernel.data.Row, io.delta.kernel.utils.CloseableIterator<io.delta.kernel.utils.DataFileStatus>, io.delta.kernel.DataWriteContext)
.getPartitionColumns
(Engine engine) Get the list of logical names of the partition columns.long
Gets the latest version of the table used as the base of this transaction.Get the schema of the table.getStatisticsColumns
(Row transactionState) Get the part of the schema of the table that needs the statistics to be collected per file.getTransactionState
(Engine engine) Get the state of the transaction.boolean
void
removeDomainMetadata
(String domain) Mark the domain metadata with identifierdomain
as removed in this transaction.void
removeDomainMetadataInternal
(String domain)
-
Field Details
-
DEFAULT_READ_VERSION
public static final int DEFAULT_READ_VERSION- See Also:
-
DEFAULT_WRITE_VERSION
public static final int DEFAULT_WRITE_VERSION- See Also:
-
-
Constructor Details
-
TransactionImpl
public TransactionImpl(boolean isCreateOrReplace, Path dataPath, Path logPath, SnapshotImpl readSnapshot, String engineInfo, Operation operation, Protocol protocol, Metadata metadata, Optional<SetTransaction> setTxnOpt, Optional<List<Column>> clusteringColumnsOpt, boolean shouldUpdateMetadata, boolean shouldUpdateProtocol, int maxRetries, int logCompactionInterval, Clock clock)
-
-
Method Details
-
getTransactionState
Description copied from interface:Transaction
Get the state of the transaction. The state helps Kernel do the transformations to logical data according to the Delta protocol and table features enabled on the table. The engine should use this at the data writer task to transform the logical data that the engine wants to write to the table in to physical data that goes in data files usingTransaction.transformLogicalData(Engine, Row, CloseableIterator, Map)
- Specified by:
getTransactionState
in interfaceTransaction
-
getPartitionColumns
Description copied from interface:Transaction
Get the list of logical names of the partition columns. This helps the connector to do physical partitioning of the data before asking the Kernel to stage the data per partition.- Specified by:
getPartitionColumns
in interfaceTransaction
-
getSchema
Description copied from interface:Transaction
Get the schema of the table. If the connector is adding any data to the table through this transaction, it should have the same schema as the table schema.- Specified by:
getSchema
in interfaceTransaction
-
getReadTableVersion
public long getReadTableVersion()Description copied from interface:Transaction
Gets the latest version of the table used as the base of this transaction. This returns -1 when the table is being created in this transaction.- Specified by:
getReadTableVersion
in interfaceTransaction
- Returns:
- The version of the table as of the beginning of this Transaction
-
getSetTxnOpt
-
addDomainMetadataInternal
-
addDomainMetadata
Description copied from interface:Transaction
Commit the provided domain metadata as part of this transaction. If this is called more than once with the samedomain
the latest providedconfig
will be committed in the transaction. Only user-controlled domains are allowed (aka. domains with a `delta.` prefix are not allowed). Adding and removing a domain with the same identifier in the same txn is not allowed. Adding domain metadata to a table that does not support the table feature is not allowed. To enable the table feature, make sure to callTransactionBuilder.withDomainMetadataSupported()
- Specified by:
addDomainMetadata
in interfaceTransaction
- Parameters:
domain
- the domain identifierconfig
- configuration string for this domain
-
removeDomainMetadataInternal
-
removeDomainMetadata
Description copied from interface:Transaction
Mark the domain metadata with identifierdomain
as removed in this transaction. If this domain does not exist in the latest version of the table, callingTransaction.commit(Engine, CloseableIterable)
will throw aDomainDoesNotExistException
. Adding and removing a domain with the same identifier in one txn is not allowed.- Specified by:
removeDomainMetadata
in interfaceTransaction
- Parameters:
domain
- the domain identifier for the domain to remove
-
getProtocol
-
commit
public TransactionCommitResult commit(Engine engine, CloseableIterable<Row> dataActions) throws ConcurrentWriteException Description copied from interface:Transaction
Commit the transaction including the data action rows generated byTransaction.generateAppendActions(io.delta.kernel.engine.Engine, io.delta.kernel.data.Row, io.delta.kernel.utils.CloseableIterator<io.delta.kernel.utils.DataFileStatus>, io.delta.kernel.DataWriteContext)
.- Specified by:
commit
in interfaceTransaction
- Parameters:
engine
-Engine
instance.dataActions
- Iterable of data actions to commit. These data actions are generated by theTransaction.generateAppendActions(Engine, Row, CloseableIterator, DataWriteContext)
. TheCloseableIterable
allows the Kernel to access the list of actions multiple times (in case of retries to resolve the conflicts due to other writers to the table). Kernel provides a in-memory based implementation ofCloseableIterable
with utility APICloseableIterable.inMemoryIterable(CloseableIterator)
- Returns:
TransactionCommitResult
status of the successful transaction.- Throws:
ConcurrentWriteException
- when the transaction has encountered a non-retryable conflicts or exceeded the maximum number of retries reached. The connector needs to rerun the query on top of the latest table state and retry the transaction.
-
isBlindAppend
public boolean isBlindAppend() -
getStatisticsColumns
Get the part of the schema of the table that needs the statistics to be collected per file.- Parameters:
transactionState
- State of the transaction.- Returns:
-