Optimizations
This commit is contained in:
parent
7c67676a25
commit
14e00a1857
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
||||
<lucene.version>9.5.0</lucene.version>
|
||||
<rocksdb.version>8.0.0</rocksdb.version>
|
||||
<junit.jupiter.version>5.9.0</junit.jupiter.version>
|
||||
<data.generator.version>1.0.7</data.generator.version>
|
||||
<data.generator.version>1.0.9</data.generator.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -5,6 +5,7 @@ import it.cavallium.buffer.BufDataInput;
|
||||
import it.cavallium.buffer.BufDataOutput;
|
||||
import it.cavallium.dbengine.database.serialization.SerializationException;
|
||||
import it.cavallium.dbengine.database.serialization.Serializer;
|
||||
import it.cavallium.dbengine.database.serialization.SerializerFixedBinaryLength;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MappedSerializer<A, B> implements Serializer<B> {
|
||||
@ -18,6 +19,16 @@ public class MappedSerializer<A, B> implements Serializer<B> {
|
||||
this.keyMapper = keyMapper;
|
||||
}
|
||||
|
||||
public static <A, B> Serializer<B> of(Serializer<A> ser,
|
||||
Mapper<A, B> keyMapper) {
|
||||
if (keyMapper.getClass() == NoMapper.class) {
|
||||
//noinspection unchecked
|
||||
return (Serializer<B>) ser;
|
||||
} else {
|
||||
return new MappedSerializer<>(ser, keyMapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull B deserialize(@NotNull BufDataInput in) throws SerializationException {
|
||||
return keyMapper.map(serializer.deserialize(in));
|
||||
|
@ -18,6 +18,16 @@ public class MappedSerializerFixedLength<A, B> implements SerializerFixedBinaryL
|
||||
this.keyMapper = keyMapper;
|
||||
}
|
||||
|
||||
public static <A, B> SerializerFixedBinaryLength<B> of(SerializerFixedBinaryLength<A> fixedLengthSerializer,
|
||||
Mapper<A, B> keyMapper) {
|
||||
if (keyMapper.getClass() == NoMapper.class) {
|
||||
//noinspection unchecked
|
||||
return (SerializerFixedBinaryLength<B>) fixedLengthSerializer;
|
||||
} else {
|
||||
return new MappedSerializerFixedLength<>(fixedLengthSerializer, keyMapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull B deserialize(@NotNull BufDataInput in) throws SerializationException {
|
||||
return keyMapper.map(fixedLengthSerializer.deserialize(in));
|
||||
|
Loading…
x
Reference in New Issue
Block a user