This commit is contained in:
Andrea Cavalli 2022-02-02 23:29:11 +01:00
parent dfe8361e19
commit 7b66259da6
2 changed files with 5 additions and 8 deletions

View File

@ -287,7 +287,7 @@ public class LLLocalDictionary implements LLDictionary {
assert !Schedulers.isInNonBlockingThread() : "Called isRangeEmpty in a nonblocking thread";
startedContains.increment();
try {
var result = containsTime.recordCallable(() -> {
Boolean isRangeEmpty = containsTime.recordCallable(() -> {
if (range.isSingle()) {
return !containsKey(snapshot, range.getSingleUnsafe());
} else {
@ -330,7 +330,7 @@ public class LLLocalDictionary implements LLDictionary {
rocksIterator.seekToFirst();
}
rocksIterator.status();
return rocksIterator.isValid();
return !rocksIterator.isValid();
}
} finally {
if (slice1 != null) {
@ -342,8 +342,8 @@ public class LLLocalDictionary implements LLDictionary {
}
}
});
assert result != null;
sink.next(!result);
assert isRangeEmpty != null;
sink.next(isRangeEmpty);
} catch (RocksDBException ex) {
sink.error(new RocksDBException("Failed to read range " + LLUtils.toStringSafe(range)
+ ": " + ex.getMessage()));

View File

@ -515,10 +515,7 @@ public class LLMemoryDictionary implements LLDictionary {
@Override
public Mono<Boolean> isRangeEmpty(@Nullable LLSnapshot snapshot, Mono<Send<LLRange>> rangeMono, boolean fillCache) {
return getRangeKeys(snapshot, rangeMono)
.map(buf -> {
buf.receive().close();
return true;
})
.doOnNext(buf -> buf.receive().close())
.count()
.map(count -> count == 0);
}