org.mapdb.serializer.SerializerEightByte Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mapdb Show documentation
Show all versions of mapdb Show documentation
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.
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);
}
}