Bugfixes
This commit is contained in:
parent
6fe9f9c24f
commit
0c17af2ae5
@ -430,8 +430,8 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
|
||||
return dictionary
|
||||
.getRangeKeys(resolveSnapshot(snapshot), rangeMono)
|
||||
.handle((key, sink) -> {
|
||||
ByteBuf keySuffixWithExt = stripPrefix(key.retain(), false);
|
||||
try {
|
||||
ByteBuf keySuffixWithExt = stripPrefix(key.retain(), false);
|
||||
try {
|
||||
sink.next(Map.entry(deserializeSuffix(keySuffixWithExt.retainedSlice()),
|
||||
new DatabaseSingleMapped<>(new DatabaseSingle<>(dictionary,
|
||||
|
@ -416,7 +416,7 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> implem
|
||||
);
|
||||
},
|
||||
ReferenceCounted::release
|
||||
).doOnDiscard(DatabaseStage.class, DatabaseStage::release);
|
||||
).transform(LLUtils::handleDiscard).doOnDiscard(DatabaseStage.class, DatabaseStage::release);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,12 @@ public class DatabaseSetDictionary<T> extends DatabaseMapDictionary<T, Nothing>
|
||||
|
||||
public static <T> DatabaseSetDictionary<T> simple(LLDictionary dictionary,
|
||||
SerializerFixedBinaryLength<T, ByteBuf> keySerializer) {
|
||||
return new DatabaseSetDictionary<>(dictionary, dictionary.getAllocator().buffer(0), keySerializer);
|
||||
var buf = dictionary.getAllocator().buffer(0);
|
||||
try {
|
||||
return new DatabaseSetDictionary<>(dictionary, buf, keySerializer);
|
||||
} finally {
|
||||
buf.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> DatabaseSetDictionary<T> tail(LLDictionary dictionary,
|
||||
|
@ -14,7 +14,7 @@ public interface SubStageGetter<U, US extends DatabaseStage<U>> {
|
||||
Mono<US> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> prefixKey,
|
||||
Flux<ByteBuf> debuggingKeyFlux);
|
||||
@Nullable Flux<ByteBuf> debuggingKeyFlux);
|
||||
|
||||
boolean isMultiKey();
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class SubStageGetterHashMap<T, U, TH> implements
|
||||
public Mono<DatabaseMapDictionaryHashed<T, U, TH>> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> prefixKeyMono,
|
||||
Flux<ByteBuf> debuggingKeysFlux) {
|
||||
@Nullable Flux<ByteBuf> debuggingKeysFlux) {
|
||||
return Mono.usingWhen(
|
||||
prefixKeyMono,
|
||||
prefixKey -> Mono
|
||||
@ -61,7 +61,7 @@ public class SubStageGetterHashMap<T, U, TH> implements
|
||||
)
|
||||
)
|
||||
.transform(mono -> {
|
||||
if (assertsEnabled && enableAssertionsWhenUsingAssertions) {
|
||||
if (debuggingKeysFlux != null) {
|
||||
return debuggingKeysFlux.handle((key, sink) -> {
|
||||
try {
|
||||
if (key.readableBytes() != prefixKey.readableBytes() + getKeyHashBinaryLength()) {
|
||||
|
@ -44,7 +44,7 @@ public class SubStageGetterHashSet<T, TH> implements
|
||||
public Mono<DatabaseSetDictionaryHashed<T, TH>> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> prefixKeyMono,
|
||||
Flux<ByteBuf> debuggingKeysFlux) {
|
||||
@Nullable Flux<ByteBuf> debuggingKeysFlux) {
|
||||
return Mono.usingWhen(prefixKeyMono,
|
||||
prefixKey -> Mono
|
||||
.fromSupplier(() -> DatabaseSetDictionaryHashed
|
||||
@ -56,7 +56,7 @@ public class SubStageGetterHashSet<T, TH> implements
|
||||
)
|
||||
)
|
||||
.transform(mono -> {
|
||||
if (assertsEnabled && enableAssertionsWhenUsingAssertions) {
|
||||
if (debuggingKeysFlux != null) {
|
||||
return debuggingKeysFlux.handle((key, sink) -> {
|
||||
try {
|
||||
if (key.readableBytes() != prefixKey.readableBytes() + getKeyHashBinaryLength()) {
|
||||
|
@ -38,7 +38,7 @@ public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, Databa
|
||||
public Mono<DatabaseMapDictionary<T, U>> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> prefixKeyMono,
|
||||
Flux<ByteBuf> debuggingKeysFlux) {
|
||||
@Nullable Flux<ByteBuf> debuggingKeysFlux) {
|
||||
return Mono.usingWhen(prefixKeyMono,
|
||||
prefixKey -> Mono
|
||||
.fromSupplier(() -> DatabaseMapDictionary
|
||||
@ -49,7 +49,7 @@ public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, Databa
|
||||
)
|
||||
)
|
||||
.transform(mono -> {
|
||||
if (assertsEnabled && enableAssertionsWhenUsingAssertions) {
|
||||
if (debuggingKeysFlux != null) {
|
||||
return debuggingKeysFlux.handle((key, sink) -> {
|
||||
try {
|
||||
if (key.readableBytes() != prefixKey.readableBytes() + getKeyBinaryLength()) {
|
||||
|
@ -53,7 +53,7 @@ public class SubStageGetterMapDeep<T, U, US extends DatabaseStage<U>> implements
|
||||
public Mono<DatabaseMapDictionaryDeep<T, U, US>> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> prefixKeyMono,
|
||||
Flux<ByteBuf> debuggingKeysFlux) {
|
||||
@Nullable Flux<ByteBuf> debuggingKeysFlux) {
|
||||
return Mono.usingWhen(prefixKeyMono,
|
||||
prefixKey -> Mono
|
||||
.fromSupplier(() -> DatabaseMapDictionaryDeep
|
||||
@ -65,7 +65,7 @@ public class SubStageGetterMapDeep<T, U, US extends DatabaseStage<U>> implements
|
||||
)
|
||||
)
|
||||
.transform(mono -> {
|
||||
if (assertsEnabled && enableAssertionsWhenUsingAssertions) {
|
||||
if (debuggingKeysFlux != null) {
|
||||
return debuggingKeysFlux.handle((key, sink) -> {
|
||||
try {
|
||||
if (key.readableBytes() != prefixKey.readableBytes() + getKeyBinaryLength()) {
|
||||
|
@ -36,12 +36,12 @@ public class SubStageGetterSet<T> implements SubStageGetter<Map<T, Nothing>, Dat
|
||||
public Mono<DatabaseSetDictionary<T>> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> prefixKeyMono,
|
||||
Flux<ByteBuf> debuggingKeysFlux) {
|
||||
@Nullable Flux<ByteBuf> debuggingKeysFlux) {
|
||||
return Mono.usingWhen(prefixKeyMono,
|
||||
prefixKey -> Mono
|
||||
.fromSupplier(() -> DatabaseSetDictionary.tail(dictionary, prefixKey.retain(), keySerializer))
|
||||
.transform(mono -> {
|
||||
if (assertsEnabled && enableAssertionsWhenUsingAssertions) {
|
||||
if (debuggingKeysFlux != null) {
|
||||
return debuggingKeysFlux.handle((key, sink) -> {
|
||||
try {
|
||||
if (key.readableBytes() != prefixKey.readableBytes() + getKeyBinaryLength()) {
|
||||
|
@ -32,16 +32,16 @@ public class SubStageGetterSingle<T> implements SubStageGetter<T, DatabaseStageE
|
||||
public Mono<DatabaseStageEntry<T>> subStage(LLDictionary dictionary,
|
||||
@Nullable CompositeSnapshot snapshot,
|
||||
Mono<ByteBuf> keyPrefixMono,
|
||||
Flux<ByteBuf> debuggingKeysFlux) {
|
||||
@Nullable Flux<ByteBuf> debuggingKeysFlux) {
|
||||
return Mono.usingWhen(
|
||||
keyPrefixMono,
|
||||
keyPrefix -> Mono
|
||||
.<DatabaseStageEntry<T>>fromSupplier(() -> new DatabaseSingle<>(dictionary, keyPrefix.retain(), serializer))
|
||||
.transform(mono -> {
|
||||
if (assertsEnabled && needsDebuggingKeyFlux()) {
|
||||
if (debuggingKeysFlux != null) {
|
||||
return debuggingKeysFlux.handle((key, sink) -> {
|
||||
try {
|
||||
if (!LLUtils.equals(keyPrefix, key)) {
|
||||
if (needsDebuggingKeyFlux() && !LLUtils.equals(keyPrefix, key)) {
|
||||
sink.error(new IndexOutOfBoundsException("Found more than one element!"));
|
||||
} else {
|
||||
sink.complete();
|
||||
|
@ -1151,6 +1151,7 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
var valueChangedResult = new ArrayList<ExtraKeyOperationResult<ByteBuf, X>>(mappedInputs.size());
|
||||
try {
|
||||
for (var mappedInput : mappedInputs) {
|
||||
//noinspection BlockingMethodInNonBlockingContext
|
||||
var updatedValue = updateFunction.apply(mappedInput.getT1().retain(), mappedInput.getT2());
|
||||
valueChangedResult.add(new ExtraKeyOperationResult<>(mappedInput.getT1(),
|
||||
mappedInput.getT2(),
|
||||
@ -1288,43 +1289,24 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
|
||||
private Flux<Entry<ByteBuf, ByteBuf>> getRangeMulti(LLSnapshot snapshot, Mono<LLRange> rangeMono) {
|
||||
return Flux.usingWhen(rangeMono,
|
||||
range -> Flux
|
||||
.using(
|
||||
() -> new LLLocalEntryReactiveRocksIterator(db,
|
||||
alloc,
|
||||
cfh,
|
||||
range.retain(),
|
||||
databaseOptions.allowNettyDirect(),
|
||||
resolveSnapshot(snapshot),
|
||||
getRangeMultiDebugName
|
||||
),
|
||||
llLocalEntryReactiveRocksIterator -> llLocalEntryReactiveRocksIterator
|
||||
.flux()
|
||||
.subscribeOn(dbScheduler),
|
||||
LLLocalReactiveRocksIterator::release
|
||||
),
|
||||
range -> Flux.using(
|
||||
() -> new LLLocalEntryReactiveRocksIterator(db, alloc, cfh, range.retain(),
|
||||
databaseOptions.allowNettyDirect(), resolveSnapshot(snapshot), getRangeMultiDebugName),
|
||||
llLocalEntryReactiveRocksIterator -> llLocalEntryReactiveRocksIterator.flux().subscribeOn(dbScheduler),
|
||||
LLLocalReactiveRocksIterator::release
|
||||
).transform(LLUtils::handleDiscard),
|
||||
range -> Mono.fromRunnable(range::release)
|
||||
);
|
||||
}
|
||||
|
||||
private Flux<List<Entry<ByteBuf, ByteBuf>>> getRangeMultiGrouped(LLSnapshot snapshot, Mono<LLRange> rangeMono, int prefixLength) {
|
||||
return Flux.usingWhen(rangeMono,
|
||||
range -> Flux
|
||||
.using(
|
||||
() -> new LLLocalGroupedEntryReactiveRocksIterator(db,
|
||||
alloc,
|
||||
cfh,
|
||||
prefixLength,
|
||||
range.retain(),
|
||||
databaseOptions.allowNettyDirect(),
|
||||
resolveSnapshot(snapshot),
|
||||
"getRangeMultiGrouped"
|
||||
),
|
||||
reactiveRocksIterator -> reactiveRocksIterator
|
||||
.flux()
|
||||
.subscribeOn(dbScheduler),
|
||||
LLLocalGroupedReactiveRocksIterator::release
|
||||
),
|
||||
range -> Flux.using(
|
||||
() -> new LLLocalGroupedEntryReactiveRocksIterator(db, alloc, cfh, prefixLength, range.retain(),
|
||||
databaseOptions.allowNettyDirect(), resolveSnapshot(snapshot), "getRangeMultiGrouped"),
|
||||
reactiveRocksIterator -> reactiveRocksIterator.flux().subscribeOn(dbScheduler),
|
||||
LLLocalGroupedReactiveRocksIterator::release
|
||||
).transform(LLUtils::handleDiscard),
|
||||
range -> Mono.fromRunnable(range::release)
|
||||
);
|
||||
}
|
||||
@ -1348,20 +1330,12 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
Mono<LLRange> rangeMono,
|
||||
int prefixLength) {
|
||||
return Flux.usingWhen(rangeMono,
|
||||
range -> Flux
|
||||
.using(
|
||||
() -> new LLLocalGroupedKeyReactiveRocksIterator(db,
|
||||
alloc,
|
||||
cfh,
|
||||
prefixLength,
|
||||
range.retain(),
|
||||
databaseOptions.allowNettyDirect(),
|
||||
resolveSnapshot(snapshot),
|
||||
"getRangeKeysGrouped"
|
||||
), reactiveRocksIterator -> reactiveRocksIterator.flux()
|
||||
.subscribeOn(dbScheduler),
|
||||
LLLocalGroupedReactiveRocksIterator::release
|
||||
),
|
||||
range -> Flux.using(
|
||||
() -> new LLLocalGroupedKeyReactiveRocksIterator(db, alloc, cfh, prefixLength, range.retain(),
|
||||
databaseOptions.allowNettyDirect(), resolveSnapshot(snapshot), "getRangeKeysGrouped"),
|
||||
reactiveRocksIterator -> reactiveRocksIterator.flux().subscribeOn(dbScheduler),
|
||||
LLLocalGroupedReactiveRocksIterator::release
|
||||
).transform(LLUtils::handleDiscard),
|
||||
range -> Mono.fromRunnable(range::release)
|
||||
);
|
||||
}
|
||||
@ -1449,24 +1423,14 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings("Convert2MethodRef")
|
||||
private Flux<ByteBuf> getRangeKeysMulti(LLSnapshot snapshot, Mono<LLRange> rangeMono) {
|
||||
return Flux.usingWhen(rangeMono,
|
||||
range -> Flux
|
||||
.using(
|
||||
() -> new LLLocalKeyReactiveRocksIterator(db,
|
||||
alloc,
|
||||
cfh,
|
||||
range.retain(),
|
||||
databaseOptions.allowNettyDirect(),
|
||||
resolveSnapshot(snapshot),
|
||||
getRangeKeysMultiDebugName
|
||||
),
|
||||
llLocalKeyReactiveRocksIterator -> llLocalKeyReactiveRocksIterator.flux(),
|
||||
LLLocalReactiveRocksIterator::release
|
||||
)
|
||||
.doOnDiscard(ByteBuf.class, ReferenceCounted::release)
|
||||
.subscribeOn(dbScheduler),
|
||||
range -> Flux.using(
|
||||
() -> new LLLocalKeyReactiveRocksIterator(db, alloc, cfh, range.retain(),
|
||||
databaseOptions.allowNettyDirect(), resolveSnapshot(snapshot), getRangeKeysMultiDebugName),
|
||||
llLocalKeyReactiveRocksIterator -> llLocalKeyReactiveRocksIterator.flux().subscribeOn(dbScheduler),
|
||||
LLLocalReactiveRocksIterator::release
|
||||
).transform(LLUtils::handleDiscard),
|
||||
range -> Mono.fromRunnable(range::release)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user