public static HyperLogLog build(DataInput serializedByteStream) throws IOException { int log2m = serializedByteStream.readInt(); int byteArraySize = serializedByteStream.readInt(); return new HyperLogLog(log2m, new RegisterSet(1 << log2m, Bits.getBits(serializedByteStream, byteArraySize))); } }
private static HyperLogLogPlus legacyDecode(DataInput oi) throws IOException { int p = oi.readInt(); int sp = oi.readInt(); int formatType = oi.readInt(); if (formatType == 0) { int size = oi.readInt(); byte[] longArrayBytes = new byte[size]; oi.readFully(longArrayBytes); RegisterSet registerSetFromBytes = new RegisterSet(1 << p, Bits.getBits(longArrayBytes)); HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, registerSetFromBytes); hyperLogLogPlus.format = Format.NORMAL; return hyperLogLogPlus; } else { int l; List<byte[]> deltaByteSet = new ArrayList<byte[]>(); while ((l = oi.readInt()) > 0) { byte[] longArrayBytes = new byte[l]; oi.readFully(longArrayBytes, 0, l); deltaByteSet.add(longArrayBytes); } HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, deltaByteSet); hyperLogLogPlus.format = Format.SPARSE; return hyperLogLogPlus; } }
private static HyperLogLogPlus decodeBytes(DataInput oi) throws IOException { int p = Varint.readUnsignedVarInt(oi); int sp = Varint.readUnsignedVarInt(oi); int formatType = Varint.readUnsignedVarInt(oi); if (formatType == 0) { int size = Varint.readUnsignedVarInt(oi); byte[] longArrayBytes = new byte[size]; oi.readFully(longArrayBytes); HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, new RegisterSet(1 << p, Bits.getBits(longArrayBytes))); hyperLogLogPlus.format = Format.NORMAL; return hyperLogLogPlus; } else { int[] rehydratedSparseSet = new int[Varint.readUnsignedVarInt(oi)]; int prevDeltaRead = 0; for (int i = 0; i < rehydratedSparseSet.length; i++) { int nextVal = Varint.readUnsignedVarInt(oi) + prevDeltaRead; rehydratedSparseSet[i] = nextVal; prevDeltaRead = nextVal; } HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, rehydratedSparseSet); hyperLogLogPlus.format = Format.SPARSE; return hyperLogLogPlus; } } }
public static HyperLogLog build(DataInput serializedByteStream) throws IOException { int log2m = serializedByteStream.readInt(); int byteArraySize = serializedByteStream.readInt(); return new HyperLogLog(log2m, new RegisterSet(1 << log2m, com.clearspring.analytics.util.Bits.getBits(serializedByteStream, byteArraySize))); } }
public static HyperLogLog build(DataInput serializedByteStream) throws IOException { int log2m = serializedByteStream.readInt(); int byteArraySize = serializedByteStream.readInt(); return new HyperLogLog(log2m, new RegisterSet(1 << log2m, Bits.getBits(serializedByteStream, byteArraySize))); } }
private static HyperLogLogPlus legacyDecode(DataInput oi) throws IOException { int p = oi.readInt(); int sp = oi.readInt(); int formatType = oi.readInt(); if (formatType == 0) { int size = oi.readInt(); byte[] longArrayBytes = new byte[size]; oi.readFully(longArrayBytes); RegisterSet registerSetFromBytes = new RegisterSet((int) Math.pow(2, p), Bits.getBits(longArrayBytes)); HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, registerSetFromBytes); hyperLogLogPlus.format = Format.NORMAL; return hyperLogLogPlus; } else { int l; List<byte[]> deltaByteSet = new ArrayList<byte[]>(); while ((l = oi.readInt()) > 0) { byte[] longArrayBytes = new byte[l]; oi.readFully(longArrayBytes, 0, l); deltaByteSet.add(longArrayBytes); } HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, deltaByteSet); hyperLogLogPlus.format = Format.SPARSE; return hyperLogLogPlus; } }
private static HyperLogLogPlus legacyDecode(DataInput oi) throws IOException { int p = oi.readInt(); int sp = oi.readInt(); int formatType = oi.readInt(); if (formatType == 0) { int size = oi.readInt(); byte[] longArrayBytes = new byte[size]; oi.readFully(longArrayBytes); RegisterSet registerSetFromBytes = new RegisterSet(1 << p, com.clearspring.analytics.util.Bits.getBits(longArrayBytes)); HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, registerSetFromBytes); hyperLogLogPlus.format = Format.NORMAL; return hyperLogLogPlus; } else { int l; List<byte[]> deltaByteSet = new ArrayList<byte[]>(); while ((l = oi.readInt()) > 0) { byte[] longArrayBytes = new byte[l]; oi.readFully(longArrayBytes, 0, l); deltaByteSet.add(longArrayBytes); } HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, deltaByteSet); hyperLogLogPlus.format = Format.SPARSE; return hyperLogLogPlus; } }
private static HyperLogLogPlus decodeBytes(DataInput oi) throws IOException { int p = Varint.readUnsignedVarInt(oi); int sp = Varint.readUnsignedVarInt(oi); int formatType = Varint.readUnsignedVarInt(oi); if (formatType == 0) { int size = Varint.readUnsignedVarInt(oi); byte[] longArrayBytes = new byte[size]; oi.readFully(longArrayBytes); HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, new RegisterSet((int) Math.pow(2, p), Bits.getBits(longArrayBytes))); hyperLogLogPlus.format = Format.NORMAL; return hyperLogLogPlus; } else { int[] rehydratedSparseSet = new int[Varint.readUnsignedVarInt(oi)]; int prevDeltaRead = 0; for (int i = 0; i < rehydratedSparseSet.length; i++) { int nextVal = Varint.readUnsignedVarInt(oi) + prevDeltaRead; rehydratedSparseSet[i] = nextVal; prevDeltaRead = nextVal; } HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, rehydratedSparseSet); hyperLogLogPlus.format = Format.SPARSE; return hyperLogLogPlus; } } }
private static HyperLogLogPlus decodeBytes(DataInput oi) throws IOException { int p = Varint.readUnsignedVarInt(oi); int sp = Varint.readUnsignedVarInt(oi); int formatType = Varint.readUnsignedVarInt(oi); if (formatType == 0) { int size = Varint.readUnsignedVarInt(oi); byte[] longArrayBytes = new byte[size]; oi.readFully(longArrayBytes); HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, new RegisterSet(1 << p, com.clearspring.analytics.util.Bits.getBits(longArrayBytes))); hyperLogLogPlus.format = Format.NORMAL; return hyperLogLogPlus; } else { int[] rehydratedSparseSet = new int[Varint.readUnsignedVarInt(oi)]; int prevDeltaRead = 0; for (int i = 0; i < rehydratedSparseSet.length; i++) { int nextVal = Varint.readUnsignedVarInt(oi) + prevDeltaRead; rehydratedSparseSet[i] = nextVal; prevDeltaRead = nextVal; } HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, sp, rehydratedSparseSet); hyperLogLogPlus.format = Format.SPARSE; return hyperLogLogPlus; } } }