diff --git a/src/example/java/it.cavallium.dbengine.client/Example.java b/src/example/java/it.cavallium.dbengine.client/Example.java index 55a7ab6..9fcabc4 100644 --- a/src/example/java/it.cavallium.dbengine.client/Example.java +++ b/src/example/java/it.cavallium.dbengine.client/Example.java @@ -7,7 +7,7 @@ import it.cavallium.dbengine.database.Column; import it.cavallium.dbengine.database.LLKeyValueDatabase; import it.cavallium.dbengine.database.collections.DatabaseMapDictionary; import it.cavallium.dbengine.database.collections.DatabaseMapDictionaryDeep; -import it.cavallium.dbengine.database.collections.FixedLengthSerializer; +import it.cavallium.dbengine.database.collections.SerializerFixedBinaryLength; import it.cavallium.dbengine.database.collections.Serializer; import it.cavallium.dbengine.database.collections.SubStageGetterSingleBytes; import it.cavallium.dbengine.database.disk.LLLocalDatabaseConnection; @@ -62,7 +62,7 @@ public class Example { private static Mono testAtPut() { var ssg = new SubStageGetterSingleBytes(); - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var itemKey = new byte[]{0, 1, 2, 3}; var newValue = new byte[]{4, 5, 6, 7}; var itemKeyBuffer = Unpooled.wrappedBuffer(itemKey); @@ -90,7 +90,7 @@ public class Example { private static Mono testPutValueAndGetPrevious() { var ssg = new SubStageGetterSingleBytes(); - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var itemKey = new byte[]{0, 1, 2, 3}; var newValue = new byte[]{4, 5, 6, 7}; var itemKeyBuffer = Unpooled.wrappedBuffer(itemKey); @@ -117,7 +117,7 @@ public class Example { private static Mono testPutValue() { var ssg = new SubStageGetterSingleBytes(); - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var itemKey = new byte[]{0, 1, 2, 3}; var newValue = new byte[]{4, 5, 6, 7}; var itemKeyBuffer = Unpooled.wrappedBuffer(itemKey); @@ -140,7 +140,7 @@ public class Example { private static Mono testPutMulti() { var ssg = new SubStageGetterSingleBytes(); - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); HashMap keysToPut = new HashMap<>(); for (int i = 0; i < batchSize; i++) { keysToPut.put(Unpooled.wrappedBuffer(Ints.toByteArray(i * 3)), Ints.toByteArray(i * 11)); @@ -158,7 +158,7 @@ public class Example { } private static Mono rangeTestAtPut() { - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var vser = Serializer.noopBytes(); var itemKey = new byte[]{0, 1, 2, 3}; var newValue = new byte[]{4, 5, 6, 7}; @@ -186,7 +186,7 @@ public class Example { } private static Mono rangeTestPutValueAndGetPrevious() { - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var vser = Serializer.noopBytes(); var itemKey = new byte[]{0, 1, 2, 3}; var newValue = new byte[]{4, 5, 6, 7}; @@ -213,7 +213,7 @@ public class Example { } private static Mono rangeTestPutValue() { - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var vser = Serializer.noopBytes(); var itemKey = new byte[]{0, 1, 2, 3}; var newValue = new byte[]{4, 5, 6, 7}; @@ -236,7 +236,7 @@ public class Example { } private static Mono rangeTestPutMulti() { - var ser = FixedLengthSerializer.noop(4); + var ser = SerializerFixedBinaryLength.noop(4); var vser = Serializer.noopBytes(); HashMap keysToPut = new HashMap<>(); for (int i = 0; i < batchSize; i++) { diff --git a/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java b/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java index 77fbd77..c850b7f 100644 --- a/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java +++ b/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionary.java @@ -20,19 +20,19 @@ public class DatabaseMapDictionary extends DatabaseMapDictionaryDeep valueSerializer; - protected DatabaseMapDictionary(LLDictionary dictionary, byte[] prefixKey, FixedLengthSerializer keySuffixSerializer, Serializer valueSerializer) { + protected DatabaseMapDictionary(LLDictionary dictionary, byte[] prefixKey, SerializerFixedBinaryLength keySuffixSerializer, Serializer valueSerializer) { super(dictionary, new SubStageGetterSingle<>(valueSerializer), keySuffixSerializer, prefixKey, 0); this.valueSerializer = valueSerializer; } public static DatabaseMapDictionary simple(LLDictionary dictionary, - FixedLengthSerializer keySerializer, + SerializerFixedBinaryLength keySerializer, Serializer valueSerializer) { return new DatabaseMapDictionary<>(dictionary, EMPTY_BYTES, keySerializer, valueSerializer); } public static DatabaseMapDictionary tail(LLDictionary dictionary, - FixedLengthSerializer keySuffixSerializer, + SerializerFixedBinaryLength keySuffixSerializer, Serializer valueSerializer, byte[] prefixKey) { return new DatabaseMapDictionary<>(dictionary, prefixKey, keySuffixSerializer, valueSerializer); diff --git a/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionaryDeep.java b/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionaryDeep.java index 84d229c..091c067 100644 --- a/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionaryDeep.java +++ b/src/main/java/it/cavallium/dbengine/database/collections/DatabaseMapDictionaryDeep.java @@ -20,7 +20,7 @@ public class DatabaseMapDictionaryDeep> implem public static final byte[] EMPTY_BYTES = new byte[0]; protected final LLDictionary dictionary; protected final SubStageGetter subStageGetter; - protected final FixedLengthSerializer keySuffixSerializer; + protected final SerializerFixedBinaryLength keySuffixSerializer; protected final byte[] keyPrefix; protected final int keySuffixLength; protected final int keyExtLength; @@ -73,20 +73,20 @@ public class DatabaseMapDictionaryDeep> implem @Deprecated public static DatabaseMapDictionaryDeep> simple(LLDictionary dictionary, SubStageGetterSingle subStageGetter, - FixedLengthSerializer keySerializer) { + SerializerFixedBinaryLength keySerializer) { return new DatabaseMapDictionaryDeep<>(dictionary, subStageGetter, keySerializer, EMPTY_BYTES, 0); } public static > DatabaseMapDictionaryDeep deepTail(LLDictionary dictionary, SubStageGetter subStageGetter, - FixedLengthSerializer keySerializer, + SerializerFixedBinaryLength keySerializer, int keyExtLength) { return new DatabaseMapDictionaryDeep<>(dictionary, subStageGetter, keySerializer, EMPTY_BYTES, keyExtLength); } public static > DatabaseMapDictionaryDeep deepIntermediate(LLDictionary dictionary, SubStageGetter subStageGetter, - FixedLengthSerializer keySuffixSerializer, + SerializerFixedBinaryLength keySuffixSerializer, byte[] prefixKey, int keyExtLength) { return new DatabaseMapDictionaryDeep<>(dictionary, subStageGetter, keySuffixSerializer, prefixKey, keyExtLength); @@ -94,14 +94,14 @@ public class DatabaseMapDictionaryDeep> implem protected DatabaseMapDictionaryDeep(LLDictionary dictionary, SubStageGetter subStageGetter, - FixedLengthSerializer keySuffixSerializer, + SerializerFixedBinaryLength keySuffixSerializer, byte[] prefixKey, int keyExtLength) { this.dictionary = dictionary; this.subStageGetter = subStageGetter; this.keySuffixSerializer = keySuffixSerializer; this.keyPrefix = prefixKey; - this.keySuffixLength = keySuffixSerializer.getLength(); + this.keySuffixLength = keySuffixSerializer.getSerializedBinaryLength(); this.keyExtLength = keyExtLength; byte[] firstKey = firstKey(keyPrefix, keyPrefix.length, keySuffixLength, keyExtLength); byte[] lastKey = lastKey(keyPrefix, keyPrefix.length, keySuffixLength, keyExtLength); diff --git a/src/main/java/it/cavallium/dbengine/database/collections/FixedLengthSerializer.java b/src/main/java/it/cavallium/dbengine/database/collections/SerializerFixedBinaryLength.java similarity index 59% rename from src/main/java/it/cavallium/dbengine/database/collections/FixedLengthSerializer.java rename to src/main/java/it/cavallium/dbengine/database/collections/SerializerFixedBinaryLength.java index c53dcb3..5d6b60b 100644 --- a/src/main/java/it/cavallium/dbengine/database/collections/FixedLengthSerializer.java +++ b/src/main/java/it/cavallium/dbengine/database/collections/SerializerFixedBinaryLength.java @@ -2,12 +2,12 @@ package it.cavallium.dbengine.database.collections; import io.netty.buffer.ByteBuf; -public interface FixedLengthSerializer extends Serializer { +public interface SerializerFixedBinaryLength extends Serializer { - int getLength(); + int getSerializedBinaryLength(); - static FixedLengthSerializer noop(int length) { - return new FixedLengthSerializer<>() { + static SerializerFixedBinaryLength noop(int length) { + return new SerializerFixedBinaryLength<>() { @Override public ByteBuf deserialize(ByteBuf serialized) { return serialized.readSlice(length); @@ -19,7 +19,7 @@ public interface FixedLengthSerializer extends Serializer { } @Override - public int getLength() { + public int getSerializedBinaryLength() { return length; } }; diff --git a/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMap.java b/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMap.java index a8406ec..55c6ce3 100644 --- a/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMap.java +++ b/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMap.java @@ -9,10 +9,10 @@ import reactor.core.publisher.Mono; public class SubStageGetterMap implements SubStageGetter, DatabaseStageEntry>> { - private final FixedLengthSerializer keySerializer; + private final SerializerFixedBinaryLength keySerializer; private final Serializer valueSerializer; - public SubStageGetterMap(FixedLengthSerializer keySerializer, Serializer valueSerializer) { + public SubStageGetterMap(SerializerFixedBinaryLength keySerializer, Serializer valueSerializer) { this.keySerializer = keySerializer; this.valueSerializer = valueSerializer; } diff --git a/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMapDeep.java b/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMapDeep.java index 6a76c5f..d5c28e5 100644 --- a/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMapDeep.java +++ b/src/main/java/it/cavallium/dbengine/database/collections/SubStageGetterMapDeep.java @@ -11,11 +11,11 @@ public class SubStageGetterMapDeep> implements SubStageGetter, DatabaseStageEntry>> { private final SubStageGetter subStageGetter; - private final FixedLengthSerializer keySerializer; + private final SerializerFixedBinaryLength keySerializer; private final int keyExtLength; public SubStageGetterMapDeep(SubStageGetter subStageGetter, - FixedLengthSerializer keySerializer, + SerializerFixedBinaryLength keySerializer, int keyExtLength) { this.subStageGetter = subStageGetter; this.keySerializer = keySerializer;