Package com.google.cloud.spanner.watcher
Class TimebasedShardProvider
- java.lang.Object
-
- com.google.cloud.spanner.watcher.TimebasedShardProvider
-
- All Implemented Interfaces:
ShardProvider
public final class TimebasedShardProvider extends Object implements ShardProvider
Implementation ofShardProviderthat generates aShardIdbased on the current system time of Cloud Spanner. The generated shard id groups a set of commit timestamps together. TheTimebasedShardProvidercan only be used when all clients that write to the tables that are being watched update the shard column with the most recent shard id for each update that is written to the tables.- See Also:
for an example on how to use this .
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimebasedShardProvider.Intervalstatic classTimebasedShardProvider.TimebasedShardIdA generated timebased shard id that has been fetched from Cloud Spanner.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendShardFilter(com.google.cloud.spanner.Statement.Builder statement)Appends the required sharding filter to the given statement.static TimebasedShardProvidercreate(String column, TimebasedShardProvider.Interval interval)Creates aTimebasedShardProviderfor the given database column and interval.com.google.cloud.spanner.ValuegetShardValue()Returns the (fixed) value that is used by thisShardProvider.
-
-
-
Method Detail
-
create
public static TimebasedShardProvider create(String column, TimebasedShardProvider.Interval interval)
Creates aTimebasedShardProviderfor the given database column and interval.
-
appendShardFilter
public void appendShardFilter(com.google.cloud.spanner.Statement.Builder statement)
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
@Nullable 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
-
-