Interface ShardProvider

  • All Known Implementing Classes:
    FixedShardProvider, TimebasedShardProvider

    public interface ShardProvider
    Interface for providing a shard id for Spanner Table Change watchers. The shard id will be used by the change watcher when querying the table for the most recent changes. This can be used to prevent full table scans when polling a table.

    See https://cloud.google.com/spanner/docs/schema-design#fix_hash_the_key for more information on how logical shards should be implemented in Cloud Spanner.

    • Method Detail

      • appendShardFilter

        void appendShardFilter​(com.google.cloud.spanner.Statement.Builder statementBuilder)
        Appends the required sharding filter to the given statement. This could be an SQL fragment or one or more parameters or a combination of both.
      • getShardValue

        @Nullable
        com.google.cloud.spanner.Value getShardValue()
        Returns the (fixed) value that is used by this ShardProvider. This value will be passed to the CommitTimestampRepository to indicate the last seen commit timestamp for a certain shard. This value will be null if the ShardProvider does not use a fixed value.