Search in sources :

Example 1 with Long2ShortRBTreeMap

use of it.unimi.dsi.fastutil.longs.Long2ShortRBTreeMap in project presto by prestodb.

the class SetDigest method newInstance.

public static SetDigest newInstance(Slice serialized) {
    requireNonNull(serialized, "serialized is null");
    SliceInput input = serialized.getInput();
    checkArgument(input.readByte() == UNCOMPRESSED_FORMAT, "Unexpected version");
    int hllLength = input.readInt();
    Slice serializedHll = Slices.allocate(hllLength);
    input.readBytes(serializedHll, hllLength);
    HyperLogLog hll = HyperLogLog.newInstance(serializedHll);
    Long2ShortRBTreeMap minhash = new Long2ShortRBTreeMap();
    int maxHashes = input.readInt();
    int minhashLength = input.readInt();
    // The values are stored after the keys
    SliceInput valuesInput = serialized.getInput();
    valuesInput.setPosition(input.position() + minhashLength * SIZE_OF_LONG);
    for (int i = 0; i < minhashLength; i++) {
        minhash.put(input.readLong(), valuesInput.readShort());
    }
    return new SetDigest(maxHashes, hll, minhash);
}
Also used : Slice(io.airlift.slice.Slice) Long2ShortRBTreeMap(it.unimi.dsi.fastutil.longs.Long2ShortRBTreeMap) SliceInput(io.airlift.slice.SliceInput) HyperLogLog(com.facebook.airlift.stats.cardinality.HyperLogLog)

Aggregations

HyperLogLog (com.facebook.airlift.stats.cardinality.HyperLogLog)1 Slice (io.airlift.slice.Slice)1 SliceInput (io.airlift.slice.SliceInput)1 Long2ShortRBTreeMap (it.unimi.dsi.fastutil.longs.Long2ShortRBTreeMap)1