Use sorted maps

This commit is contained in:
Andrea Cavalli 2021-12-18 18:16:56 +01:00
parent 1de5e52ffd
commit 480ab77db8
15 changed files with 210 additions and 132 deletions

View File

@ -17,6 +17,9 @@ import it.cavallium.dbengine.database.serialization.SerializationException;
import it.cavallium.dbengine.database.serialization.SerializationFunction; import it.cavallium.dbengine.database.serialization.SerializationFunction;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMaps;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -127,7 +130,7 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
} }
@Override @Override
public Mono<Map<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) { public Mono<Object2ObjectSortedMap<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) {
return dictionary return dictionary
.getRange(resolveSnapshot(snapshot), rangeMono, existsAlmostCertainly) .getRange(resolveSnapshot(snapshot), rangeMono, existsAlmostCertainly)
.<Entry<T, U>>handle((entrySend, sink) -> { .<Entry<T, U>>handle((entrySend, sink) -> {
@ -151,12 +154,13 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
sink.error(ex); sink.error(ex);
} }
}) })
.collectMap(Entry::getKey, Entry::getValue, LinkedHashMap::new) .collectMap(Entry::getKey, Entry::getValue, Object2ObjectLinkedOpenHashMap::new)
.map(map -> (Object2ObjectSortedMap<T, U>) map)
.filter(map -> !map.isEmpty()); .filter(map -> !map.isEmpty());
} }
@Override @Override
public Mono<Map<T, U>> setAndGetPrevious(Map<T, U> value) { public Mono<Object2ObjectSortedMap<T, U>> setAndGetPrevious(Object2ObjectSortedMap<T, U> value) {
return this return this
.get(null, false) .get(null, false)
.concatWith(dictionary.setRange(rangeMono, Flux .concatWith(dictionary.setRange(rangeMono, Flux
@ -168,9 +172,9 @@ public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U,
} }
@Override @Override
public Mono<Map<T, U>> clearAndGetPrevious() { public Mono<Object2ObjectSortedMap<T, U>> clearAndGetPrevious() {
return this return this
.setAndGetPrevious(Map.of()); .setAndGetPrevious(Object2ObjectSortedMaps.emptyMap());
} }
@Override @Override

View File

@ -17,6 +17,9 @@ import io.net5.buffer.api.internal.ResourceSupport;
import it.cavallium.dbengine.database.UpdateMode; import it.cavallium.dbengine.database.UpdateMode;
import it.cavallium.dbengine.database.serialization.SerializationException; import it.cavallium.dbengine.database.serialization.SerializationException;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -27,8 +30,9 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
// todo: implement optimized methods (which?) // todo: implement optimized methods (which?)
public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> extends ResourceSupport<DatabaseStage<Map<T, U>>, DatabaseMapDictionaryDeep<T, U, US>> public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> extends
implements DatabaseStageMap<T, U, US> { ResourceSupport<DatabaseStage<Object2ObjectSortedMap<T, U>>, DatabaseMapDictionaryDeep<T, U, US>> implements
DatabaseStageMap<T, U, US> {
private static final Logger logger = LogManager.getLogger(DatabaseMapDictionaryDeep.class); private static final Logger logger = LogManager.getLogger(DatabaseMapDictionaryDeep.class);

View File

@ -14,6 +14,8 @@ import io.net5.buffer.api.internal.ResourceSupport;
import it.cavallium.dbengine.database.UpdateMode; import it.cavallium.dbengine.database.UpdateMode;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import it.unimi.dsi.fastutil.objects.ObjectArraySet; import it.unimi.dsi.fastutil.objects.ObjectArraySet;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -30,8 +32,9 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<DatabaseStage<Map<T, U>>, DatabaseMapDictionaryHashed<T, U, TH>> public class DatabaseMapDictionaryHashed<T, U, TH> extends
implements DatabaseStageMap<T, U, DatabaseStageEntry<U>> { ResourceSupport<DatabaseStage<Object2ObjectSortedMap<T, U>>, DatabaseMapDictionaryHashed<T, U, TH>> implements
DatabaseStageMap<T, U, DatabaseStageEntry<U>> {
private static final Logger logger = LogManager.getLogger(DatabaseMapDictionaryHashed.class); private static final Logger logger = LogManager.getLogger(DatabaseMapDictionaryHashed.class);
@ -88,7 +91,7 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<Datab
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
private DatabaseMapDictionaryHashed(BufferAllocator alloc, private DatabaseMapDictionaryHashed(BufferAllocator alloc,
Function<T, TH> keySuffixHashFunction, Function<T, TH> keySuffixHashFunction,
Send<DatabaseStage<Map<TH, ObjectArraySet<Entry<T, U>>>>> subDictionary, Send<DatabaseStage<Object2ObjectSortedMap<TH, ObjectArraySet<Entry<T, U>>>>> subDictionary,
Drop<DatabaseMapDictionaryHashed<T, U, TH>> drop) { Drop<DatabaseMapDictionaryHashed<T, U, TH>> drop) {
super((Drop<DatabaseMapDictionaryHashed<T, U, TH>>) (Drop) DROP); super((Drop<DatabaseMapDictionaryHashed<T, U, TH>>) (Drop) DROP);
this.alloc = alloc; this.alloc = alloc;
@ -131,8 +134,8 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<Datab
); );
} }
private Map<TH, ObjectArraySet<Entry<T, U>>> serializeMap(Map<T, U> map) { private Object2ObjectSortedMap<TH, ObjectArraySet<Entry<T, U>>> serializeMap(Object2ObjectSortedMap<T, U> map) {
var newMap = new HashMap<TH, ObjectArraySet<Entry<T, U>>>(map.size()); var newMap = new Object2ObjectLinkedOpenHashMap<TH, ObjectArraySet<Entry<T, U>>>(map.size());
map.forEach((key, value) -> newMap.compute(keySuffixHashFunction.apply(key), (hash, prev) -> { map.forEach((key, value) -> newMap.compute(keySuffixHashFunction.apply(key), (hash, prev) -> {
if (prev == null) { if (prev == null) {
prev = new ObjectArraySet<>(); prev = new ObjectArraySet<>();
@ -143,29 +146,30 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<Datab
return newMap; return newMap;
} }
private Map<T, U> deserializeMap(Map<TH, ObjectArraySet<Entry<T, U>>> map) { private Object2ObjectSortedMap<T, U> deserializeMap(Object2ObjectSortedMap<TH, ObjectArraySet<Entry<T, U>>> map) {
var newMap = new HashMap<T, U>(map.size()); var newMap = new Object2ObjectLinkedOpenHashMap<T, U>(map.size());
map.forEach((hash, set) -> set.forEach(entry -> newMap.put(entry.getKey(), entry.getValue()))); map.forEach((hash, set) -> set.forEach(entry -> newMap.put(entry.getKey(), entry.getValue())));
return newMap; return newMap;
} }
@Override @Override
public Mono<Map<T, U>> get(@Nullable CompositeSnapshot snapshot) { public Mono<Object2ObjectSortedMap<T, U>> get(@Nullable CompositeSnapshot snapshot) {
return subDictionary.get(snapshot).map(this::deserializeMap); return subDictionary.get(snapshot).map(this::deserializeMap);
} }
@Override @Override
public Mono<Map<T, U>> getOrDefault(@Nullable CompositeSnapshot snapshot, Mono<Map<T, U>> defaultValue) { public Mono<Object2ObjectSortedMap<T, U>> getOrDefault(@Nullable CompositeSnapshot snapshot,
Mono<Object2ObjectSortedMap<T, U>> defaultValue) {
return this.get(snapshot).switchIfEmpty(defaultValue); return this.get(snapshot).switchIfEmpty(defaultValue);
} }
@Override @Override
public Mono<Void> set(Map<T, U> map) { public Mono<Void> set(Object2ObjectSortedMap<T, U> map) {
return Mono.fromSupplier(() -> this.serializeMap(map)).flatMap(subDictionary::set); return Mono.fromSupplier(() -> this.serializeMap(map)).flatMap(subDictionary::set);
} }
@Override @Override
public Mono<Boolean> setAndGetChanged(Map<T, U> map) { public Mono<Boolean> setAndGetChanged(Object2ObjectSortedMap<T, U> map) {
return Mono.fromSupplier(() -> this.serializeMap(map)).flatMap(subDictionary::setAndGetChanged).single(); return Mono.fromSupplier(() -> this.serializeMap(map)).flatMap(subDictionary::setAndGetChanged).single();
} }
@ -180,7 +184,7 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<Datab
} }
@Override @Override
public DatabaseStageEntry<Map<T, U>> entry() { public DatabaseStageEntry<Object2ObjectSortedMap<T, U>> entry() {
return this; return this;
} }
@ -247,7 +251,7 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<Datab
} }
@Override @Override
public Mono<Map<T, U>> setAndGetPrevious(Map<T, U> value) { public Mono<Object2ObjectSortedMap<T, U>> setAndGetPrevious(Object2ObjectSortedMap<T, U> value) {
return Mono return Mono
.fromSupplier(() -> this.serializeMap(value)) .fromSupplier(() -> this.serializeMap(value))
.flatMap(subDictionary::setAndGetPrevious) .flatMap(subDictionary::setAndGetPrevious)
@ -255,14 +259,14 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends ResourceSupport<Datab
} }
@Override @Override
public Mono<Map<T, U>> clearAndGetPrevious() { public Mono<Object2ObjectSortedMap<T, U>> clearAndGetPrevious() {
return subDictionary return subDictionary
.clearAndGetPrevious() .clearAndGetPrevious()
.map(this::deserializeMap); .map(this::deserializeMap);
} }
@Override @Override
public Mono<Map<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) { public Mono<Object2ObjectSortedMap<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) {
return subDictionary return subDictionary
.get(snapshot, existsAlmostCertainly) .get(snapshot, existsAlmostCertainly)
.map(this::deserializeMap); .map(this::deserializeMap);

View File

@ -8,6 +8,7 @@ import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing; import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -42,7 +43,7 @@ public class DatabaseSetDictionary<T> extends DatabaseMapDictionary<T, Nothing>
} }
public Mono<Set<T>> setAndGetPreviousKeySet(Set<T> value) { public Mono<Set<T>> setAndGetPreviousKeySet(Set<T> value) {
var hm = new HashMap<T, Nothing>(); var hm = new Object2ObjectLinkedOpenHashMap<T, Nothing>();
for (T t : value) { for (T t : value) {
hm.put(t, DatabaseEmpty.NOTHING); hm.put(t, DatabaseEmpty.NOTHING);
} }

View File

@ -9,6 +9,7 @@ import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing; import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -70,7 +71,7 @@ public class DatabaseSetDictionaryHashed<T, TH> extends DatabaseMapDictionaryHas
} }
public Mono<Set<T>> setAndGetPreviousKeySet(Set<T> value) { public Mono<Set<T>> setAndGetPreviousKeySet(Set<T> value) {
var hm = new HashMap<T, Nothing>(); var hm = new Object2ObjectLinkedOpenHashMap<T, Nothing>();
for (T t : value) { for (T t : value) {
hm.put(t, DatabaseEmpty.NOTHING); hm.put(t, DatabaseEmpty.NOTHING);
} }

View File

@ -9,8 +9,10 @@ import it.cavallium.dbengine.database.UpdateReturnMode;
import it.cavallium.dbengine.database.serialization.KVSerializationFunction; import it.cavallium.dbengine.database.serialization.KVSerializationFunction;
import it.cavallium.dbengine.database.serialization.SerializationException; import it.cavallium.dbengine.database.serialization.SerializationException;
import it.cavallium.dbengine.database.serialization.SerializationFunction; import it.cavallium.dbengine.database.serialization.SerializationFunction;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMaps;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
@ -23,7 +25,8 @@ import reactor.util.function.Tuple2;
import reactor.util.function.Tuples; import reactor.util.function.Tuples;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends DatabaseStageEntry<Map<T, U>> { public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends
DatabaseStageEntry<Object2ObjectSortedMap<T, U>> {
Mono<US> at(@Nullable CompositeSnapshot snapshot, T key); Mono<US> at(@Nullable CompositeSnapshot snapshot, T key);
@ -185,15 +188,16 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
} }
@Override @Override
default Mono<Map<T, U>> setAndGetPrevious(Map<T, U> value) { default Mono<Object2ObjectSortedMap<T, U>> setAndGetPrevious(Object2ObjectSortedMap<T, U> value) {
return this return this
.setAllValuesAndGetPrevious(Flux.fromIterable(Map.copyOf(value).entrySet())) .setAllValuesAndGetPrevious(Flux.fromIterable(value.entrySet()))
.collectMap(Entry::getKey, Entry::getValue, LinkedHashMap::new) .collectMap(Entry::getKey, Entry::getValue, Object2ObjectLinkedOpenHashMap::new)
.map(map -> (Object2ObjectSortedMap<T, U>) map)
.filter(map -> !map.isEmpty()); .filter(map -> !map.isEmpty());
} }
@Override @Override
default Mono<Boolean> setAndGetChanged(Map<T, U> value) { default Mono<Boolean> setAndGetChanged(Object2ObjectSortedMap<T, U> value) {
return this return this
.setAndGetPrevious(value) .setAndGetPrevious(value)
.map(oldValue -> !Objects.equals(oldValue, value.isEmpty() ? null : value)) .map(oldValue -> !Objects.equals(oldValue, value.isEmpty() ? null : value))
@ -201,7 +205,7 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
} }
@Override @Override
default Mono<Delta<Map<T, U>>> updateAndGetDelta(SerializationFunction<@Nullable Map<T, U>, @Nullable Map<T, U>> updater, default Mono<Delta<Object2ObjectSortedMap<T, U>>> updateAndGetDelta(SerializationFunction<@Nullable Object2ObjectSortedMap<T, U>, @Nullable Object2ObjectSortedMap<T, U>> updater,
boolean existsAlmostCertainly) { boolean existsAlmostCertainly) {
return this return this
.getUpdateMode() .getUpdateMode()
@ -210,9 +214,10 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
if (updateMode == UpdateMode.ALLOW_UNSAFE) { if (updateMode == UpdateMode.ALLOW_UNSAFE) {
return this return this
.getAllValues(null) .getAllValues(null)
.collectMap(Entry::getKey, Entry::getValue, LinkedHashMap::new) .collectMap(Entry::getKey, Entry::getValue, Object2ObjectLinkedOpenHashMap::new)
.map(map -> (Object2ObjectSortedMap<T, U>) map)
.single() .single()
.<Tuple2<Optional<Map<T, U>>, Optional<Map<T, U>>>>handle((v, sink) -> { .<Tuple2<Optional<Object2ObjectSortedMap<T, U>>, Optional<Object2ObjectSortedMap<T, U>>>>handle((v, sink) -> {
if (v.isEmpty()) { if (v.isEmpty()) {
v = null; v = null;
} }
@ -228,7 +233,7 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
}) })
.flatMap(result -> Mono .flatMap(result -> Mono
.justOrEmpty(result.getT2()) .justOrEmpty(result.getT2())
.flatMap(values -> this.setAllValues(Flux.fromIterable(Map.copyOf(values).entrySet()))) .flatMap(values -> this.setAllValues(Flux.fromIterable(values.entrySet())))
.thenReturn(new Delta<>(result.getT1().orElse(null), result.getT2().orElse(null))) .thenReturn(new Delta<>(result.getT1().orElse(null), result.getT2().orElse(null)))
); );
} else if (updateMode == UpdateMode.ALLOW) { } else if (updateMode == UpdateMode.ALLOW) {
@ -248,15 +253,16 @@ public interface DatabaseStageMap<T, U, US extends DatabaseStage<U>> extends Dat
} }
@Override @Override
default Mono<Map<T, U>> clearAndGetPrevious() { default Mono<Object2ObjectSortedMap<T, U>> clearAndGetPrevious() {
return this.setAndGetPrevious(Map.of()); return this.setAndGetPrevious(Object2ObjectSortedMaps.emptyMap());
} }
@Override @Override
default Mono<Map<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) { default Mono<Object2ObjectSortedMap<T, U>> get(@Nullable CompositeSnapshot snapshot, boolean existsAlmostCertainly) {
return this return this
.getAllValues(snapshot) .getAllValues(snapshot)
.collectMap(Entry::getKey, Entry::getValue, LinkedHashMap::new) .collectMap(Entry::getKey, Entry::getValue, Object2ObjectLinkedOpenHashMap::new)
.map(map -> (Object2ObjectSortedMap<T, U>) map)
.filter(map -> !map.isEmpty()); .filter(map -> !map.isEmpty());
} }

View File

@ -8,6 +8,7 @@ import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -15,7 +16,7 @@ import reactor.core.publisher.Mono;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class SubStageGetterHashMap<T, U, TH> implements public class SubStageGetterHashMap<T, U, TH> implements
SubStageGetter<Map<T, U>, DatabaseMapDictionaryHashed<T, U, TH>> { SubStageGetter<Object2ObjectSortedMap<T, U>, DatabaseMapDictionaryHashed<T, U, TH>> {
private final Serializer<T> keySerializer; private final Serializer<T> keySerializer;
private final Serializer<U> valueSerializer; private final Serializer<U> valueSerializer;

View File

@ -9,6 +9,7 @@ import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing; import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -16,7 +17,7 @@ import reactor.core.publisher.Mono;
@SuppressWarnings({"unused", "ClassCanBeRecord"}) @SuppressWarnings({"unused", "ClassCanBeRecord"})
public class SubStageGetterHashSet<T, TH> implements public class SubStageGetterHashSet<T, TH> implements
SubStageGetter<Map<T, Nothing>, DatabaseSetDictionaryHashed<T, TH>> { SubStageGetter<Object2ObjectSortedMap<T, Nothing>, DatabaseSetDictionaryHashed<T, TH>> {
private final Serializer<T> keySerializer; private final Serializer<T> keySerializer;
private final Function<T, TH> keyHashFunction; private final Function<T, TH> keyHashFunction;

View File

@ -8,11 +8,13 @@ import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, DatabaseMapDictionary<T, U>> { public class SubStageGetterMap<T, U> implements
SubStageGetter<Object2ObjectSortedMap<T, U>, DatabaseMapDictionary<T, U>> {
private final SerializerFixedBinaryLength<T> keySerializer; private final SerializerFixedBinaryLength<T> keySerializer;
private final Serializer<U> valueSerializer; private final Serializer<U> valueSerializer;

View File

@ -7,12 +7,13 @@ import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
public class SubStageGetterMapDeep<T, U, US extends DatabaseStage<U>> implements public class SubStageGetterMapDeep<T, U, US extends DatabaseStage<U>> implements
SubStageGetter<Map<T, U>, DatabaseMapDictionaryDeep<T, U, US>> { SubStageGetter<Object2ObjectSortedMap<T, U>, DatabaseMapDictionaryDeep<T, U, US>> {
private final SubStageGetter<U, US> subStageGetter; private final SubStageGetter<U, US> subStageGetter;
private final SerializerFixedBinaryLength<T> keySerializer; private final SerializerFixedBinaryLength<T> keySerializer;

View File

@ -7,11 +7,13 @@ import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing; import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
public class SubStageGetterSet<T> implements SubStageGetter<Map<T, Nothing>, DatabaseSetDictionary<T>> { public class SubStageGetterSet<T> implements
SubStageGetter<Object2ObjectSortedMap<T, Nothing>, DatabaseSetDictionary<T>> {
private final SerializerFixedBinaryLength<T> keySerializer; private final SerializerFixedBinaryLength<T> keySerializer;

View File

@ -24,6 +24,7 @@ import it.cavallium.dbengine.lucene.mlt.BigCompositeReader;
import it.cavallium.dbengine.lucene.mlt.MultiMoreLikeThis; import it.cavallium.dbengine.lucene.mlt.MultiMoreLikeThis;
import it.cavallium.dbengine.lucene.searcher.LocalQueryParams; import it.cavallium.dbengine.lucene.searcher.LocalQueryParams;
import it.cavallium.dbengine.lucene.similarity.NGramSimilarity; import it.cavallium.dbengine.lucene.similarity.NGramSimilarity;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.io.EOFException; import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -224,7 +225,7 @@ public class LuceneUtils {
public static <T, U, V> ValueGetter<Entry<T, U>, V> getAsyncDbValueGetterDeep( public static <T, U, V> ValueGetter<Entry<T, U>, V> getAsyncDbValueGetterDeep(
CompositeSnapshot snapshot, CompositeSnapshot snapshot,
DatabaseMapDictionaryDeep<T, Map<U, V>, DatabaseMapDictionary<U, V>> dictionaryDeep) { DatabaseMapDictionaryDeep<T, Object2ObjectSortedMap<U, V>, DatabaseMapDictionary<U, V>> dictionaryDeep) {
return entry -> LLUtils.usingResource(dictionaryDeep return entry -> LLUtils.usingResource(dictionaryDeep
.at(snapshot, entry.getKey()), sub -> sub.getValue(snapshot, entry.getValue()), true); .at(snapshot, entry.getKey()), sub -> sub.getValue(snapshot, entry.getValue()), true);
} }

View File

@ -27,6 +27,7 @@ import it.cavallium.dbengine.database.disk.MemorySegmentUtils;
import it.cavallium.dbengine.database.serialization.SerializationException; import it.cavallium.dbengine.database.serialization.SerializationException;
import it.cavallium.dbengine.database.serialization.Serializer; import it.cavallium.dbengine.database.serialization.Serializer;
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -188,7 +189,7 @@ public class DbTestUtils {
} }
} }
public static DatabaseMapDictionaryDeep<String, Map<String, String>, public static DatabaseMapDictionaryDeep<String, Object2ObjectSortedMap<String, String>,
DatabaseMapDictionary<String, String>> tempDatabaseMapDictionaryDeepMap( DatabaseMapDictionary<String, String>> tempDatabaseMapDictionaryDeepMap(
LLDictionary dictionary, LLDictionary dictionary,
int key1Bytes, int key1Bytes,
@ -203,7 +204,7 @@ public class DbTestUtils {
); );
} }
public static DatabaseMapDictionaryDeep<String, Map<String, String>, public static DatabaseMapDictionaryDeep<String, Object2ObjectSortedMap<String, String>,
DatabaseMapDictionaryHashed<String, String, Integer>> tempDatabaseMapDictionaryDeepMapHashMap( DatabaseMapDictionaryHashed<String, String, Integer>> tempDatabaseMapDictionaryDeepMapHashMap(
LLDictionary dictionary, LLDictionary dictionary,
int key1Bytes) { int key1Bytes) {

View File

@ -6,6 +6,9 @@ import static it.cavallium.dbengine.SyncUtils.*;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.DbTestUtils.TestAllocator; import it.cavallium.dbengine.DbTestUtils.TestAllocator;
import it.cavallium.dbengine.database.UpdateMode; import it.cavallium.dbengine.database.UpdateMode;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMaps;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -114,7 +117,7 @@ public abstract class TestDictionaryMap {
Assertions.assertEquals(shouldFail ? 0 : 1, resultingMapSize); Assertions.assertEquals(shouldFail ? 0 : 1, resultingMapSize);
var resultingMap = run(map.get(null)); var resultingMap = run(map.get(null));
Assertions.assertEquals(shouldFail ? null : Map.of(key, value), resultingMap); Assertions.assertEquals(shouldFail ? null : Object2ObjectSortedMaps.singleton(key, value), resultingMap);
map.close(); map.close();
@ -355,17 +358,16 @@ public abstract class TestDictionaryMap {
} else { } else {
badKeys = List.of(); badKeys = List.of();
} }
List<Tuple2<List<String>, Boolean>> keys = Stream.concat( List<Tuple2<List<String>, Boolean>> keys = Stream
goodKeys.stream().map(s -> Tuples.of(s, false)), .concat(goodKeys.stream().map(s -> Tuples.of(s, false)), badKeys.stream().map(s -> Tuples.of(s, true)))
badKeys.stream().map(s -> Tuples.of(s, true)) .toList();
).collect(Collectors.toList());
var values = isCIMode() ? List.of("val") : List.of("", "\0", BIG_STRING); var values = isCIMode() ? List.of("val") : List.of("", "\0", BIG_STRING);
return keys return keys
.stream() .stream()
.map(keyTuple -> keyTuple.mapT1(ks -> Flux .map(keyTuple -> keyTuple.mapT1(ks -> Flux
.zip(Flux.fromIterable(ks), Flux.fromIterable(values)) .zip(Flux.fromIterable(ks), Flux.fromIterable(values))
.collectMap(Tuple2::getT1, Tuple2::getT2) .collectMap(Tuple2::getT1, Tuple2::getT2, Object2ObjectLinkedOpenHashMap::new)
.block() .block()
)) ))
.flatMap(entryTuple -> Arrays.stream(UpdateMode.values()).map(updateMode -> Tuples.of(updateMode, .flatMap(entryTuple -> Arrays.stream(UpdateMode.values()).map(updateMode -> Tuples.of(updateMode,
@ -385,7 +387,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testPutMultiGetMulti(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testPutMultiGetMulti(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -419,7 +421,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testSetAllValuesGetMulti(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testSetAllValuesGetMulti(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -450,7 +452,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testSetAllValuesAndGetPrevious(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testSetAllValuesAndGetPrevious(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -478,7 +480,10 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testSetGetMulti(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testSetGetMulti(MapType mapType,
UpdateMode updateMode,
Object2ObjectSortedMap<String, String> entries,
boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -513,7 +518,7 @@ public abstract class TestDictionaryMap {
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testSetAndGetChanged(MapType mapType, public void testSetAndGetChanged(MapType mapType,
UpdateMode updateMode, UpdateMode updateMode,
Map<String, String> entries, Object2ObjectSortedMap<String, String> entries,
boolean shouldFail) { boolean shouldFail) {
Step<Boolean> stpVer = StepVerifier Step<Boolean> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -545,7 +550,10 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testSetAndGetPrevious(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testSetAndGetPrevious(MapType mapType,
UpdateMode updateMode,
Object2ObjectSortedMap<String, String> entries,
boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -571,7 +579,10 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testSetClearAndGetPreviousGet(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testSetClearAndGetPreviousGet(MapType mapType,
UpdateMode updateMode,
Object2ObjectSortedMap<String, String> entries,
boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -597,7 +608,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testPutMultiGetAllValues(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testPutMultiGetAllValues(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -625,7 +636,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testPutMultiGet(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testPutMultiGet(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -655,7 +666,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testPutMultiGetAllStagesGet(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testPutMultiGetAllStagesGet(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Entry<String, String>> stpVer = StepVerifier Step<Entry<String, String>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -690,7 +701,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testPutMultiIsEmpty(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testPutMultiIsEmpty(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, String>, Boolean>().keySet(true);
Step<Boolean> stpVer = StepVerifier Step<Boolean> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -716,7 +727,7 @@ public abstract class TestDictionaryMap {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPutMulti") @MethodSource("provideArgumentsPutMulti")
public void testPutMultiClear(MapType mapType, UpdateMode updateMode, Map<String, String> entries, boolean shouldFail) { public void testPutMultiClear(MapType mapType, UpdateMode updateMode, Object2ObjectSortedMap<String, String> entries, boolean shouldFail) {
List<Boolean> result; List<Boolean> result;
try { try {
result = SyncUtils.run(DbTestUtils.tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) result = SyncUtils.run(DbTestUtils.tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)

View File

@ -17,6 +17,9 @@ import it.cavallium.dbengine.DbTestUtils.TestAllocator;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.UpdateMode; import it.cavallium.dbengine.database.UpdateMode;
import it.cavallium.dbengine.database.collections.DatabaseMapDictionaryDeep; import it.cavallium.dbengine.database.collections.DatabaseMapDictionaryDeep;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMaps;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -72,14 +75,14 @@ public abstract class TestDictionaryMapDeep {
badKeys.stream().map(s -> Tuples.of(s, true)) badKeys.stream().map(s -> Tuples.of(s, true))
).collect(Collectors.toSet()); ).collect(Collectors.toSet());
var values = Set.of( var values = Set.of(
Map.of("123456", "a", "234567", ""), new Object2ObjectLinkedOpenHashMap<>(Map.of("123456", "a", "234567", "")),
Map.of("123456", "\0", "234567", "\0\0", "345678", BIG_STRING) new Object2ObjectLinkedOpenHashMap<>(Map.of("123456", "\0", "234567", "\0\0", "345678", BIG_STRING))
); );
return keys return keys
.stream() .stream()
.flatMap(keyTuple -> { .flatMap(keyTuple -> {
Stream<Map<String, String>> strm; Stream<Object2ObjectLinkedOpenHashMap<String, String>> strm;
if (keyTuple.getT2()) { if (keyTuple.getT2()) {
strm = values.stream().limit(1); strm = values.stream().limit(1);
} else { } else {
@ -182,7 +185,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testPutValue(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testPutValue(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) {
var gen = getTempDbGenerator(); var gen = getTempDbGenerator();
var db = run(gen.openTempDb(allocator)); var db = run(gen.openTempDb(allocator));
var dict = run(tempDictionary(db.db(), updateMode)); var dict = run(tempDictionary(db.db(), updateMode));
@ -206,7 +212,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testGetValue(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testGetValue(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) {
var gen = getTempDbGenerator(); var gen = getTempDbGenerator();
var db = run(gen.openTempDb(allocator)); var db = run(gen.openTempDb(allocator));
var dict = run(tempDictionary(db.db(), updateMode)); var dict = run(tempDictionary(db.db(), updateMode));
@ -229,7 +238,7 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetValueGetAllValues(UpdateMode updateMode, String key, Map<String, String> value, public void testSetValueGetAllValues(UpdateMode updateMode, String key, Object2ObjectSortedMap<String, String> value,
boolean shouldFail) { boolean shouldFail) {
var stpVer = StepVerifier var stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -250,7 +259,9 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testAtSetGetAllStagesGetAllValues(UpdateMode updateMode, String key, Map<String, String> value, public void testAtSetGetAllStagesGetAllValues(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Tuple3<String, String, String>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Tuple3<String, String, String>, Boolean>().keySet(true);
Step<Tuple3<String, String, String>> stpVer = StepVerifier Step<Tuple3<String, String, String>> stpVer = StepVerifier
@ -269,7 +280,7 @@ public abstract class TestDictionaryMapDeep {
.at(null, "capra") .at(null, "capra")
.flatMap(v_ -> Mono.using( .flatMap(v_ -> Mono.using(
() -> v_, () -> v_,
v -> v.set(Map.of("normal", "123", "ormaln", "456")), v -> v.set(new Object2ObjectLinkedOpenHashMap<>(Map.of("normal", "123", "ormaln", "456"))),
ResourceSupport::close ResourceSupport::close
)) ))
) )
@ -332,15 +343,18 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetAndGetPrevious(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testSetAndGetPrevious(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) {
var stpVer = StepVerifier var stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
.concat .concat
(map (map
.putValueAndGetPrevious(key, Map.of("error?", "error.")) .putValueAndGetPrevious(key, new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error.")))
.defaultIfEmpty(Map.of("nothing", "nothing")), .defaultIfEmpty(new Object2ObjectLinkedOpenHashMap<>(Map.of("nothing", "nothing"))),
map.putValueAndGetPrevious(key, value), map.putValueAndGetPrevious(key, value),
map.putValueAndGetPrevious(key, value) map.putValueAndGetPrevious(key, value)
) )
@ -351,7 +365,12 @@ public abstract class TestDictionaryMapDeep {
this.checkLeaks = false; this.checkLeaks = false;
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
stpVer.expectNext(Map.of("nothing", "nothing"), Map.of("error?", "error.")).expectNext(value).verifyComplete(); stpVer
.expectNext(new Object2ObjectLinkedOpenHashMap<>(Map.of("nothing", "nothing")),
new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."))
)
.expectNext(value)
.verifyComplete();
} }
} }
@ -396,7 +415,9 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetValueRemoveAndGetPrevious(UpdateMode updateMode, String key, Map<String, String> value, public void testSetValueRemoveAndGetPrevious(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) { boolean shouldFail) {
var stpVer = StepVerifier var stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -460,7 +481,9 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetValueRemoveAndGetStatus(UpdateMode updateMode, String key, Map<String, String> value, public void testSetValueRemoveAndGetStatus(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) { boolean shouldFail) {
var stpVer = StepVerifier var stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -524,7 +547,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testUpdate(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testUpdate(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) {
if (updateMode != UpdateMode.ALLOW_UNSAFE && !isTestBadKeysEnabled()) { if (updateMode != UpdateMode.ALLOW_UNSAFE && !isTestBadKeysEnabled()) {
return; return;
} }
@ -535,15 +561,15 @@ public abstract class TestDictionaryMapDeep {
.concat( .concat(
map.updateValue(key, old -> { map.updateValue(key, old -> {
assert old == null; assert old == null;
return Map.of("error?", "error."); return new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."));
}), }),
map.updateValue(key, false, old -> { map.updateValue(key, false, old -> {
assert Objects.equals(old, Map.of("error?", "error.")); assert Objects.equals(old, Map.of("error?", "error."));
return Map.of("error?", "error."); return new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."));
}), }),
map.updateValue(key, true, old -> { map.updateValue(key, true, old -> {
assert Objects.equals(old, Map.of("error?", "error.")); assert Objects.equals(old, Map.of("error?", "error."));
return Map.of("error?", "error."); return new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."));
}), }),
map.updateValue(key, true, old -> { map.updateValue(key, true, old -> {
assert Objects.equals(old, Map.of("error?", "error.")); assert Objects.equals(old, Map.of("error?", "error."));
@ -613,7 +639,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testUpdateGet(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testUpdateGet(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) {
if (updateMode != UpdateMode.ALLOW_UNSAFE && !isTestBadKeysEnabled()) { if (updateMode != UpdateMode.ALLOW_UNSAFE && !isTestBadKeysEnabled()) {
return; return;
} }
@ -622,18 +651,18 @@ public abstract class TestDictionaryMapDeep {
.flatMapMany(map -> Flux.concat( .flatMapMany(map -> Flux.concat(
map.updateValue(key, old -> { map.updateValue(key, old -> {
assert old == null; assert old == null;
return Map.of("error?", "error."); return new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."));
}).then(map.getValue(null, key)), }).then(map.getValue(null, key)),
map.updateValue(key, false, old -> { map.updateValue(key, false, old -> {
assert Objects.equals(old, Map.of("error?", "error.")); assert Objects.equals(old, Map.of("error?", "error."));
return Map.of("error?", "error."); return new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."));
}).then(map.getValue(null, key)), }).then(map.getValue(null, key)),
map.updateValue(key, true, old -> { map.updateValue(key, true, old -> {
assert Objects.equals(old, Map.of("error?", "error.")); assert Objects.equals(old, Map.of("error?", "error."));
return Map.of("error?", "error."); return new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."));
}).then(map.getValue(null, key)), }).then(map.getValue(null, key)),
map.updateValue(key, true, old -> { map.updateValue(key, true, old -> {
assert Objects.equals(old, Map.of("error?", "error.")); assert Objects.equals(old, new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error.")));
return value; return value;
}).then(map.getValue(null, key)), }).then(map.getValue(null, key)),
map.updateValue(key, true, old -> { map.updateValue(key, true, old -> {
@ -646,7 +675,12 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
stpVer stpVer
.expectNext(Map.of("error?", "error."), Map.of("error?", "error."), Map.of("error?", "error."), value, value) .expectNext(new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error.")),
new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error.")),
new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error.")),
value,
value
)
.verifyComplete(); .verifyComplete();
} }
} }
@ -708,17 +742,20 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetAndGetChanged(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testSetAndGetChanged(UpdateMode updateMode,
String key,
Object2ObjectSortedMap<String, String> value,
boolean shouldFail) {
var stpVer = StepVerifier var stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
.concat( .concat(
map.putValueAndGetChanged(key, Map.of("error?", "error.")).single(), map.putValueAndGetChanged(key, new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."))).single(),
map.putValueAndGetChanged(key, value).single(), map.putValueAndGetChanged(key, value).single(),
map.putValueAndGetChanged(key, value).single(), map.putValueAndGetChanged(key, value).single(),
map.remove(key), map.remove(key),
map.putValueAndGetChanged(key, Map.of("error?", "error.")).single() map.putValueAndGetChanged(key, new Object2ObjectLinkedOpenHashMap<>(Map.of("error?", "error."))).single()
) )
.doFinally(s -> map.close()) .doFinally(s -> map.close())
) )
@ -739,20 +776,19 @@ public abstract class TestDictionaryMapDeep {
} else { } else {
badKeys = List.of(); badKeys = List.of();
} }
List<Tuple2<List<String>, Boolean>> keys = Stream.concat( List<Tuple2<List<String>, Boolean>> keys = Stream
goodKeys.stream().map(s -> Tuples.of(s, false)), .concat(goodKeys.stream().map(s -> Tuples.of(s, false)), badKeys.stream().map(s -> Tuples.of(s, true)))
badKeys.stream().map(s -> Tuples.of(s, true)) .toList();
).collect(Collectors.toList()); var values = isCIMode() ? List.of(new Object2ObjectLinkedOpenHashMap<>(Map.of("123456", "val"))) : List.of(
var values = isCIMode() ? List.of(Map.of("123456", "val")) : List.of( new Object2ObjectLinkedOpenHashMap<>(Map.of("123456", "a", "234567", "")),
Map.of("123456", "a", "234567", ""), new Object2ObjectLinkedOpenHashMap<>(Map.of("123456", "\0", "234567", "\0\0", "345678", BIG_STRING))
Map.of("123456", "\0", "234567", "\0\0", "345678", BIG_STRING)
); );
return keys return keys
.stream() .stream()
.map(keyTuple -> keyTuple.mapT1(ks -> Flux .map(keyTuple -> keyTuple.mapT1(ks -> Flux
.zip(Flux.fromIterable(ks), Flux.fromIterable(values)) .zip(Flux.fromIterable(ks), Flux.fromIterable(values))
.collectMap(Tuple2::getT1, Tuple2::getT2) .collectMap(Tuple2::getT1, Tuple2::getT2, Object2ObjectLinkedOpenHashMap::new)
.block() .block()
)) ))
.flatMap(entryTuple -> Arrays.stream(UpdateMode.values()).map(updateMode -> Tuples.of(updateMode, .flatMap(entryTuple -> Arrays.stream(UpdateMode.values()).map(updateMode -> Tuples.of(updateMode,
@ -764,7 +800,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetMultiGetMulti(UpdateMode updateMode,
Map<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var flux = tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) var flux = tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
@ -793,7 +830,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAllValuesGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetAllValuesGetMulti(UpdateMode updateMode,
Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Map<String, String>>> stpVer = StepVerifier
@ -824,10 +862,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAllValuesAndGetPrevious(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetAllValuesAndGetPrevious(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
@ -844,7 +882,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -853,9 +891,9 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetGetMulti(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> { .flatMapMany(map -> {
@ -877,7 +915,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -886,7 +924,7 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAndGetStatus(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetAndGetStatus(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
Step<Boolean> stpVer = StepVerifier Step<Boolean> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -919,10 +957,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAndGetPrevious(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetAndGetPrevious(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
@ -940,7 +978,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -949,10 +987,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetClearAndGetPreviousGet(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetClearAndGetPreviousGet(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
@ -968,7 +1006,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -977,10 +1015,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGetAllValues(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetMultiGetAllValues(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
@ -996,7 +1034,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -1005,9 +1043,9 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGet(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetMultiGet(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries, boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
@ -1025,7 +1063,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -1034,10 +1072,10 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGetAllStagesGet(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetMultiGetAllStagesGet(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
var remainingEntries = new ConcurrentHashMap<Entry<String, Map<String, String>>, Boolean>().keySet(true); var remainingEntries = new ConcurrentHashMap<Entry<String, Object2ObjectSortedMap<String, String>>, Boolean>().keySet(true);
Step<Entry<String, Map<String, String>>> stpVer = StepVerifier Step<Entry<String, Object2ObjectSortedMap<String, String>>> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))
.flatMapMany(map -> Flux .flatMapMany(map -> Flux
@ -1060,7 +1098,7 @@ public abstract class TestDictionaryMapDeep {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v))); entries.forEach((k, v) -> remainingEntries.add(Map.entry(k, v)));
for (Entry<String, Map<String, String>> ignored : remainingEntries) { for (Entry<String, Object2ObjectSortedMap<String, String>> ignored : remainingEntries) {
stpVer = stpVer.expectNextMatches(remainingEntries::remove); stpVer = stpVer.expectNextMatches(remainingEntries::remove);
} }
stpVer.verifyComplete(); stpVer.verifyComplete();
@ -1069,7 +1107,7 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiIsEmpty(UpdateMode updateMode, Map<String, Map<String, String>> entries, public void testSetMultiIsEmpty(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries,
boolean shouldFail) { boolean shouldFail) {
Step<Boolean> stpVer = StepVerifier Step<Boolean> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -1094,7 +1132,7 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiClear(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetMultiClear(UpdateMode updateMode, Object2ObjectSortedMap<String, Object2ObjectSortedMap<String, String>> entries, boolean shouldFail) {
Step<Boolean> stpVer = StepVerifier Step<Boolean> stpVer = StepVerifier
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
.map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6)) .map(dict -> tempDatabaseMapDictionaryDeepMap(dict, 5, 6))