public class NotNullShardProvider extends Object implements ShardProvider
ShardProvider that will add a WHERE ShardId IS NOT NULL clause to the
filter of a polling operation.
This ShardProvider can be used in combination with a NULL_FILTERED secondary index on
the ShardId and the commit timestamp columns. The value inserted into the ShardId column can be
anything as long as it is not null.
It is recommended to use this ShardProvider in combination with a table hint that
forces the use of the secondary index during polling. See below for an example.
The value of ShardId can be set to null by another process for rows that have not been updated recently. This will keep the NULL_FILTERED secondary index small as all entries with a null value in one of the index columns will be left out of the secondary index. See https://cloud.google.com/spanner/docs/secondary-indexes#null-indexing-disable for more information on NULL_FILTERED secondary indexes.
Example usage in combination with a SpannerTableTailer:
SpannerTableTailer tailer =
SpannerTableTailer.newBuilder(
spanner, TableId.of(databaseId, "TABLE_NAME"))
.setShardProvider(NotNullShardProvider.create("SHARD_COLUMN"))
.setTableHint("@{FORCE_INDEX=IDX_SHARD_COLUMN_COMMIT_TIMESTAMP}")
.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 NotNullShardProvider |
create(String column)
Creates a
NotNullShardProvider that will filter on the given column. |
com.google.cloud.spanner.Value |
getShardValue()
Always returns
null as the watcher will always search for changes in all shards. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetColumnNamepublic static NotNullShardProvider create(String column)
NotNullShardProvider that will filter on the given column.public void appendShardFilter(com.google.cloud.spanner.Statement.Builder statementBuilder)
ShardProviderappendShardFilter in interface ShardProviderpublic com.google.cloud.spanner.Value getShardValue()
null as the watcher will always search for changes in all shards.getShardValue in interface ShardProviderCopyright © 2022 Google LLC. All rights reserved.