This commit is contained in:
Andrea Cavalli 2021-05-03 12:44:22 +02:00
parent 7588cd3219
commit 91cc7b9291

View File

@ -796,7 +796,7 @@ public class LLLocalDictionary implements LLDictionary {
batch.close(); batch.close();
} else { } else {
for (Entry<ByteBuf, ByteBuf> entry : entriesWindow) { for (Entry<ByteBuf, ByteBuf> entry : entriesWindow) {
db.put(cfh, LLUtils.toArray(entry.getKey()), LLUtils.toArray(entry.getValue())); db.put(cfh, EMPTY_WRITE_OPTIONS, entry.getKey().nioBuffer(), entry.getValue().nioBuffer());
} }
} }
return null; return null;
@ -1191,8 +1191,7 @@ public class LLLocalDictionary implements LLDictionary {
rocksIterator.seekToFirst(); rocksIterator.seekToFirst();
} }
while (rocksIterator.isValid()) { while (rocksIterator.isValid()) {
var b = LLUtils.toArray(LLUtils.readDirectNioBuffer(alloc, rocksIterator::key)); writeBatch.delete(cfh, LLUtils.readDirectNioBuffer(alloc, rocksIterator::key));
writeBatch.delete(cfh, b);
rocksIterator.next(); rocksIterator.next();
} }
} finally { } finally {
@ -1213,26 +1212,20 @@ public class LLLocalDictionary implements LLDictionary {
readOpts.setFillCache(false); readOpts.setFillCache(false);
ReleasableSlice minBound; ReleasableSlice minBound;
if (range.hasMin()) { if (range.hasMin()) {
var arr = LLUtils.toArray(range.getMin()); minBound = setIterateBound(readOpts, IterateBound.LOWER, range.getMin().retain());
var minSlice = new Slice(arr);
readOpts.setIterateLowerBound(minSlice);
minBound = new ReleasableSlice(minSlice, null, arr);
} else { } else {
minBound = emptyReleasableSlice(); minBound = emptyReleasableSlice();
} }
try { try {
ReleasableSlice maxBound; ReleasableSlice maxBound;
if (range.hasMax()) { if (range.hasMax()) {
var arr = LLUtils.toArray(range.getMax()); maxBound = setIterateBound(readOpts, IterateBound.UPPER, range.getMax().retain());
var maxSlice = new Slice(arr);
readOpts.setIterateUpperBound(maxSlice);
maxBound = new ReleasableSlice(maxSlice, null, arr);
} else { } else {
maxBound = emptyReleasableSlice(); maxBound = emptyReleasableSlice();
} }
try (var rocksIterator = db.newIterator(cfh, readOpts)) { try (var rocksIterator = db.newIterator(cfh, readOpts)) {
if (!LLLocalDictionary.PREFER_SEEK_TO_FIRST && range.hasMin()) { if (!LLLocalDictionary.PREFER_SEEK_TO_FIRST && range.hasMin()) {
rocksIterator.seek(LLUtils.toArray(range.getMin())); rocksIterSeekTo(rocksIterator, range.getMin().retain());
} else { } else {
rocksIterator.seekToFirst(); rocksIterator.seekToFirst();
} }