/** * Returns a timestamp bound that will perform reads and queries at the given timestamp. Unlike * other modes, reads at a specific timestamp are repeatable; the same read at the same timestamp * always returns the same data. If the timestamp is in the future, the read will block until the * specified timestamp, modulo the read's deadline. * * <p>This mode is useful for large scale consistent reads such as mapreduces, or for coordinating * many reads against a consistent snapshot of the data. */ public static TimestampBound ofReadTimestamp(Timestamp timestamp) { return new TimestampBound(Mode.READ_TIMESTAMP, checkNotNull(timestamp), null); }
/** * Returns a timestamp bound that will perform reads and queries at a timestamp chosen to be at * least {@code timestamp}. This is useful for requesting fresher data than some previous read, or * data that is fresh enough to observe the effects of some previously committed transaction whose * timestamp is known. * * <p>Note that this option can only be used in single-use reads and single-use read-only * transactions. */ public static TimestampBound ofMinReadTimestamp(Timestamp timestamp) { return new TimestampBound(Mode.MIN_READ_TIMESTAMP, checkNotNull(timestamp), null); }
/** * Returns a timestamp bound that will perform reads and queries at an exact staleness. The * timestamp is chosen soon after the read is started. * * <p>Guarantees that all writes that have committed more than the specified number of seconds ago * are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the * client's local clock is substantially skewed from Cloud Spanner commit timestamps. * * <p>Useful for reading at nearby replicas without the distributed timestamp negotiation overhead * of {@link #ofMaxStaleness(long, TimeUnit)}. */ public static TimestampBound ofExactStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.EXACT_STALENESS, null, createDuration(num, units)); }
/** * Returns a timestamp bound that will perform reads and queries at a timestamp chosen to be at * most {@code num units} stale. This guarantees that all writes that have committed more than the * specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, * this mode works even if the client's local clock is substantially skewed from Cloud Spanner * commit timestamps. * * <p>Useful for reading the freshest data available at a nearby replica, while bounding the * possible staleness if the local replica has fallen behind. * * <p>Note that this option can only be used in single-use reads and single-use read-only * transactions. */ public static TimestampBound ofMaxStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.MAX_STALENESS, null, createDuration(num, units)); }
/** * Returns a timestamp bound that will perform reads and queries at the given timestamp. Unlike * other modes, reads at a specific timestamp are repeatable; the same read at the same timestamp * always returns the same data. If the timestamp is in the future, the read will block until the * specified timestamp, modulo the read's deadline. * * <p>This mode is useful for large scale consistent reads such as mapreduces, or for coordinating * many reads against a consistent snapshot of the data. */ public static TimestampBound ofReadTimestamp(Timestamp timestamp) { return new TimestampBound(Mode.READ_TIMESTAMP, checkNotNull(timestamp), null); }
/** * Returns a timestamp bound that will perform reads and queries at a timestamp chosen to be at * least {@code timestamp}. This is useful for requesting fresher data than some previous read, or * data that is fresh enough to observe the effects of some previously committed transaction whose * timestamp is known. * * <p>Note that this option can only be used in single-use reads and single-use read-only * transactions. */ public static TimestampBound ofMinReadTimestamp(Timestamp timestamp) { return new TimestampBound(Mode.MIN_READ_TIMESTAMP, checkNotNull(timestamp), null); }
/** * Returns a timestamp bound that will perform reads and queries at an exact staleness. The * timestamp is chosen soon after the read is started. * * <p>Guarantees that all writes that have committed more than the specified number of seconds ago * are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the * client's local clock is substantially skewed from Cloud Spanner commit timestamps. * * <p>Useful for reading at nearby replicas without the distributed timestamp negotiation overhead * of {@link #ofMaxStaleness(long, TimeUnit)}. */ public static TimestampBound ofExactStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.EXACT_STALENESS, null, createDuration(num, units)); }
/** * Returns a timestamp bound that will perform reads and queries at a timestamp chosen to be at * most {@code num units} stale. This guarantees that all writes that have committed more than the * specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, * this mode works even if the client's local clock is substantially skewed from Cloud Spanner * commit timestamps. * * <p>Useful for reading the freshest data available at a nearby replica, while bounding the * possible staleness if the local replica has fallen behind. * * <p>Note that this option can only be used in single-use reads and single-use read-only * transactions. */ public static TimestampBound ofMaxStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.MAX_STALENESS, null, createDuration(num, units)); }