@Test public void mergeTest() throws IOException { double error = 0; int n = 100; for (int i = 0; i < n; i += 10) { double e = merge(i); error += e; } System.out.println("Total average error is " + error / n); System.out.println(" errorRateCount1 is " + errorCount1 + "!"); System.out.println(" errorRateCount2 is " + errorCount2 + "!"); System.out.println(" errorRateCount3 is " + errorCount3 + "!"); Assert.assertTrue(errorCount1 <= n * 0.30); Assert.assertTrue(errorCount2 <= n * 0.05); Assert.assertTrue(errorCount3 <= n * 0.02); }
public void merge(HLLCounterOld another) { assert this.p == another.p; assert this.hashFunc == another.hashFunc; if (another.singleBucket == -1) { return; } else if (another.singleBucket >= 0) { int b = another.singleBucket; if (registers[b] < another.registers[b]) registers[b] = another.registers[b]; } else { for (int i = 0; i < m; i++) { if (registers[i] < another.registers[i]) registers[i] = another.registers[i]; } } singleBucket = Integer.MIN_VALUE; }
HLLCounterOld implements Serializable, Comparable<HLLCounterOld> { public void merge(HLLCounterOld another) { assert this.p == another.p; assert this.hashFunc == another.hashFunc; if (another.singleBucket == -1) { return; } else if (another.singleBucket >= 0) { int b = another.singleBucket; if (registers[b] < another.registers[b]) registers[b] = another.registers[b]; } else { for (int i = 0; i < m; i++) { if (registers[i] < another.registers[i]) registers[i] = another.registers[i]; } } singleBucket = Integer.MIN_VALUE; } }
HLLCounterOld implements Serializable, Comparable<HLLCounterOld> { public void merge(HLLCounterOld another) { assert this.p == another.p; assert this.hashFunc == another.hashFunc; if (another.singleBucket == -1) { return; } else if (another.singleBucket >= 0) { int b = another.singleBucket; if (registers[b] < another.registers[b]) registers[b] = another.registers[b]; } else { for (int i = 0; i < m; i++) { if (registers[i] < another.registers[i]) registers[i] = another.registers[i]; } } singleBucket = Integer.MIN_VALUE; } HLLCounterOld();  HLLCounterOld(int p);  HLLCounterOld(HLLCounterOld another); private  HLLCounterOld(int p, HashFunction hashFunc); }
HLLCounterOld implements Serializable, Comparable<HLLCounterOld> { public void merge(HLLCounterOld another) { assert this.p == another.p; assert this.hashFunc == another.hashFunc; if (another.singleBucket == -1) { return; } else if (another.singleBucket >= 0) { int b = another.singleBucket; if (registers[b] < another.registers[b]) registers[b] = another.registers[b]; } else { for (int i = 0; i < m; i++) { if (registers[i] < another.registers[i]) registers[i] = another.registers[i]; } } singleBucket = Integer.MIN_VALUE; } HLLCounterOld();  HLLCounterOld(int p);  HLLCounterOld(HLLCounterOld another); private  HLLCounterOld(int p, HashFunction hashFunc); void clear(); void add(int value); void add(String value); void add(byte[] value); void add(byte[] value, int offset, int length); void merge(HLLCounterOld another); long getCountEstimate(); int getPrecision(); double getErrorRate(); @Override String toString(); void writeRegisters(final ByteBuffer out); void readRegisters(ByteBuffer in); int peekLength(ByteBuffer in); int maxLength(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(HLLCounterOld o); static void main(String[] args); static void writeUnsigned(int num, int size, ByteBuffer out); static int readUnsigned(ByteBuffer in, int size); }
HLLCounterOld implements Serializable, Comparable<HLLCounterOld> { public void merge(HLLCounterOld another) { assert this.p == another.p; assert this.hashFunc == another.hashFunc; if (another.singleBucket == -1) { return; } else if (another.singleBucket >= 0) { int b = another.singleBucket; if (registers[b] < another.registers[b]) registers[b] = another.registers[b]; } else { for (int i = 0; i < m; i++) { if (registers[i] < another.registers[i]) registers[i] = another.registers[i]; } } singleBucket = Integer.MIN_VALUE; } HLLCounterOld();  HLLCounterOld(int p);  HLLCounterOld(HLLCounterOld another); private  HLLCounterOld(int p, HashFunction hashFunc); void clear(); void add(int value); void add(String value); void add(byte[] value); void add(byte[] value, int offset, int length); void merge(HLLCounterOld another); long getCountEstimate(); int getPrecision(); double getErrorRate(); @Override String toString(); void writeRegisters(final ByteBuffer out); void readRegisters(ByteBuffer in); int peekLength(ByteBuffer in); int maxLength(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(HLLCounterOld o); static void main(String[] args); static void writeUnsigned(int num, int size, ByteBuffer out); static int readUnsigned(ByteBuffer in, int size);  }