Bugfix
This commit is contained in:
parent
0e7df84c38
commit
a720a12701
@ -156,6 +156,17 @@ public class LLRange extends ResourceSupport<LLRange, LLRange> {
|
||||
}
|
||||
}
|
||||
|
||||
public Buffer getMinCopy() {
|
||||
ensureOwned();
|
||||
if (min != null) {
|
||||
return min.copy();
|
||||
} else if (single != null) {
|
||||
return single.copy();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMax() {
|
||||
ensureOwned();
|
||||
return max != null || single != null;
|
||||
@ -185,6 +196,17 @@ public class LLRange extends ResourceSupport<LLRange, LLRange> {
|
||||
}
|
||||
}
|
||||
|
||||
public Buffer getMaxCopy() {
|
||||
ensureOwned();
|
||||
if (max != null) {
|
||||
return max.copy();
|
||||
} else if (single != null) {
|
||||
return single.copy();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Send<Buffer> getSingle() {
|
||||
ensureOwned();
|
||||
assert isSingle();
|
||||
|
@ -1,5 +1,7 @@
|
||||
package it.cavallium.dbengine.database.collections;
|
||||
|
||||
import static java.util.Objects.requireNonNullElseGet;
|
||||
|
||||
import io.netty5.buffer.api.Buffer;
|
||||
import io.netty5.buffer.api.Resource;
|
||||
import io.netty5.buffer.api.Send;
|
||||
@ -494,23 +496,9 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
|
||||
private LLRange getPatchedRange(@NotNull LLRange range, @Nullable T keyMin, @Nullable T keyMax)
|
||||
throws SerializationException {
|
||||
try (range) {
|
||||
try (Buffer keyMinBuf = serializeSuffixForRange(keyMin)) {
|
||||
try (Buffer keyMaxBuf = serializeSuffixForRange(keyMax)) {
|
||||
Buffer keyMinBufSend;
|
||||
if (keyMinBuf == null) {
|
||||
keyMinBufSend = range.getMinUnsafe().copy();
|
||||
} else {
|
||||
keyMinBufSend = keyMinBuf;
|
||||
}
|
||||
Buffer keyMaxBufSend;
|
||||
if (keyMaxBuf == null) {
|
||||
keyMaxBufSend = range.getMaxUnsafe().copy();
|
||||
} else {
|
||||
keyMaxBufSend = keyMaxBuf;
|
||||
}
|
||||
return LLRange.ofUnsafe(keyMinBufSend, keyMaxBufSend);
|
||||
}
|
||||
}
|
||||
Buffer keyMinBuf = requireNonNullElseGet(serializeSuffixForRange(keyMin), range::getMinCopy);
|
||||
Buffer keyMaxBuf = requireNonNullElseGet(serializeSuffixForRange(keyMax), range::getMaxCopy);
|
||||
return LLRange.ofUnsafe(keyMinBuf, keyMaxBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,7 +534,7 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
|
||||
} else {
|
||||
Mono<LLRange> boundedRangeMono = rangeMono
|
||||
.handle((fullRange, sink) -> {
|
||||
try {
|
||||
try (fullRange) {
|
||||
sink.next(getPatchedRange(fullRange, keyMin, keyMax));
|
||||
} catch (SerializationException e) {
|
||||
sink.error(e);
|
||||
|
@ -868,12 +868,16 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
boolean reverse,
|
||||
boolean smallRange) {
|
||||
return rangeMono.flatMapMany(range -> {
|
||||
try (range) {
|
||||
try {
|
||||
if (range.isSingle()) {
|
||||
return this.getRangeKeysSingle(snapshot, rangeMono.map(LLRange::getSingleUnsafe));
|
||||
} else {
|
||||
return this.getRangeKeysMulti(snapshot, rangeMono, reverse, smallRange);
|
||||
}
|
||||
} finally {
|
||||
if (range != null && range.isAccessible()) {
|
||||
range.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user