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