All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.oak.common.integer.OakIntSerializer Maven / Gradle / Ivy

There is a newer version: 0.2.5
Show newest version
/*
 * Copyright 2020, Verizon Media.
 * Licensed under the terms of the Apache 2.0 license.
 * Please see LICENSE file in the project root for terms.
 */

package com.yahoo.oak.common.integer;

import com.yahoo.oak.OakScopedReadBuffer;
import com.yahoo.oak.OakScopedWriteBuffer;
import com.yahoo.oak.OakSerializer;

public class OakIntSerializer implements OakSerializer {

    private final int size;

    public OakIntSerializer() {
        this(Integer.BYTES);
    }

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

    @Override
    public void serialize(Integer value, OakScopedWriteBuffer targetBuffer) {
        targetBuffer.putInt(0, value);
    }

    @Override
    public Integer deserialize(OakScopedReadBuffer serializedValue) {
        return serializedValue.getInt(0);
    }

    @Override
    public int calculateSize(Integer value) {
        return size;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy