yahoo / Oak

A Scalable Concurrent Key-Value Map for Big Data Analytics
Apache License 2.0
268 stars 48 forks source link

Add more common serializers #138

Open sanastas opened 3 years ago

sanastas commented 3 years ago

Oak requests its users to provide serializers for their objects representing keys and values.

Oak has internal common package including sub-packages for common serializers for common objects: IntBuffer, Integer and String. It would be good to have more of such. What kind of objects? It is up to implementer decision.

@liran-funaro can you please add more details to this issue?

For more explanations feel free to add questions in this issue.

nnrepos commented 3 years ago

how would a FloatSerializer be different from an IntSerializer? wouldn't this suffice:

public class OakFloatSerializer implements OakSerializer<Float> {

    private final int size;

    public OakFloatSerializer() {
        this(Float.BYTES);
    }

    public OakFloatSerializer(int size) {
        this.size = size;
    }

    @Override
    public void serialize(Float value, OakScopedWriteBuffer targetBuffer) {
        targetBuffer.putFloat(0, value);
    }
liran-funaro commented 3 years ago

Yes. That is exactly what we expect. It would also help if a simple test would be added that validates that this serializer works correctly with OakMap.