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

org.mapdb.serializer.SerializerEightByte 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 org.mapdb.Serializer;

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

public abstract class SerializerEightByte implements GroupSerializer {

    protected abstract E unpack(long l);
    protected abstract long pack(E l);

    @Override
    public E valueArrayGet(Object vals, int pos){
        return unpack(((long[]) vals)[pos]);
    }


    @Override
    public int valueArraySize(Object vals){
        return ((long[])vals).length;
    }

    @Override
    public Object valueArrayEmpty(){
        return new long[0];
    }

    @Override
    public Object valueArrayPut(Object vals, int pos, E newValue) {

        long[] array = (long[]) vals;
        final long[] ret = Arrays.copyOf(array, array.length+1);
        if(pos>> 1;
            int compare = comparator.compare(key, unpack(array[mid]));

            if (compare == 0)
                return mid;
            else if (compare < 0)
                hi = mid - 1;
            else
                lo = mid + 1;
        }
        return -(lo + 1);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy