Package com.google.cloud.spanner.watcher
Class FixedShardProvider
- java.lang.Object
-
- com.google.cloud.spanner.watcher.FixedShardProvider
-
- All Implemented Interfaces:
ShardProvider
public final class FixedShardProvider extends Object implements ShardProvider
Implementation ofShardProviderthat returns a fixed shard id. This can be used in combination with multiple change watchers, where each change watcher is responsible for watching a specific segment of the table.Example usage in combination with a
SpannerTableTailer:String shards = new String[] {"EAST", "WEST"}; for (String shard : shards) { SpannerTableTailer tailer = SpannerTableTailer.newBuilder( spanner, TableId.of(databaseId, "TABLE_NAME")) .setShardProvider(FixedShardProvider.create("SHARD_COLUMN", shard)) .build(); }
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendShardFilter(com.google.cloud.spanner.Statement.Builder statementBuilder)Appends the required sharding filter to the given statement.static FixedShardProvidercreate(String column, boolean value)static FixedShardProvidercreate(String column, double value)static FixedShardProvidercreate(String column, long value)static FixedShardProvidercreate(String column, com.google.cloud.ByteArray value)static FixedShardProvidercreate(String column, com.google.cloud.Date value)static FixedShardProvidercreate(String column, com.google.cloud.spanner.Value value)static FixedShardProvidercreate(String column, com.google.cloud.Timestamp value)static FixedShardProvidercreate(String column, String value)com.google.cloud.spanner.ValuegetShardValue()Returns the (fixed) value that is used by thisShardProvider.
-
-
-
Method Detail
-
create
public static FixedShardProvider create(String column, boolean value)
-
create
public static FixedShardProvider create(String column, com.google.cloud.ByteArray value)
-
create
public static FixedShardProvider create(String column, com.google.cloud.Date value)
-
create
public static FixedShardProvider create(String column, double value)
-
create
public static FixedShardProvider create(String column, long value)
-
create
public static FixedShardProvider create(String column, String value)
-
create
public static FixedShardProvider create(String column, com.google.cloud.Timestamp value)
-
create
public static FixedShardProvider create(String column, com.google.cloud.spanner.Value value)
-
appendShardFilter
public void appendShardFilter(com.google.cloud.spanner.Statement.Builder statementBuilder)
Description copied from interface:ShardProviderAppends the required sharding filter to the given statement. This could be an SQL fragment or one or more parameters or a combination of both.- Specified by:
appendShardFilterin interfaceShardProvider
-
getShardValue
public com.google.cloud.spanner.Value getShardValue()
Description copied from interface:ShardProviderReturns the (fixed) value that is used by thisShardProvider. This value will be passed to theCommitTimestampRepositoryto indicate the last seen commit timestamp for a certain shard. This value will benullif theShardProviderdoes not use a fixed value.- Specified by:
getShardValuein interfaceShardProvider
-
-