UpdateMode is now a "blocking" method
This commit is contained in:
parent
f9c2f7ca31
commit
f739f4f9f4
@ -25,7 +25,7 @@ public interface LLDictionary extends LLKeyValueDatabaseStructure {
|
||||
|
||||
Mono<Buffer> put(Mono<Buffer> key, Mono<Buffer> value, LLDictionaryResultType resultType);
|
||||
|
||||
Mono<UpdateMode> getUpdateMode();
|
||||
UpdateMode getUpdateMode();
|
||||
|
||||
default Mono<Buffer> update(Mono<Buffer> key,
|
||||
BinarySerializationFunction updater,
|
||||
|
@ -285,7 +285,7 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UpdateMode> getUpdateMode() {
|
||||
public UpdateMode getUpdateMode() {
|
||||
return dictionary.getUpdateMode();
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> extend
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UpdateMode> getUpdateMode() {
|
||||
public UpdateMode getUpdateMode() {
|
||||
return dictionary.getUpdateMode();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,8 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends SimpleResource implem
|
||||
Serializer<U> valueSerializer,
|
||||
Function<T, TH> keySuffixHashFunction,
|
||||
SerializerFixedBinaryLength<TH> keySuffixHashSerializer) {
|
||||
if (dictionary.getUpdateMode().transform(LLUtils::handleDiscard).block() != UpdateMode.ALLOW) {
|
||||
var updateMode = dictionary.getUpdateMode();
|
||||
if (updateMode != UpdateMode.ALLOW) {
|
||||
throw new IllegalArgumentException("Hashed maps only works when UpdateMode is ALLOW");
|
||||
}
|
||||
this.alloc = dictionary.getAllocator();
|
||||
@ -61,7 +62,6 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends SimpleResource implem
|
||||
this.keySuffixHashFunction = keySuffixHashFunction;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private DatabaseMapDictionaryHashed(BufferAllocator alloc,
|
||||
Function<T, TH> keySuffixHashFunction,
|
||||
DatabaseStage<Object2ObjectSortedMap<TH, ObjectArraySet<Entry<T, U>>>> subDictionary,
|
||||
@ -177,7 +177,7 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends SimpleResource implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UpdateMode> getUpdateMode() {
|
||||
public UpdateMode getUpdateMode() {
|
||||
return subDictionary.getUpdateMode();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends
|
||||
return Mono.usingWhen(at(null, key).single(), stage -> stage.set(value), LLUtils::finalizeResource);
|
||||
}
|
||||
|
||||
Mono<UpdateMode> getUpdateMode();
|
||||
UpdateMode getUpdateMode();
|
||||
|
||||
default Mono<U> updateValue(T key,
|
||||
UpdateReturnMode updateReturnMode,
|
||||
@ -192,10 +192,7 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends
|
||||
|
||||
@Override
|
||||
default Mono<Delta<Object2ObjectSortedMap<T, U>>> updateAndGetDelta(SerializationFunction<@Nullable Object2ObjectSortedMap<T, U>, @Nullable Object2ObjectSortedMap<T, U>> updater) {
|
||||
return this
|
||||
.getUpdateMode()
|
||||
.single()
|
||||
.flatMap(updateMode -> {
|
||||
var updateMode = this.getUpdateMode();
|
||||
if (updateMode == UpdateMode.ALLOW_UNSAFE) {
|
||||
return this
|
||||
.getAllValues(null, true)
|
||||
@ -234,7 +231,6 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends
|
||||
throw new UnsupportedOperationException("Unknown update mode: " + updateMode);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -409,8 +409,8 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UpdateMode> getUpdateMode() {
|
||||
return Mono.just(updateMode);
|
||||
public UpdateMode getUpdateMode() {
|
||||
return updateMode;
|
||||
}
|
||||
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
|
@ -201,8 +201,8 @@ public class LLMemoryDictionary implements LLDictionary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<UpdateMode> getUpdateMode() {
|
||||
return Mono.just(updateMode);
|
||||
public UpdateMode getUpdateMode() {
|
||||
return updateMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,7 +201,7 @@ public abstract class TestLLDictionary {
|
||||
@MethodSource("provideArguments")
|
||||
public void testGetUpdateMode(UpdateMode updateMode) {
|
||||
var dict = getDict(updateMode);
|
||||
assertEquals(updateMode, run(dict.getUpdateMode()));
|
||||
assertEquals(updateMode, dict.getUpdateMode());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
@ -154,7 +154,7 @@ public abstract class TestLLDictionaryLeaks {
|
||||
@MethodSource("provideArguments")
|
||||
public void testGetUpdateMode(UpdateMode updateMode) {
|
||||
var dict = getDict(updateMode);
|
||||
assertEquals(updateMode, run(dict.getUpdateMode()));
|
||||
assertEquals(updateMode, dict.getUpdateMode());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
Loading…
Reference in New Issue
Block a user