Use rocksdb .keyExists
This commit is contained in:
parent
fe0256dbf9
commit
361e2f04f6
|
@ -323,29 +323,8 @@ public sealed abstract class AbstractRocksDBColumn<T extends RocksDB> implements
|
||||||
try {
|
try {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
ensureOwned(readOptions);
|
ensureOwned(readOptions);
|
||||||
int size = RocksDB.NOT_FOUND;
|
|
||||||
byte[] keyBytes = LLUtils.asArray(key);
|
byte[] keyBytes = LLUtils.asArray(key);
|
||||||
Holder<byte[]> data = new Holder<>();
|
return db.keyExists(cfh, readOptions.getUnsafe(), keyBytes);
|
||||||
boolean mayExistHit = false;
|
|
||||||
if (db.keyMayExist(cfh, readOptions.getUnsafe(), keyBytes, data)) {
|
|
||||||
mayExistHit = true;
|
|
||||||
if (data.getValue() != null) {
|
|
||||||
size = data.getValue().length;
|
|
||||||
} else {
|
|
||||||
size = db.get(cfh, readOptions.getUnsafe(), keyBytes, NO_DATA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
boolean found = size != RocksDB.NOT_FOUND;
|
|
||||||
if (found) {
|
|
||||||
readValueFoundWithBloomSimpleBufferSize.record(size);
|
|
||||||
} else {
|
|
||||||
if (mayExistHit) {
|
|
||||||
readValueNotFoundWithMayExistBloomBufferSize.record(0);
|
|
||||||
} else {
|
|
||||||
readValueNotFoundWithBloomBufferSize.record(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
} finally {
|
} finally {
|
||||||
closeLock.unlockRead(closeReadLock);
|
closeLock.unlockRead(closeReadLock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue