Add debug option to disable snapshots, optimize iterate bounds
This commit is contained in:
parent
dc03d25fdc
commit
7e7e1c410b
@ -231,18 +231,6 @@ public sealed abstract class AbstractRocksDBColumn<T extends RocksDB> implements
|
||||
this.keyMayExistGetter = new DBColumnKeyMayExistGetter();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should not modify or move the writerIndex/readerIndex of the key
|
||||
*/
|
||||
static void setIterateBound(LLReadOptions readOpts, IterateBound boundType, Buf key) {
|
||||
byte[] slice = key != null ? requireNonNull(LLUtils.asArray(key)) : null;
|
||||
if (boundType == IterateBound.LOWER) {
|
||||
readOpts.setIterateLowerBound(slice);
|
||||
} else {
|
||||
readOpts.setIterateUpperBound(slice);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should not modify or move the writerIndex/readerIndex of the buffers inside the range
|
||||
*/
|
||||
@ -557,8 +545,10 @@ public sealed abstract class AbstractRocksDBColumn<T extends RocksDB> implements
|
||||
try {
|
||||
ensureOpen();
|
||||
ensureOwned(readOptions);
|
||||
setIterateBound(readOptions, IterateBound.LOWER, min);
|
||||
setIterateBound(readOptions, IterateBound.UPPER, max);
|
||||
assert !readOptions.hasIterateLowerBound() : "ReadOptions has already a range!";
|
||||
assert !readOptions.hasIterateUpperBound() : "ReadOptions has already a range!";
|
||||
readOptions.setIterateLowerBound(min != null ? requireNonNull(LLUtils.asArray(min)) : null);
|
||||
readOptions.setIterateUpperBound(max != null ? requireNonNull(LLUtils.asArray(max)) : null);
|
||||
return readOptions.newIterator(db, cfh, iteratorMetrics);
|
||||
} finally {
|
||||
closeLock.unlockRead(closeReadLock);
|
||||
|
@ -1462,6 +1462,7 @@ public class LLLocalKeyValueDatabase extends Backuppable implements LLKeyValueDa
|
||||
|
||||
@Override
|
||||
public LLSnapshot takeSnapshot() {
|
||||
if (!ALLOW_SNAPSHOTS) throw new UnsupportedOperationException("Snapshots are disabled!");
|
||||
var closeReadLock = closeLock.readLock();
|
||||
try {
|
||||
ensureOpen();
|
||||
|
@ -140,4 +140,12 @@ public final class LLReadOptions extends SimpleResource {
|
||||
public Snapshot snapshot() {
|
||||
return val.snapshot();
|
||||
}
|
||||
|
||||
public boolean hasIterateLowerBound() {
|
||||
return val.iterateLowerBound() != null;
|
||||
}
|
||||
|
||||
public boolean hasIterateUpperBound() {
|
||||
return val.iterateUpperBound() != null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user