super(copyReadOptions(other.nativeHandle_));
this.iterateLowerBoundSlice_ = other.iterateLowerBoundSlice_;
this.iterateUpperBoundSlice_ = other.iterateUpperBoundSlice_;
+ this.timestampSlice_ = other.timestampSlice_;
+ this.iterStartTs_ = other.iterStartTs_;
}
/**
*
* Default: null
*
- * @param iterateLowerBound Slice representing the upper bound
+ * @param iterateLowerBound Slice representing the lower bound
* @return the reference to the current ReadOptions.
*/
- public ReadOptions setIterateLowerBound(final Slice iterateLowerBound) {
+ public ReadOptions setIterateLowerBound(final AbstractSlice<?> iterateLowerBound) {
assert(isOwningHandle());
- if (iterateLowerBound != null) {
- // Hold onto a reference so it doesn't get garbage collected out from under us.
- iterateLowerBoundSlice_ = iterateLowerBound;
- setIterateLowerBound(nativeHandle_, iterateLowerBoundSlice_.getNativeHandle());
- }
+ setIterateLowerBound(
+ nativeHandle_, iterateLowerBound == null ? 0 : iterateLowerBound.getNativeHandle());
+ // Hold onto a reference so it doesn't get garbage collected out from under us.
+ iterateLowerBoundSlice_ = iterateLowerBound;
return this;
}
* @param iterateUpperBound Slice representing the upper bound
* @return the reference to the current ReadOptions.
*/
- public ReadOptions setIterateUpperBound(final Slice iterateUpperBound) {
+ public ReadOptions setIterateUpperBound(final AbstractSlice<?> iterateUpperBound) {
assert(isOwningHandle());
- if (iterateUpperBound != null) {
- // Hold onto a reference so it doesn't get garbage collected out from under us.
- iterateUpperBoundSlice_ = iterateUpperBound;
- setIterateUpperBound(nativeHandle_, iterateUpperBoundSlice_.getNativeHandle());
- }
+ setIterateUpperBound(
+ nativeHandle_, iterateUpperBound == null ? 0 : iterateUpperBound.getNativeHandle());
+ // Hold onto a reference so it doesn't get garbage collected out from under us.
+ iterateUpperBoundSlice_ = iterateUpperBound;
return this;
}
}
/**
- * Needed to support differential snapshots. Has 2 effects:
- * 1) Iterator will skip all internal keys with seqnum < iter_start_seqnum
- * 2) if this param > 0 iterator will return INTERNAL keys instead of user
- * keys; e.g. return tombstones as well.
+ * When true, by default use total_order_seek = true, and RocksDB can
+ * selectively enable prefix seek mode if won't generate a different result
+ * from total_order_seek, based on seek key, and iterator upper bound.
+ * Not supported in ROCKSDB_LITE mode, in the way that even with value true
+ * prefix mode is not used.
+ * Default: false
*
- * Default: 0 (don't filter by seqnum, return user keys)
+ * @return true if auto prefix mode is set.
*
- * @param startSeqnum the starting sequence number.
+ */
+ public boolean autoPrefixMode() {
+ assert (isOwningHandle());
+ return autoPrefixMode(nativeHandle_);
+ }
+
+ /**
+ * When true, by default use total_order_seek = true, and RocksDB can
+ * selectively enable prefix seek mode if won't generate a different result
+ * from total_order_seek, based on seek key, and iterator upper bound.
+ * Not supported in ROCKSDB_LITE mode, in the way that even with value true
+ * prefix mode is not used.
+ * Default: false
+ * @param mode auto prefix mode
+ * @return the reference to the current ReadOptions.
+ */
+ public ReadOptions setAutoPrefixMode(final boolean mode) {
+ assert (isOwningHandle());
+ setAutoPrefixMode(nativeHandle_, mode);
+ return this;
+ }
+
+ /**
+ * Timestamp of operation. Read should return the latest data visible to the
+ * specified timestamp. All timestamps of the same database must be of the
+ * same length and format. The user is responsible for providing a customized
+ * compare function via Comparator to order >key, timestamp> tuples.
+ * For iterator, iter_start_ts is the lower bound (older) and timestamp
+ * serves as the upper bound. Versions of the same record that fall in
+ * the timestamp range will be returned. If iter_start_ts is nullptr,
+ * only the most recent version visible to timestamp is returned.
+ * The user-specified timestamp feature is still under active development,
+ * and the API is subject to change.
*
+ * Default: null
+ * @see #iterStartTs()
+ * @return Reference to timestamp or null if there is no timestamp defined.
+ */
+ public Slice timestamp() {
+ assert (isOwningHandle());
+ final long timestampSliceHandle = timestamp(nativeHandle_);
+ if (timestampSliceHandle != 0) {
+ return new Slice(timestampSliceHandle);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Timestamp of operation. Read should return the latest data visible to the
+ * specified timestamp. All timestamps of the same database must be of the
+ * same length and format. The user is responsible for providing a customized
+ * compare function via Comparator to order {@code <key, timestamp>} tuples.
+ * For iterator, {@code iter_start_ts} is the lower bound (older) and timestamp
+ * serves as the upper bound. Versions of the same record that fall in
+ * the timestamp range will be returned. If iter_start_ts is nullptr,
+ * only the most recent version visible to timestamp is returned.
+ * The user-specified timestamp feature is still under active development,
+ * and the API is subject to change.
+ *
+ * Default: null
+ * @see #setIterStartTs(AbstractSlice)
+ * @param timestamp Slice representing the timestamp
* @return the reference to the current ReadOptions.
*/
- public ReadOptions setIterStartSeqnum(final long startSeqnum) {
- assert(isOwningHandle());
- setIterStartSeqnum(nativeHandle_, startSeqnum);
+ public ReadOptions setTimestamp(final AbstractSlice<?> timestamp) {
+ assert (isOwningHandle());
+ setTimestamp(nativeHandle_, timestamp == null ? 0 : timestamp.getNativeHandle());
+ timestampSlice_ = timestamp;
return this;
}
/**
- * Returns the starting Sequence Number of any iterator.
- * See {@link #setIterStartSeqnum(long)}.
+ * Timestamp of operation. Read should return the latest data visible to the
+ * specified timestamp. All timestamps of the same database must be of the
+ * same length and format. The user is responsible for providing a customized
+ * compare function via Comparator to order {@code <key, timestamp>} tuples.
+ * For iterator, {@code iter_start_ts} is the lower bound (older) and timestamp
+ * serves as the upper bound. Versions of the same record that fall in
+ * the timestamp range will be returned. If iter_start_ts is nullptr,
+ * only the most recent version visible to timestamp is returned.
+ * The user-specified timestamp feature is still under active development,
+ * and the API is subject to change.
*
- * @return the starting sequence number of any iterator.
+ * Default: null
+ * @return Reference to lower bound timestamp or null if there is no lower bound timestamp
+ * defined.
+ */
+ public Slice iterStartTs() {
+ assert (isOwningHandle());
+ final long iterStartTsHandle = iterStartTs(nativeHandle_);
+ if (iterStartTsHandle != 0) {
+ return new Slice(iterStartTsHandle);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Timestamp of operation. Read should return the latest data visible to the
+ * specified timestamp. All timestamps of the same database must be of the
+ * same length and format. The user is responsible for providing a customized
+ * compare function via Comparator to order {@code <key, timestamp>} tuples.
+ * For iterator, {@code iter_start_ts} is the lower bound (older) and timestamp
+ * serves as the upper bound. Versions of the same record that fall in
+ * the timestamp range will be returned. If iter_start_ts is nullptr,
+ * only the most recent version visible to timestamp is returned.
+ * The user-specified timestamp feature is still under active development,
+ * and the API is subject to change.
+ *
+ * Default: null
+ *
+ * @param iterStartTs Reference to lower bound timestamp or null if there is no lower bound
+ * timestamp defined
+ * @return the reference to the current ReadOptions.
*/
- public long iterStartSeqnum() {
- assert(isOwningHandle());
- return iterStartSeqnum(nativeHandle_);
+ public ReadOptions setIterStartTs(final AbstractSlice<?> iterStartTs) {
+ assert (isOwningHandle());
+ setIterStartTs(nativeHandle_, iterStartTs == null ? 0 : iterStartTs.getNativeHandle());
+ iterStartTs_ = iterStartTs;
+ return this;
+ }
+
+ /**
+ * Deadline for completing an API call (Get/MultiGet/Seek/Next for now)
+ * in microseconds.
+ * It should be set to microseconds since epoch, i.e, {@code gettimeofday} or
+ * equivalent plus allowed duration in microseconds. The best way is to use
+ * {@code env->NowMicros() + some timeout}.
+ * This is best efforts. The call may exceed the deadline if there is IO
+ * involved and the file system doesn't support deadlines, or due to
+ * checking for deadline periodically rather than for every key if
+ * processing a batch
+ *
+ * @return deadline time in microseconds
+ */
+ public long deadline() {
+ assert (isOwningHandle());
+ return deadline(nativeHandle_);
+ }
+
+ /**
+ * Deadline for completing an API call (Get/MultiGet/Seek/Next for now)
+ * in microseconds.
+ * It should be set to microseconds since epoch, i.e, {@code gettimeofday} or
+ * equivalent plus allowed duration in microseconds. The best way is to use
+ * {@code env->NowMicros() + some timeout}.
+ * This is best efforts. The call may exceed the deadline if there is IO
+ * involved and the file system doesn't support deadlines, or due to
+ * checking for deadline periodically rather than for every key if
+ * processing a batch
+ *
+ * @param deadlineTime deadline time in microseconds.
+ * @return the reference to the current ReadOptions.
+ */
+ public ReadOptions setDeadline(final long deadlineTime) {
+ assert (isOwningHandle());
+ setDeadline(nativeHandle_, deadlineTime);
+ return this;
+ }
+
+ /**
+ * A timeout in microseconds to be passed to the underlying FileSystem for
+ * reads. As opposed to deadline, this determines the timeout for each
+ * individual file read request. If a MultiGet/Get/Seek/Next etc call
+ * results in multiple reads, each read can last up to io_timeout us.
+ * @return ioTimeout time in microseconds
+ */
+ public long ioTimeout() {
+ assert (isOwningHandle());
+ return ioTimeout(nativeHandle_);
+ }
+
+ /**
+ * A timeout in microseconds to be passed to the underlying FileSystem for
+ * reads. As opposed to deadline, this determines the timeout for each
+ * individual file read request. If a MultiGet/Get/Seek/Next etc call
+ * results in multiple reads, each read can last up to io_timeout us.
+ *
+ * @param ioTimeout time in microseconds.
+ * @return the reference to the current ReadOptions.
+ */
+ public ReadOptions setIoTimeout(final long ioTimeout) {
+ assert (isOwningHandle());
+ setIoTimeout(nativeHandle_, ioTimeout);
+ return this;
+ }
+
+ /**
+ * It limits the maximum cumulative value size of the keys in batch while
+ * reading through MultiGet. Once the cumulative value size exceeds this
+ * soft limit then all the remaining keys are returned with status Aborted.
+ *
+ * Default: {@code std::numeric_limits<uint64_t>::max()}
+ * @return actual valueSizeSofLimit
+ */
+ public long valueSizeSoftLimit() {
+ assert (isOwningHandle());
+ return valueSizeSoftLimit(nativeHandle_);
+ }
+
+ /**
+ * It limits the maximum cumulative value size of the keys in batch while
+ * reading through MultiGet. Once the cumulative value size exceeds this
+ * soft limit then all the remaining keys are returned with status Aborted.
+ *
+ * Default: {@code std::numeric_limits<uint64_t>::max()}
+ *
+ * @param valueSizeSoftLimit the maximum cumulative value size of the keys
+ * @return the reference to the current ReadOptions
+ */
+ public ReadOptions setValueSizeSoftLimit(final long valueSizeSoftLimit) {
+ assert (isOwningHandle());
+ setValueSizeSoftLimit(nativeHandle_, valueSizeSoftLimit);
+ return this;
}
// instance variables
// freely leave scope without us losing the Java Slice object, which during
// close() would also reap its associated rocksdb::Slice native object since
// it's possibly (likely) to be an owning handle.
- private Slice iterateLowerBoundSlice_;
- private Slice iterateUpperBoundSlice_;
+ private AbstractSlice<?> iterateLowerBoundSlice_;
+ private AbstractSlice<?> iterateUpperBoundSlice_;
+ private AbstractSlice<?> timestampSlice_;
+ private AbstractSlice<?> iterStartTs_;
private native static long newReadOptions();
private native static long newReadOptions(final boolean verifyChecksums,
private native void setIterateLowerBound(final long handle,
final long lowerBoundSliceHandle);
private native long iterateLowerBound(final long handle);
- private native void setTableFilter(final long handle,
- final long tableFilterHandle);
- private native void setIterStartSeqnum(final long handle, final long seqNum);
- private native long iterStartSeqnum(final long handle);
+ private native void setTableFilter(final long handle, final long tableFilterHandle);
+ private native boolean autoPrefixMode(final long handle);
+ private native void setAutoPrefixMode(final long handle, final boolean autoPrefixMode);
+ private native long timestamp(final long handle);
+ private native void setTimestamp(final long handle, final long timestampSliceHandle);
+ private native long iterStartTs(final long handle);
+ private native void setIterStartTs(final long handle, final long iterStartTsHandle);
+ private native long deadline(final long handle);
+ private native void setDeadline(final long handle, final long deadlineTime);
+ private native long ioTimeout(final long handle);
+ private native void setIoTimeout(final long handle, final long ioTimeout);
+ private native long valueSizeSoftLimit(final long handle);
+ private native void setValueSizeSoftLimit(final long handle, final long softLimit);
}