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

org.mapdb.serializer.SerializerFloat Maven / Gradle / Ivy

Go to download

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap memory. It is a fast, scalable and easy to use embedded Java database.

There is a newer version: 3.1.0
Show newest version
package org.mapdb.serializer;

import org.mapdb.DataInput2;
import org.mapdb.DataOutput2;

import java.io.IOException;
import java.util.Arrays;

/**
 * Created by jan on 2/28/16.
 */
public class SerializerFloat extends SerializerFourByte {

    @Override
    protected Float unpack(int l) {
        return new Float(Float.intBitsToFloat(l));
    }

    @Override
    protected int pack(Float l) {
        return Float.floatToIntBits(l);
    }


    @Override
    public void serialize(DataOutput2 out, Float value) throws IOException {
        out.writeFloat(value);
    }

    @Override
    public Float deserialize(DataInput2 in, int available) throws IOException {
        return new Float(in.readFloat());
    }


    @Override
    public int valueArraySearch(Object keys, Float key) {
        //TODO PERF this can be optimized, but must take care of NaN
        return Arrays.binarySearch(valueArrayToArray(keys), key);
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy