Oak icon indicating copy to clipboard operation
Oak copied to clipboard

Add more common serializers

Open sanastas opened this issue 4 years ago • 2 comments

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.

sanastas avatar Mar 01 '21 08:03 sanastas

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);
    }

nnrepos avatar Mar 15 '21 08:03 nnrepos

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.

liran-funaro avatar Mar 15 '21 08:03 liran-funaro