Class NotNullShardProvider
- java.lang.Object
-
- com.google.cloud.spanner.watcher.NotNullShardProvider
-
- All Implemented Interfaces:
ShardProvider
public class NotNullShardProvider extends Object implements ShardProvider
AShardProviderthat will add aWHERE ShardId IS NOT NULLclause to the filter of a polling operation.This
ShardProvidercan 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
ShardProviderin 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();
-
-
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 NotNullShardProvidercreate(String column)Creates aNotNullShardProviderthat will filter on the given column.com.google.cloud.spanner.ValuegetShardValue()Always returnsnullas the watcher will always search for changes in all shards.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.cloud.spanner.watcher.ShardProvider
getColumnName
-
-
-
-
Method Detail
-
create
public static NotNullShardProvider create(String column)
Creates aNotNullShardProviderthat will filter on the given column.
-
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()
Always returnsnullas the watcher will always search for changes in all shards.- Specified by:
getShardValuein interfaceShardProvider
-
-