Enum TimebasedShardProvider.Interval

    • Method Detail

      • values

        public static TimebasedShardProvider.Interval[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (TimebasedShardProvider.Interval c : TimebasedShardProvider.Interval.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TimebasedShardProvider.Interval valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getCurrentShardId

        public TimebasedShardProvider.TimebasedShardId getCurrentShardId​(com.google.cloud.spanner.ReadContext readContext)
        Fetches the current shard id from the database. It is the responsibility of all clients that write data to tables that are being watched that the correct shard id is written to the table. Failure to do so will cause the change to be missed by Spanner Change Watchers. The shard id will remain constant during the complete interval that has been chosen. It is therefore possible for clients to cache the current shard id value, as long as the client renews the shard id once the interval has passed. The shard is calculated in UTC, which means that for example a shard id based on DAY will change at the moment that the current system time in UTC changes 23:59 to 00:00.
      • getShardIdExpression

        public String getShardIdExpression()
        Returns the SQL expression that calculates the current shard id. This expression can be included in DML statements to automatically set the current shard id. See Samples#watchTableWithTimebasedShardProviderExample(String, String, String, String) for an example on how to use this.
      • isCyclic

        public boolean isCyclic()
        Returns true if this interval is cyclic, i.e. the same shard id will be generated at later moment again. DAY_OF_WEEK, DAY_OF_MONTH and DAY_OF_YEAR are examples of cyclic intervals.