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.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
|
* 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 {
|
try {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
ensureOwned(readOptions);
|
ensureOwned(readOptions);
|
||||||
setIterateBound(readOptions, IterateBound.LOWER, min);
|
assert !readOptions.hasIterateLowerBound() : "ReadOptions has already a range!";
|
||||||
setIterateBound(readOptions, IterateBound.UPPER, max);
|
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);
|
return readOptions.newIterator(db, cfh, iteratorMetrics);
|
||||||
} finally {
|
} finally {
|
||||||
closeLock.unlockRead(closeReadLock);
|
closeLock.unlockRead(closeReadLock);
|
||||||
|
@ -1462,6 +1462,7 @@ public class LLLocalKeyValueDatabase extends Backuppable implements LLKeyValueDa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LLSnapshot takeSnapshot() {
|
public LLSnapshot takeSnapshot() {
|
||||||
|
if (!ALLOW_SNAPSHOTS) throw new UnsupportedOperationException("Snapshots are disabled!");
|
||||||
var closeReadLock = closeLock.readLock();
|
var closeReadLock = closeLock.readLock();
|
||||||
try {
|
try {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
|
@ -140,4 +140,12 @@ public final class LLReadOptions extends SimpleResource {
|
|||||||
public Snapshot snapshot() {
|
public Snapshot snapshot() {
|
||||||
return val.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