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