Class PartitionMetadataDao.InTransactionContext
java.lang.Object
org.apache.beam.sdk.io.gcp.spanner.changestreams.dao.PartitionMetadataDao.InTransactionContext
- Enclosing class:
PartitionMetadataDao
Represents the execution of a read / write transaction in Cloud Spanner.
-
Constructor Summary
ConstructorsConstructorDescriptionInTransactionContext
(String metadataTableName, TransactionContext transaction, Dialect dialect) Constructs a context to execute a user defined function transactionally. -
Method Summary
Modifier and TypeMethodDescriptiongetPartition
(String partitionToken) Fetches the partition metadata row data for the given partition token.insert
(PartitionMetadata row) Inserts the partition metadata.updateToFinished
(String partitionToken) Updates a partition row toPartitionMetadata.State.FINISHED
state.updateToRunning
(String partitionToken) Updates a partition row toPartitionMetadata.State.RUNNING
state.updateToScheduled
(List<String> partitionTokens) Updates multiple partition rows toPartitionMetadata.State.SCHEDULED
state.updateWatermark
(String partitionToken, com.google.cloud.Timestamp watermark) Update the partition watermark to the given timestamp.
-
Constructor Details
-
InTransactionContext
public InTransactionContext(String metadataTableName, TransactionContext transaction, Dialect dialect) Constructs a context to execute a user defined function transactionally.- Parameters:
metadataTableName
- the name of the partition metadata tabletransaction
- the underlying client library transaction to be executeddialect
- the dialect of the database.
-
-
Method Details
-
insert
Inserts the partition metadata.- Parameters:
row
- the partition metadata to be inserted
-
updateToScheduled
Updates multiple partition rows toPartitionMetadata.State.SCHEDULED
state.- Parameters:
partitionTokens
- the partitions' unique identifiers
-
updateToRunning
Updates a partition row toPartitionMetadata.State.RUNNING
state.- Parameters:
partitionToken
- the partition unique identifier
-
updateToFinished
Updates a partition row toPartitionMetadata.State.FINISHED
state.- Parameters:
partitionToken
- the partition unique identifier
-
updateWatermark
Update the partition watermark to the given timestamp.- Parameters:
partitionToken
- the partition unique identifierwatermark
- the new partition watermark- Returns:
- the commit timestamp of the read / write transaction
-
getPartition
Fetches the partition metadata row data for the given partition token.- Parameters:
partitionToken
- the partition unique identifier- Returns:
- the partition metadata for the given token if it exists as a struct. Otherwise, it returns null.
-