Update DatabaseMapDictionary.java, DatabaseMapDictionaryDeep.java, and 5 more files...

This commit is contained in:
Andrea Cavalli 2021-02-01 10:56:14 +01:00
parent a949fcd1de
commit f537303b90
7 changed files with 29 additions and 22 deletions

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary;
@ -18,22 +19,22 @@ import reactor.core.publisher.Mono;
*/
public class DatabaseMapDictionary<T, U> extends DatabaseMapDictionaryDeep<T, U, DatabaseStageEntry<U>> {
private final Serializer<U> valueSerializer;
private final Serializer<U, ByteBuf> valueSerializer;
protected DatabaseMapDictionary(LLDictionary dictionary, byte[] prefixKey, SerializerFixedBinaryLength<T> keySuffixSerializer, Serializer<U> valueSerializer) {
protected DatabaseMapDictionary(LLDictionary dictionary, byte[] prefixKey, SerializerFixedBinaryLength<T, ByteBuf> keySuffixSerializer, Serializer<U, ByteBuf> valueSerializer) {
super(dictionary, new SubStageGetterSingle<>(valueSerializer), keySuffixSerializer, prefixKey, 0);
this.valueSerializer = valueSerializer;
}
public static <T, U> DatabaseMapDictionary<T, U> simple(LLDictionary dictionary,
SerializerFixedBinaryLength<T> keySerializer,
Serializer<U> valueSerializer) {
SerializerFixedBinaryLength<T, ByteBuf> keySerializer,
Serializer<U, ByteBuf> valueSerializer) {
return new DatabaseMapDictionary<>(dictionary, EMPTY_BYTES, keySerializer, valueSerializer);
}
public static <T, U> DatabaseMapDictionary<T, U> tail(LLDictionary dictionary,
SerializerFixedBinaryLength<T> keySuffixSerializer,
Serializer<U> valueSerializer,
SerializerFixedBinaryLength<T, ByteBuf> keySuffixSerializer,
Serializer<U, ByteBuf> valueSerializer,
byte[] prefixKey) {
return new DatabaseMapDictionary<>(dictionary, prefixKey, keySuffixSerializer, valueSerializer);
}

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary;
@ -20,7 +21,7 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> implem
public static final byte[] EMPTY_BYTES = new byte[0];
protected final LLDictionary dictionary;
protected final SubStageGetter<U, US> subStageGetter;
protected final SerializerFixedBinaryLength<T> keySuffixSerializer;
protected final SerializerFixedBinaryLength<T, ByteBuf> keySuffixSerializer;
protected final byte[] keyPrefix;
protected final int keySuffixLength;
protected final int keyExtLength;
@ -73,20 +74,20 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> implem
@Deprecated
public static <T, U> DatabaseMapDictionaryDeep<T, U, DatabaseStageEntry<U>> simple(LLDictionary dictionary,
SubStageGetterSingle<U> subStageGetter,
SerializerFixedBinaryLength<T> keySerializer) {
SerializerFixedBinaryLength<T, ByteBuf> keySerializer) {
return new DatabaseMapDictionaryDeep<>(dictionary, subStageGetter, keySerializer, EMPTY_BYTES, 0);
}
public static <T, U, US extends DatabaseStage<U>> DatabaseMapDictionaryDeep<T, U, US> deepTail(LLDictionary dictionary,
SubStageGetter<U, US> subStageGetter,
SerializerFixedBinaryLength<T> keySerializer,
SerializerFixedBinaryLength<T, ByteBuf> keySerializer,
int keyExtLength) {
return new DatabaseMapDictionaryDeep<>(dictionary, subStageGetter, keySerializer, EMPTY_BYTES, keyExtLength);
}
public static <T, U, US extends DatabaseStage<U>> DatabaseMapDictionaryDeep<T, U, US> deepIntermediate(LLDictionary dictionary,
SubStageGetter<U, US> subStageGetter,
SerializerFixedBinaryLength<T> keySuffixSerializer,
SerializerFixedBinaryLength<T, ByteBuf> keySuffixSerializer,
byte[] prefixKey,
int keyExtLength) {
return new DatabaseMapDictionaryDeep<>(dictionary, subStageGetter, keySuffixSerializer, prefixKey, keyExtLength);
@ -94,7 +95,7 @@ public class DatabaseMapDictionaryDeep<T, U, US extends DatabaseStage<U>> implem
protected DatabaseMapDictionaryDeep(LLDictionary dictionary,
SubStageGetter<U, US> subStageGetter,
SerializerFixedBinaryLength<T> keySuffixSerializer,
SerializerFixedBinaryLength<T, ByteBuf> keySuffixSerializer,
byte[] prefixKey,
int keyExtLength) {
this.dictionary = dictionary;

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary;
@ -13,9 +14,9 @@ public class DatabaseSingle<U> implements DatabaseStageEntry<U> {
private final LLDictionary dictionary;
private final byte[] key;
private final Serializer<U> serializer;
private final Serializer<U, ByteBuf> serializer;
public DatabaseSingle(LLDictionary dictionary, byte[] key, Serializer<U> serializer) {
public DatabaseSingle(LLDictionary dictionary, byte[] key, Serializer<U, ByteBuf> serializer) {
this.dictionary = dictionary;
this.key = key;
this.serializer = serializer;

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.cavallium.dbengine.client.CompositeSnapshot;
import org.jetbrains.annotations.Nullable;
@ -8,9 +9,9 @@ import reactor.core.publisher.Mono;
public class DatabaseSingleMapped<U> implements DatabaseStageEntry<U> {
private final DatabaseSingle<byte[]> serializedSingle;
private final Serializer<U> serializer;
private final Serializer<U, ByteBuf> serializer;
public DatabaseSingleMapped(DatabaseSingle<byte[]> serializedSingle, Serializer<U> serializer) {
public DatabaseSingleMapped(DatabaseSingle<byte[]> serializedSingle, Serializer<U, ByteBuf> serializer) {
this.serializedSingle = serializedSingle;
this.serializer = serializer;
}

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary;
import java.util.Map;
@ -9,10 +10,10 @@ import reactor.core.publisher.Mono;
public class SubStageGetterMap<T, U> implements SubStageGetter<Map<T, U>, DatabaseStageEntry<Map<T, U>>> {
private final SerializerFixedBinaryLength<T> keySerializer;
private final Serializer<U> valueSerializer;
private final SerializerFixedBinaryLength<T, ByteBuf> keySerializer;
private final Serializer<U, ByteBuf> valueSerializer;
public SubStageGetterMap(SerializerFixedBinaryLength<T> keySerializer, Serializer<U> valueSerializer) {
public SubStageGetterMap(SerializerFixedBinaryLength<T, ByteBuf> keySerializer, Serializer<U, ByteBuf> valueSerializer) {
this.keySerializer = keySerializer;
this.valueSerializer = valueSerializer;
}

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary;
import java.util.Map;
@ -11,11 +12,11 @@ public class SubStageGetterMapDeep<T, U, US extends DatabaseStage<U>> implements
SubStageGetter<Map<T, U>, DatabaseStageEntry<Map<T, U>>> {
private final SubStageGetter<U, US> subStageGetter;
private final SerializerFixedBinaryLength<T> keySerializer;
private final SerializerFixedBinaryLength<T, ByteBuf> keySerializer;
private final int keyExtLength;
public SubStageGetterMapDeep(SubStageGetter<U, US> subStageGetter,
SerializerFixedBinaryLength<T> keySerializer,
SerializerFixedBinaryLength<T, ByteBuf> keySerializer,
int keyExtLength) {
this.subStageGetter = subStageGetter;
this.keySerializer = keySerializer;

View File

@ -1,5 +1,6 @@
package it.cavallium.dbengine.database.collections;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.cavallium.dbengine.client.CompositeSnapshot;
import it.cavallium.dbengine.database.LLDictionary;
@ -10,9 +11,9 @@ import reactor.core.publisher.Mono;
public class SubStageGetterSingle<T> implements SubStageGetter<T, DatabaseStageEntry<T>> {
private final Serializer<T> serializer;
private final Serializer<T, ByteBuf> serializer;
public SubStageGetterSingle(Serializer<T> serializer) {
public SubStageGetterSingle(Serializer<T, ByteBuf> serializer) {
this.serializer = serializer;
}