public static enum TimebasedShardProvider.Interval extends Enum<TimebasedShardProvider.Interval>
| Enum Constant and Description |
|---|
DAY
Creates a shard for each unique date.
|
DAY_OF_MONTH
Creates a cyclic shard for each day of month (1-31).
|
DAY_OF_WEEK
Creates a cyclic shard for each weekday (1-7).
|
DAY_OF_YEAR
Creates a cyclic shard for each day of year (1-366).
|
HOUR_OF_DAY
Creates a cyclic shard for each hour of a day (0-23).
|
MINUTE_OF_HOUR
MINUTE_OF_HOUR is mainly intended for testing purposes. |
MONTH
Creates a shard for each month and year.
|
WEEK
Creates a shard for each week and year.
|
WEEK_OF_YEAR
Creates a cyclic shard for each week of year (1-53).
|
YEAR
Creates a shard for each year.
|
| Modifier and Type | Method and Description |
|---|---|
TimebasedShardProvider.TimebasedShardId |
getCurrentShardId(com.google.cloud.spanner.ReadContext readContext)
Fetches the current shard id from the database.
|
String |
getShardIdExpression()
Returns the SQL expression that calculates the current shard id.
|
boolean |
isCyclic()
Returns true if this interval is cyclic, i.e.
|
static TimebasedShardProvider.Interval |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static TimebasedShardProvider.Interval[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final TimebasedShardProvider.Interval DAY
public static final TimebasedShardProvider.Interval WEEK
public static final TimebasedShardProvider.Interval MONTH
public static final TimebasedShardProvider.Interval YEAR
public static final TimebasedShardProvider.Interval MINUTE_OF_HOUR
MINUTE_OF_HOUR is mainly intended for testing purposes. Creates a cyclic shard for
each minute of an hour (0-59). Using MINUTE_OF_HOUR means that the shard value will
change very frequently, and transactions that run longer than 1 minute will potentially
receive the wrong shard value.public static final TimebasedShardProvider.Interval HOUR_OF_DAY
public static final TimebasedShardProvider.Interval DAY_OF_WEEK
public static final TimebasedShardProvider.Interval DAY_OF_MONTH
public static final TimebasedShardProvider.Interval WEEK_OF_YEAR
public static final TimebasedShardProvider.Interval DAY_OF_YEAR
public static TimebasedShardProvider.Interval[] values()
for (TimebasedShardProvider.Interval c : TimebasedShardProvider.Interval.values()) System.out.println(c);
public static TimebasedShardProvider.Interval valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic TimebasedShardProvider.TimebasedShardId getCurrentShardId(com.google.cloud.spanner.ReadContext readContext)
DAY will change at the moment that the
current system time in UTC changes 23:59 to 00:00.public String getShardIdExpression()
Samples#watchTableWithTimebasedShardProviderExample(String, String, String, String) for an
example on how to use this.public boolean isCyclic()
DAY_OF_WEEK, DAY_OF_MONTH and DAY_OF_YEAR are examples of cyclic intervals.Copyright © 2022 Google LLC. All rights reserved.