Update Example.java, SubStageGetterMap.java, and SubStageGetterMapDeep.java
This commit is contained in:
parent
d9187b70a9
commit
ae5cda2f70
@ -26,7 +26,6 @@ import java.util.Comparator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -147,7 +146,8 @@ public class Example {
|
|||||||
tempDb()
|
tempDb()
|
||||||
.flatMap(db -> db.getDictionary("testmap").map(dict -> Tuples.of(db, dict)))
|
.flatMap(db -> db.getDictionary("testmap").map(dict -> Tuples.of(db, dict)))
|
||||||
.map(tuple -> tuple.mapT2(dict -> {
|
.map(tuple -> tuple.mapT2(dict -> {
|
||||||
return DatabaseMapDictionaryDeep.deepTail(dict, ssg2, k1ser, ssg2.getKeyBinaryLength());
|
return DatabaseMapDictionaryDeep
|
||||||
|
.deepTail(dict, ssg2, k1ser, ssg2.getKeyBinaryLength());
|
||||||
})),
|
})),
|
||||||
tuple -> Flux.range(0, batchSize).flatMap(n -> {
|
tuple -> Flux.range(0, batchSize).flatMap(n -> {
|
||||||
var itemKey1 = Ints.toByteArray(n / 4);
|
var itemKey1 = Ints.toByteArray(n / 4);
|
||||||
@ -161,9 +161,7 @@ public class Example {
|
|||||||
System.out.println("Setting new value at key " + Arrays.toString(itemKey1) + "+" + Arrays.toString(itemKey2) + "+" + Arrays.toString(itemKey3) + ": " + Arrays.toString(newValue));
|
System.out.println("Setting new value at key " + Arrays.toString(itemKey1) + "+" + Arrays.toString(itemKey2) + "+" + Arrays.toString(itemKey3) + ": " + Arrays.toString(newValue));
|
||||||
})
|
})
|
||||||
.then(tuple.getT2().at(null, itemKey1))
|
.then(tuple.getT2().at(null, itemKey1))
|
||||||
.map(handle -> (DatabaseStageMap<byte[], Map<byte[], byte[]>, DatabaseStageEntry<Map<byte[], byte[]>>>) handle)
|
|
||||||
.flatMap(handleK1 -> handleK1.at(null, itemKey2))
|
.flatMap(handleK1 -> handleK1.at(null, itemKey2))
|
||||||
.map(handle -> (DatabaseStageMap<byte[], byte[], DatabaseStageEntry<byte[]>>) handle)
|
|
||||||
.flatMap(handleK2 -> handleK2.at(null, itemKey3))
|
.flatMap(handleK2 -> handleK2.at(null, itemKey3))
|
||||||
.flatMap(handleK3 -> handleK3.setAndGetPrevious(newValue))
|
.flatMap(handleK3 -> handleK3.setAndGetPrevious(newValue))
|
||||||
.doOnSuccess(oldValue -> {
|
.doOnSuccess(oldValue -> {
|
||||||
@ -183,15 +181,14 @@ public class Example {
|
|||||||
var k3ser = SerializerFixedBinaryLength.noop(4);
|
var k3ser = SerializerFixedBinaryLength.noop(4);
|
||||||
var k4ser = SerializerFixedBinaryLength.noop(8);
|
var k4ser = SerializerFixedBinaryLength.noop(8);
|
||||||
var vser = SerializerFixedBinaryLength.noop(4);
|
var vser = SerializerFixedBinaryLength.noop(4);
|
||||||
var ssg4 = new SubStageGetterMap<byte[], byte[]>(k4ser, vser);
|
SubStageGetterMap<byte[], byte[]> ssg4 = new SubStageGetterMap<>(k4ser, vser);
|
||||||
var ssg3 = new SubStageGetterMapDeep<>(ssg4, k3ser, ssg4.getKeyBinaryLength());
|
var ssg3 = new SubStageGetterMapDeep<>(ssg4, k3ser, ssg4.getKeyBinaryLength());
|
||||||
var ssg2 = new SubStageGetterMapDeep<>(ssg3, k2ser, ssg3.getKeyBinaryLength());
|
var ssg2 = new SubStageGetterMapDeep<>(ssg3, k2ser, ssg3.getKeyBinaryLength());
|
||||||
return test("4 level put",
|
return test("4 level put",
|
||||||
tempDb()
|
tempDb()
|
||||||
.flatMap(db -> db.getDictionary("testmap").map(dict -> Tuples.of(db, dict)))
|
.flatMap(db -> db.getDictionary("testmap").map(dict -> Tuples.of(db, dict)))
|
||||||
.map(tuple -> tuple.mapT2(dict -> {
|
.map(tuple -> tuple.mapT2(dict -> DatabaseMapDictionaryDeep
|
||||||
return DatabaseMapDictionaryDeep.deepTail(dict, ssg2, k1ser, ssg2.getKeyBinaryLength());
|
.deepTail(dict, ssg2, k1ser, ssg2.getKeyBinaryLength()))),
|
||||||
})),
|
|
||||||
tuple -> Flux.range(0, batchSize).flatMap(n -> {
|
tuple -> Flux.range(0, batchSize).flatMap(n -> {
|
||||||
var itemKey1 = Ints.toByteArray(n / 4);
|
var itemKey1 = Ints.toByteArray(n / 4);
|
||||||
var itemKey2 = Longs.toByteArray(n);
|
var itemKey2 = Longs.toByteArray(n);
|
||||||
@ -205,11 +202,8 @@ public class Example {
|
|||||||
System.out.println("Setting new value at key " + Arrays.toString(itemKey1) + "+" + Arrays.toString(itemKey2) + "+" + Arrays.toString(itemKey3) + "+" + Arrays.toString(itemKey4) + ": " + Arrays.toString(newValue));
|
System.out.println("Setting new value at key " + Arrays.toString(itemKey1) + "+" + Arrays.toString(itemKey2) + "+" + Arrays.toString(itemKey3) + "+" + Arrays.toString(itemKey4) + ": " + Arrays.toString(newValue));
|
||||||
})
|
})
|
||||||
.then(tuple.getT2().at(null, itemKey1))
|
.then(tuple.getT2().at(null, itemKey1))
|
||||||
.map(handle -> (DatabaseStageMap<byte[], Map<byte[], Map<byte[], byte[]>>, DatabaseStageEntry<Map<byte[], Map<byte[], byte[]>>>>) handle)
|
|
||||||
.flatMap(handleK1 -> handleK1.at(null, itemKey2))
|
.flatMap(handleK1 -> handleK1.at(null, itemKey2))
|
||||||
.map(handle -> (DatabaseStageMap<byte[], Map<byte[], byte[]>, DatabaseStageEntry<Map<byte[], byte[]>>>) handle)
|
|
||||||
.flatMap(handleK2 -> handleK2.at(null, itemKey3))
|
.flatMap(handleK2 -> handleK2.at(null, itemKey3))
|
||||||
.map(handle -> (DatabaseStageMap<byte[], byte[], DatabaseStageEntry<byte[]>>) handle)
|
|
||||||
.flatMap(handleK3 -> handleK3.at(null, itemKey4))
|
.flatMap(handleK3 -> handleK3.at(null, itemKey4))
|
||||||
.flatMap(handleK4 -> handleK4.setAndGetPrevious(newValue))
|
.flatMap(handleK4 -> handleK4.setAndGetPrevious(newValue))
|
||||||
.doOnSuccess(oldValue -> {
|
.doOnSuccess(oldValue -> {
|
||||||
|
@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, DatabaseStageEntry<Map<T, U>>> {
|
public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, DatabaseMapDictionary<T, U>> {
|
||||||
|
|
||||||
private static final boolean assertsEnabled;
|
private static final boolean assertsEnabled;
|
||||||
static {
|
static {
|
||||||
@ -28,11 +28,11 @@ public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, Databa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<DatabaseStageEntry<Map<T, U>>> subStage(LLDictionary dictionary,
|
public Mono<DatabaseMapDictionary<T, U>> subStage(LLDictionary dictionary,
|
||||||
@Nullable CompositeSnapshot snapshot,
|
@Nullable CompositeSnapshot snapshot,
|
||||||
byte[] prefixKey,
|
byte[] prefixKey,
|
||||||
Flux<byte[]> keyFlux) {
|
Flux<byte[]> keyFlux) {
|
||||||
Mono<DatabaseStageEntry<Map<T, U>>> result = Mono.just(DatabaseMapDictionary.tail(dictionary,
|
Mono<DatabaseMapDictionary<T, U>> result = Mono.just(DatabaseMapDictionary.tail(dictionary,
|
||||||
keySerializer,
|
keySerializer,
|
||||||
valueSerializer,
|
valueSerializer,
|
||||||
prefixKey
|
prefixKey
|
||||||
|
@ -7,8 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
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<Map<T, U>, DatabaseStageEntry<Map<T, U>>> {
|
|
||||||
|
|
||||||
private static final boolean assertsEnabled;
|
private static final boolean assertsEnabled;
|
||||||
static {
|
static {
|
||||||
@ -44,11 +43,11 @@ public class SubStageGetterMapDeep<T, U, US extends DatabaseStage<U>> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<DatabaseStageEntry<Map<T, U>>> subStage(LLDictionary dictionary,
|
public Mono<DatabaseMapDictionaryDeep<T, U, US>> subStage(LLDictionary dictionary,
|
||||||
@Nullable CompositeSnapshot snapshot,
|
@Nullable CompositeSnapshot snapshot,
|
||||||
byte[] prefixKey,
|
byte[] prefixKey,
|
||||||
Flux<byte[]> keyFlux) {
|
Flux<byte[]> keyFlux) {
|
||||||
Mono<DatabaseStageEntry<Map<T, U>>> result = Mono.just(DatabaseMapDictionaryDeep.deepIntermediate(dictionary,
|
Mono<DatabaseMapDictionaryDeep<T, U, US>> result = Mono.just(DatabaseMapDictionaryDeep.deepIntermediate(dictionary,
|
||||||
subStageGetter,
|
subStageGetter,
|
||||||
keySerializer,
|
keySerializer,
|
||||||
prefixKey,
|
prefixKey,
|
||||||
|
Loading…
Reference in New Issue
Block a user