Avoid multiple drops

This commit is contained in:
Andrea Cavalli 2021-09-24 01:59:56 +02:00
parent 9c86a51a69
commit 20c19f662b
12 changed files with 147 additions and 95 deletions

View File

@ -30,6 +30,7 @@ public class LLDelta extends LiveResourceSupport<LLDelta, LLDelta> {
} }
public static LLDelta of(Send<Buffer> min, Send<Buffer> max) { public static LLDelta of(Send<Buffer> min, Send<Buffer> max) {
assert (min == null && max == null) || (min != max);
return new LLDelta(min, max, d -> {}); return new LLDelta(min, max, d -> {});
} }
@ -80,17 +81,16 @@ public class LLDelta extends LiveResourceSupport<LLDelta, LLDelta> {
@Override @Override
public String toString() { public String toString() {
return new StringJoiner(", ", LLDelta.class.getSimpleName() + "[", "]") return new StringJoiner(", ", LLDelta.class.getSimpleName() + "[", "]")
.add("min=" + LLUtils.toString(previous)) .add("min=" + LLUtils.toStringSafe(previous))
.add("max=" + LLUtils.toString(current)) .add("max=" + LLUtils.toStringSafe(current))
.toString(); .toString();
} }
public LLDelta copy() { public LLDelta copy() {
ensureOwned(); ensureOwned();
return new LLDelta(previous != null ? previous.copy().send() : null, var prevCopy = previous != null ? previous.copy().send() : null;
current != null ? current.copy().send() : null, Send<Buffer> curCopy = current != null ? current.copy().send() : null;
d -> {} return new LLDelta(prevCopy, curCopy, d -> {});
);
} }
@Override @Override
@ -100,10 +100,8 @@ public class LLDelta extends LiveResourceSupport<LLDelta, LLDelta> {
@Override @Override
protected Owned<LLDelta> prepareSend() { protected Owned<LLDelta> prepareSend() {
Send<Buffer> minSend; Send<Buffer> minSend = this.previous != null ? this.previous.send() : null;
Send<Buffer> maxSend; Send<Buffer> maxSend = this.current != null ? this.current.send() : null;
minSend = this.previous != null ? this.previous.send() : null;
maxSend = this.current != null ? this.current.send() : null;
return drop -> new LLDelta(minSend, maxSend, drop); return drop -> new LLDelta(minSend, maxSend, drop);
} }
@ -112,17 +110,17 @@ public class LLDelta extends LiveResourceSupport<LLDelta, LLDelta> {
private final Drop<LLDelta> delegate; private final Drop<LLDelta> delegate;
public CloseOnDrop(Drop<LLDelta> drop) { public CloseOnDrop(Drop<LLDelta> drop) {
if (drop instanceof CloseOnDrop closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(LLDelta obj) { public void drop(LLDelta obj) {
if (obj.previous != null && obj.previous.isAccessible()) { if (obj.previous != null) obj.previous.close();
obj.previous.close(); if (obj.current != null) obj.current.close();
}
if (obj.current != null && obj.current.isAccessible()) {
obj.current.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -115,17 +115,17 @@ public class LLEntry extends LiveResourceSupport<LLEntry, LLEntry> {
private final Drop<LLEntry> delegate; private final Drop<LLEntry> delegate;
public CloseOnDrop(Drop<LLEntry> drop) { public CloseOnDrop(Drop<LLEntry> drop) {
if (drop instanceof CloseOnDrop closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(LLEntry obj) { public void drop(LLEntry obj) {
if (obj.key.isAccessible()) {
obj.key.close(); obj.key.close();
}
if (obj.value.isAccessible()) {
obj.value.close(); obj.value.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -8,6 +8,7 @@ import io.net5.buffer.api.Owned;
import io.net5.buffer.api.Send; import io.net5.buffer.api.Send;
import io.net5.buffer.api.internal.ResourceSupport; import io.net5.buffer.api.internal.ResourceSupport;
import java.util.StringJoiner; import java.util.StringJoiner;
import org.jetbrains.annotations.Nullable;
/** /**
* Range of data, from min (inclusive),to max (exclusive) * Range of data, from min (inclusive),to max (exclusive)
@ -15,8 +16,11 @@ import java.util.StringJoiner;
public class LLRange extends LiveResourceSupport<LLRange, LLRange> { public class LLRange extends LiveResourceSupport<LLRange, LLRange> {
private static final LLRange RANGE_ALL = new LLRange(null, null, null, d -> {}); private static final LLRange RANGE_ALL = new LLRange(null, null, null, d -> {});
@Nullable
private Buffer min; private Buffer min;
@Nullable
private Buffer max; private Buffer max;
@Nullable
private Buffer single; private Buffer single;
private LLRange(Send<Buffer> min, Send<Buffer> max, Send<Buffer> single, Drop<LLRange> drop) { private LLRange(Send<Buffer> min, Send<Buffer> max, Send<Buffer> single, Drop<LLRange> drop) {
@ -207,14 +211,18 @@ public class LLRange extends LiveResourceSupport<LLRange, LLRange> {
private final Drop<LLRange> delegate; private final Drop<LLRange> delegate;
public CloseOnDrop(Drop<LLRange> drop) { public CloseOnDrop(Drop<LLRange> drop) {
if (drop instanceof CloseOnDrop closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(LLRange obj) { public void drop(LLRange obj) {
if (obj.min != null && obj.min.isAccessible()) obj.min.close(); if (obj.min != null) obj.min.close();
if (obj.max != null && obj.max.isAccessible()) obj.max.close(); if (obj.max != null) obj.max.close();
if (obj.single != null && obj.single.isAccessible()) obj.single.close(); if (obj.single != null) obj.single.close();
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -12,6 +12,7 @@ import it.cavallium.dbengine.client.BadBlock;
import it.cavallium.dbengine.client.CompositeSnapshot; import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLDictionaryResultType; import it.cavallium.dbengine.database.LLDictionaryResultType;
import it.cavallium.dbengine.database.LLEntry;
import it.cavallium.dbengine.database.LLRange; import it.cavallium.dbengine.database.LLRange;
import it.cavallium.dbengine.database.LLSnapshot; import it.cavallium.dbengine.database.LLSnapshot;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
@ -427,23 +428,23 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> extend
this.range = null; this.range = null;
} }
private static class CloseOnDrop<T, U, US extends DatabaseStage<U>> implements private static class CloseOnDrop<T, U, US extends DatabaseStage<U>>
Drop<DatabaseMapDictionaryDeep<T, U, US>> { implements Drop<DatabaseMapDictionaryDeep<T, U, US>> {
private final Drop<DatabaseMapDictionaryDeep<T,U,US>> delegate; private final Drop<DatabaseMapDictionaryDeep<T,U,US>> delegate;
public CloseOnDrop(Drop<DatabaseMapDictionaryDeep<T, U, US>> drop) { public CloseOnDrop(Drop<DatabaseMapDictionaryDeep<T, U, US>> drop) {
if (drop instanceof CloseOnDrop<T, U, US> closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(DatabaseMapDictionaryDeep<T, U, US> obj) { public void drop(DatabaseMapDictionaryDeep<T, U, US> obj) {
if (obj.range != null) {
obj.range.close(); obj.range.close();
}
if (obj.keyPrefix != null) {
obj.keyPrefix.close(); obj.keyPrefix.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -8,6 +8,7 @@ import io.net5.buffer.api.Send;
import it.cavallium.dbengine.client.BadBlock; import it.cavallium.dbengine.client.BadBlock;
import it.cavallium.dbengine.client.CompositeSnapshot; import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLEntry;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.LiveResourceSupport; import it.cavallium.dbengine.database.LiveResourceSupport;
import it.cavallium.dbengine.database.UpdateMode; import it.cavallium.dbengine.database.UpdateMode;
@ -327,14 +328,16 @@ public class DatabaseMapDictionaryHashed<T, U, TH> extends
private final Drop<DatabaseMapDictionaryHashed<T,U,TH>> delegate; private final Drop<DatabaseMapDictionaryHashed<T,U,TH>> delegate;
public CloseOnDrop(Drop<DatabaseMapDictionaryHashed<T,U,TH>> drop) { public CloseOnDrop(Drop<DatabaseMapDictionaryHashed<T,U,TH>> drop) {
if (drop instanceof CloseOnDrop<T, U, TH> closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(DatabaseMapDictionaryHashed<T, U, TH> obj) { public void drop(DatabaseMapDictionaryHashed<T, U, TH> obj) {
if (obj.subDictionary != null) {
obj.subDictionary.close(); obj.subDictionary.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -10,6 +10,7 @@ import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.Delta; import it.cavallium.dbengine.database.Delta;
import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLDictionaryResultType; import it.cavallium.dbengine.database.LLDictionaryResultType;
import it.cavallium.dbengine.database.LLEntry;
import it.cavallium.dbengine.database.LLRange; import it.cavallium.dbengine.database.LLRange;
import it.cavallium.dbengine.database.LLSnapshot; import it.cavallium.dbengine.database.LLSnapshot;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
@ -156,14 +157,16 @@ public class DatabaseSingle<U> extends ResourceSupport<DatabaseStage<U>, Databas
private final Drop<DatabaseSingle<U>> delegate; private final Drop<DatabaseSingle<U>> delegate;
public CloseOnDrop(Drop<DatabaseSingle<U>> drop) { public CloseOnDrop(Drop<DatabaseSingle<U>> drop) {
if (drop instanceof CloseOnDrop<U> closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(DatabaseSingle<U> obj) { public void drop(DatabaseSingle<U> obj) {
if (obj.key != null) {
obj.key.close(); obj.key.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -7,6 +7,7 @@ import it.cavallium.dbengine.client.BadBlock;
import it.cavallium.dbengine.client.CompositeSnapshot; import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.Column; import it.cavallium.dbengine.database.Column;
import it.cavallium.dbengine.database.Delta; import it.cavallium.dbengine.database.Delta;
import it.cavallium.dbengine.database.LLEntry;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.LiveResourceSupport; import it.cavallium.dbengine.database.LiveResourceSupport;
import it.cavallium.dbengine.database.UpdateReturnMode; import it.cavallium.dbengine.database.UpdateReturnMode;
@ -223,14 +224,16 @@ public class DatabaseSingleBucket<K, V, TH>
private final Drop<DatabaseSingleBucket<K, V, TH>> delegate; private final Drop<DatabaseSingleBucket<K, V, TH>> delegate;
public CloseOnDrop(Drop<DatabaseSingleBucket<K, V, TH>> drop) { public CloseOnDrop(Drop<DatabaseSingleBucket<K, V, TH>> drop) {
if (drop instanceof CloseOnDrop<K, V, TH> closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(DatabaseSingleBucket<K, V, TH> obj) { public void drop(DatabaseSingleBucket<K, V, TH> obj) {
if (obj.bucketStage != null) {
obj.bucketStage.close(); obj.bucketStage.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -8,6 +8,7 @@ import it.cavallium.dbengine.client.BadBlock;
import it.cavallium.dbengine.client.CompositeSnapshot; import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.client.Mapper; import it.cavallium.dbengine.client.Mapper;
import it.cavallium.dbengine.database.Delta; import it.cavallium.dbengine.database.Delta;
import it.cavallium.dbengine.database.LLEntry;
import it.cavallium.dbengine.database.LLUtils; import it.cavallium.dbengine.database.LLUtils;
import it.cavallium.dbengine.database.UpdateReturnMode; import it.cavallium.dbengine.database.UpdateReturnMode;
import it.cavallium.dbengine.database.serialization.SerializationException; import it.cavallium.dbengine.database.serialization.SerializationException;
@ -174,14 +175,16 @@ public class DatabaseSingleMapped<A, B> extends ResourceSupport<DatabaseStage<A>
private final Drop<DatabaseSingleMapped<A, B>> delegate; private final Drop<DatabaseSingleMapped<A, B>> delegate;
public CloseOnDrop(Drop<DatabaseSingleMapped<A, B>> drop) { public CloseOnDrop(Drop<DatabaseSingleMapped<A, B>> drop) {
if (drop instanceof CloseOnDrop<A, B> closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(DatabaseSingleMapped<A, B> obj) { public void drop(DatabaseSingleMapped<A, B> obj) {
if (obj.serializedSingle != null) {
obj.serializedSingle.close(); obj.serializedSingle.close();
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -5,6 +5,7 @@ import io.net5.buffer.api.Owned;
import io.net5.buffer.api.Resource; import io.net5.buffer.api.Resource;
import io.net5.buffer.api.Send; import io.net5.buffer.api.Send;
import io.net5.buffer.api.internal.ResourceSupport; import io.net5.buffer.api.internal.ResourceSupport;
import it.cavallium.dbengine.database.LLEntry;
import it.cavallium.dbengine.database.LiveResourceSupport; import it.cavallium.dbengine.database.LiveResourceSupport;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.io.IOException; import java.io.IOException;
@ -93,12 +94,16 @@ public interface LLIndexSearchers extends Resource<LLIndexSearchers> {
private final Drop<UnshardedIndexSearchers> delegate; private final Drop<UnshardedIndexSearchers> delegate;
public CloseOnDrop(Drop<UnshardedIndexSearchers> drop) { public CloseOnDrop(Drop<UnshardedIndexSearchers> drop) {
if (drop instanceof CloseOnDrop closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(UnshardedIndexSearchers obj) { public void drop(UnshardedIndexSearchers obj) {
if (obj.indexSearcher != null) obj.indexSearcher.close(); obj.indexSearcher.close();
delegate.drop(obj); delegate.drop(obj);
} }
} }
@ -182,24 +187,21 @@ public interface LLIndexSearchers extends Resource<LLIndexSearchers> {
private static class CloseOnDrop implements Drop<ShardedIndexSearchers> { private static class CloseOnDrop implements Drop<ShardedIndexSearchers> {
private volatile boolean dropped = false;
private final Drop<ShardedIndexSearchers> delegate; private final Drop<ShardedIndexSearchers> delegate;
public CloseOnDrop(Drop<ShardedIndexSearchers> drop) { public CloseOnDrop(Drop<ShardedIndexSearchers> drop) {
if (drop instanceof CloseOnDrop closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(ShardedIndexSearchers obj) { public void drop(ShardedIndexSearchers obj) {
assert !dropped;
if (obj.indexSearchers != null) {
for (LLIndexSearcher indexSearcher : obj.indexSearchers) { for (LLIndexSearcher indexSearcher : obj.indexSearchers) {
if (indexSearcher.isAccessible()) {
indexSearcher.close(); indexSearcher.close();
} }
}
}
dropped = true;
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -930,6 +930,10 @@ public class LLLocalDictionary implements LLDictionary {
assert newData.isAccessible(); assert newData.isAccessible();
dbPut(cfh, null, key.send(), newData.copy().send()); dbPut(cfh, null, key.send(), newData.copy().send());
} }
if (newData == prevData && newData != null) {
newData = newData.copy();
}
assert (prevData == null && newData == null) || newData != prevData;
return LLDelta.of( return LLDelta.of(
prevData != null ? prevData.send() : null, prevData != null ? prevData.send() : null,
newData != null ? newData.send() : null newData != null ? newData.send() : null

View File

@ -7,6 +7,7 @@ import io.net5.buffer.api.Send;
import io.net5.buffer.api.internal.ResourceSupport; import io.net5.buffer.api.internal.ResourceSupport;
import it.cavallium.dbengine.client.SearchResult; import it.cavallium.dbengine.client.SearchResult;
import it.cavallium.dbengine.database.LiveResourceSupport; import it.cavallium.dbengine.database.LiveResourceSupport;
import it.cavallium.dbengine.database.collections.DatabaseSingle;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class NullableBuffer extends LiveResourceSupport<NullableBuffer, NullableBuffer> { public class NullableBuffer extends LiveResourceSupport<NullableBuffer, NullableBuffer> {
@ -54,16 +55,16 @@ public class NullableBuffer extends LiveResourceSupport<NullableBuffer, Nullable
private final Drop<NullableBuffer> delegate; private final Drop<NullableBuffer> delegate;
public CloseOnDrop(Drop<NullableBuffer> drop) { public CloseOnDrop(Drop<NullableBuffer> drop) {
if (drop instanceof CloseOnDrop closeOnDrop) {
this.delegate = closeOnDrop.delegate;
} else {
this.delegate = drop; this.delegate = drop;
} }
}
@Override @Override
public void drop(NullableBuffer obj) { public void drop(NullableBuffer obj) {
if (obj.buffer != null) { if (obj.buffer != null) obj.buffer.close();
if (obj.buffer.isAccessible()) {
obj.buffer.close();
}
}
delegate.drop(obj); delegate.drop(obj);
} }
} }

View File

@ -229,9 +229,7 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetValueGetAllValues(UpdateMode updateMode, public void testSetValueGetAllValues(UpdateMode updateMode, String key, Map<String, String> value,
String key,
Map<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)
@ -252,7 +250,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testAtSetGetAllStagesGetAllValues(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testAtSetGetAllStagesGetAllValues(UpdateMode updateMode, String key, Map<String, String> value,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -302,13 +301,24 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource({"provideArgumentsPut"}) @MethodSource({"provideArgumentsPut"})
public void testAtPutValueAtGetValue(UpdateMode updateMode, String key1, String key2, String value, boolean shouldFail) { public void testAtPutValueAtGetValue(UpdateMode updateMode, String key1, String key2, 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))
.flatMap(map -> map .flatMap(map -> map
.at(null, key1).flatMap(v -> v.putValue(key2, value).doFinally(s -> v.close())) .at(null, key1)
.then(map.at(null, key1).flatMap(v -> v.getValue(null, key2).doFinally(s -> v.close()))) .flatMap(v -> v
.putValue(key2, value)
.doFinally(s -> v.close())
)
.then(map
.at(null, key1)
.flatMap(v -> v
.getValue(null, key2)
.doFinally(s -> v.close())
)
)
.doFinally(s -> map.close()) .doFinally(s -> map.close())
) )
)); ));
@ -327,8 +337,8 @@ public abstract class TestDictionaryMapDeep {
.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, Map.of("error?", "error."))
.defaultIfEmpty(Map.of("nothing", "nothing")), .defaultIfEmpty(Map.of("nothing", "nothing")),
map.putValueAndGetPrevious(key, value), map.putValueAndGetPrevious(key, value),
@ -347,7 +357,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPut") @MethodSource("provideArgumentsPut")
public void testAtPutValueAndGetPrevious(UpdateMode updateMode, String key1, String key2, String value, boolean shouldFail) { public void testAtPutValueAndGetPrevious(UpdateMode updateMode, String key1, String key2, 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))
@ -385,7 +396,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetValueRemoveAndGetPrevious(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testSetValueRemoveAndGetPrevious(UpdateMode updateMode, String key, Map<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))
@ -408,7 +420,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPut") @MethodSource("provideArgumentsPut")
public void testAtPutValueRemoveAndGetPrevious(UpdateMode updateMode, String key1, String key2, String value, boolean shouldFail) { public void testAtPutValueRemoveAndGetPrevious(UpdateMode updateMode, String key1, String key2, 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))
@ -447,7 +460,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSet") @MethodSource("provideArgumentsSet")
public void testSetValueRemoveAndGetStatus(UpdateMode updateMode, String key, Map<String, String> value, boolean shouldFail) { public void testSetValueRemoveAndGetStatus(UpdateMode updateMode, String key, Map<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))
@ -470,7 +484,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsPut") @MethodSource("provideArgumentsPut")
public void testAtPutValueRemoveAndGetStatus(UpdateMode updateMode, String key1, String key2, String value, boolean shouldFail) { public void testAtPutValueRemoveAndGetStatus(UpdateMode updateMode, String key1, String key2, 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))
@ -630,7 +645,9 @@ public abstract class TestDictionaryMapDeep {
if (updateMode != UpdateMode.ALLOW_UNSAFE || shouldFail) { if (updateMode != UpdateMode.ALLOW_UNSAFE || shouldFail) {
stpVer.verifyError(); stpVer.verifyError();
} else { } else {
stpVer.expectNext(Map.of("error?", "error."), Map.of("error?", "error."), Map.of("error?", "error."), value, value).verifyComplete(); stpVer
.expectNext(Map.of("error?", "error."), Map.of("error?", "error."), Map.of("error?", "error."), value, value)
.verifyComplete();
} }
} }
@ -747,7 +764,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetMultiGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -777,7 +795,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAllValuesGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetAllValuesGetMulti(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -804,7 +823,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAllValuesAndGetPrevious(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetAllValuesAndGetPrevious(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -862,7 +882,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAndGetStatus(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetAndGetStatus(UpdateMode updateMode, Map<String, Map<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))
@ -894,7 +915,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetAndGetPrevious(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetAndGetPrevious(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -923,7 +945,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetClearAndGetPreviousGet(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetClearAndGetPreviousGet(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -950,7 +973,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGetAllValues(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetMultiGetAllValues(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -1006,7 +1030,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiGetAllStagesGet(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetMultiGetAllStagesGet(UpdateMode updateMode, Map<String, Map<String, String>> entries,
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
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode) .create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
@ -1040,7 +1065,8 @@ public abstract class TestDictionaryMapDeep {
@ParameterizedTest @ParameterizedTest
@MethodSource("provideArgumentsSetMulti") @MethodSource("provideArgumentsSetMulti")
public void testSetMultiIsEmpty(UpdateMode updateMode, Map<String, Map<String, String>> entries, boolean shouldFail) { public void testSetMultiIsEmpty(UpdateMode updateMode, Map<String, Map<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))