Class PartitionMetadataDao.InTransactionContext

  • Enclosing class:
    PartitionMetadataDao

    public static class PartitionMetadataDao.InTransactionContext
    extends java.lang.Object
    Represents the execution of a read / write transaction in Cloud Spanner.
    • Constructor Summary

      Constructors 
      Constructor Description
      InTransactionContext​(java.lang.String metadataTableName, com.google.cloud.spanner.TransactionContext transaction, com.google.cloud.spanner.Dialect dialect)
      Constructs a context to execute a user defined function transactionally.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.cloud.spanner.Struct getPartition​(java.lang.String composedPartitionToken)
      Fetches the partition metadata row data for the given composedPartitionToken.
      java.lang.Void insert​(java.util.List<PartitionMetadata> rows)
      Inserts the partition metadata in batch.
      java.lang.Void insert​(PartitionMetadata row)
      Inserts the partition metadata.
      java.lang.Void updateToFinished​(java.lang.String composedPartitionToken)
      Updates a partition row to PartitionMetadata.State.FINISHED state.
      java.lang.Void updateToRunning​(java.lang.String composedPartitionToken)
      Updates a partition row to PartitionMetadata.State.RUNNING state.
      java.lang.Void updateToScheduled​(java.util.List<java.lang.String> composedPartitionTokens)
      Updates multiple partition rows to PartitionMetadata.State.SCHEDULED state.
      java.lang.Void updateWatermark​(java.lang.String composedPartitionToken, com.google.cloud.Timestamp watermark)
      Update the partition watermark to the given timestamp iff the partition watermark in metadata table is smaller than the given watermark.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InTransactionContext

        public InTransactionContext​(java.lang.String metadataTableName,
                                    com.google.cloud.spanner.TransactionContext transaction,
                                    com.google.cloud.spanner.Dialect dialect)
        Constructs a context to execute a user defined function transactionally.
        Parameters:
        metadataTableName - the name of the partition metadata table
        transaction - the underlying client library transaction to be executed
        dialect - the dialect of the database.
    • Method Detail

      • insert

        public java.lang.Void insert​(PartitionMetadata row)
        Inserts the partition metadata.
        Parameters:
        row - the partition metadata to be inserted
      • insert

        public java.lang.Void insert​(java.util.List<PartitionMetadata> rows)
        Inserts the partition metadata in batch.
        Parameters:
        rows - the partition metadata objects to be inserted
      • updateToScheduled

        public java.lang.Void updateToScheduled​(java.util.List<java.lang.String> composedPartitionTokens)
        Updates multiple partition rows to PartitionMetadata.State.SCHEDULED state.
        Parameters:
        composedPartitionTokens - the partitions' unique identifiers
      • updateToRunning

        public java.lang.Void updateToRunning​(java.lang.String composedPartitionToken)
        Updates a partition row to PartitionMetadata.State.RUNNING state.
        Parameters:
        composedPartitionToken - the partition unique identifier
      • updateToFinished

        public java.lang.Void updateToFinished​(java.lang.String composedPartitionToken)
        Updates a partition row to PartitionMetadata.State.FINISHED state.
        Parameters:
        composedPartitionToken - the partition unique identifier
      • updateWatermark

        public java.lang.Void updateWatermark​(java.lang.String composedPartitionToken,
                                              com.google.cloud.Timestamp watermark)
        Update the partition watermark to the given timestamp iff the partition watermark in metadata table is smaller than the given watermark.
        Parameters:
        composedPartitionToken - the partition unique identifier
        watermark - the new partition watermark
        Returns:
        the commit timestamp of the read / write transaction
      • getPartition

        @Nullable
        public com.google.cloud.spanner.Struct getPartition​(java.lang.String composedPartitionToken)
        Fetches the partition metadata row data for the given composedPartitionToken.
        Parameters:
        composedPartitionToken - the partition unique identifier
        Returns:
        the partition metadata for the given composedPartitionToken if it exists as a struct. Otherwise, it returns null.