public class FixedShardProvider extends Object implements ShardProvider
ShardProvider that 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.
It can also be used to watch all segments of a table by setting the shard id to an array of all possible values in the shard column.
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();
}
| Modifier and Type | Method and Description |
|---|---|
void |
appendShardFilter(com.google.cloud.spanner.Statement.Builder statementBuilder)
Appends the required sharding filter to the given statement.
|
static FixedShardProvider |
create(String column,
BigDecimal value) |
static FixedShardProvider |
create(String column,
boolean value) |
static FixedShardProvider |
create(String column,
com.google.cloud.ByteArray value) |
static FixedShardProvider |
create(String column,
com.google.cloud.Date value) |
static FixedShardProvider |
create(String column,
double value) |
static FixedShardProvider |
create(String column,
long value) |
static FixedShardProvider |
create(String column,
String value) |
static FixedShardProvider |
create(String column,
com.google.cloud.Timestamp value) |
static FixedShardProvider |
create(String column,
com.google.cloud.spanner.Value value) |
String |
getColumnName()
Returns the name of the column that this shard provider uses.
|
com.google.cloud.spanner.Value |
getShardValue()
Returns the (fixed) value that is used by this
ShardProvider. |
public static FixedShardProvider create(String column, boolean value)
public static FixedShardProvider create(String column, com.google.cloud.ByteArray value)
public static FixedShardProvider create(String column, com.google.cloud.Date value)
public static FixedShardProvider create(String column, double value)
public static FixedShardProvider create(String column, long value)
public static FixedShardProvider create(String column, BigDecimal value)
public static FixedShardProvider create(String column, String value)
public static FixedShardProvider create(String column, com.google.cloud.Timestamp value)
public static FixedShardProvider create(String column, com.google.cloud.spanner.Value value)
public void appendShardFilter(com.google.cloud.spanner.Statement.Builder statementBuilder)
ShardProviderappendShardFilter in interface ShardProviderpublic com.google.cloud.spanner.Value getShardValue()
ShardProviderShardProvider. 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.getShardValue in interface ShardProviderpublic String getColumnName()
ShardProvidergetColumnName in interface ShardProviderCopyright © 2022 Google LLC. All rights reserved.