use of it.unimi.dsi.fastutil.longs.Long2ObjectRBTreeMap in project presto by prestodb.
the class KHyperLogLog method newInstance.
public static KHyperLogLog newInstance(Slice serialized) {
requireNonNull(serialized, "serialized is null");
SliceInput input = serialized.getInput();
checkArgument(input.readByte() == VERSION_BYTE, "Unexpected version");
Long2ObjectRBTreeMap<HyperLogLog> minhash = new Long2ObjectRBTreeMap<>();
int maxSize = input.readInt();
int hllBuckets = input.readInt();
int minhashSize = input.readInt();
int totalHllSize = input.readInt();
int[] hllSizes = new int[minhashSize];
long[] keys = new long[minhashSize];
input.readBytes(wrappedIntArray(hllSizes));
input.readBytes(wrappedLongArray(keys));
Slice allSerializedHlls = input.readSlice(totalHllSize);
int hllLength;
int index = 0;
for (int i = 0; i < minhashSize; i++) {
Slice serializedHll;
hllLength = hllSizes[i];
serializedHll = allSerializedHlls.slice(index, hllLength);
index += hllLength;
minhash.put(keys[i], HyperLogLog.newInstance(serializedHll));
}
return new KHyperLogLog(maxSize, hllBuckets, minhash);
}
Aggregations