@Test public void testHllMergeDense() throws Exception { byte[] otherBytes = TestUtil.getResourceAsBytes("v5/dense_cached_99562.dat"); HllhdrV5 otherHll = new HllhdrV5(otherBytes); HllhdrV5 thisHll = new HllhdrV5(); assertThat(thisHll.hllCount().count).isEqualTo(0L); thisHll.hllMerge(otherHll); assertThat(thisHll.hllCount().count).isEqualTo(99562L); byte[] newRepr = thisHll.dump(); for (int i = 16; i < newRepr.length; i++) { assertThat(newRepr[i]).isEqualTo(otherBytes[i]); } }
CountResult hllCount() { double m = registerSize(); int[] regHisto = new int[64]; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { denseRegHisto(regHisto); } else if (encoding == HllEncoding.SPARSE.value) { if (!sparseRegHisto(regHisto)) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double z = m * tau((m - regHisto[HLL_Q + 1]) / m); for (int i = HLL_Q; i >= 1; --i) { z += regHisto[i]; z *= 0.5; } z += m * sigma(regHisto[0] / m); double E = Math.round(HLL_ALPHA_INF * m * m / z); return new CountResult((long)E, true); }
HllhdrV5 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); int[] regHisto = new int[64]; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { denseRegHisto(regHisto); } else if (encoding == HllEncoding.SPARSE.value) { if (!sparseRegHisto(regHisto)) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double z = m * tau((m - regHisto[HLL_Q + 1]) / m); for (int i = HLL_Q; i >= 1; --i) { z += regHisto[i]; z *= 0.5; } z += m * sigma(regHisto[0] / m); double E = Math.round(HLL_ALPHA_INF * m * m / z); return new CountResult((long)E, true); } }
HllhdrV5 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); int[] regHisto = new int[64]; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { denseRegHisto(regHisto); } else if (encoding == HllEncoding.SPARSE.value) { if (!sparseRegHisto(regHisto)) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double z = m * tau((m - regHisto[HLL_Q + 1]) / m); for (int i = HLL_Q; i >= 1; --i) { z += regHisto[i]; z *= 0.5; } z += m * sigma(regHisto[0] / m); double E = Math.round(HLL_ALPHA_INF * m * m / z); return new CountResult((long)E, true); } HllhdrV5();   HllhdrV5(byte[] repr); }
HllhdrV5 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); int[] regHisto = new int[64]; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { denseRegHisto(regHisto); } else if (encoding == HllEncoding.SPARSE.value) { if (!sparseRegHisto(regHisto)) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double z = m * tau((m - regHisto[HLL_Q + 1]) / m); for (int i = HLL_Q; i >= 1; --i) { z += regHisto[i]; z *= 0.5; } z += m * sigma(regHisto[0] / m); double E = Math.round(HLL_ALPHA_INF * m * m / z); return new CountResult((long)E, true); } HllhdrV5();   HllhdrV5(byte[] repr);  }
HllhdrV5 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); int[] regHisto = new int[64]; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { denseRegHisto(regHisto); } else if (encoding == HllEncoding.SPARSE.value) { if (!sparseRegHisto(regHisto)) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double z = m * tau((m - regHisto[HLL_Q + 1]) / m); for (int i = HLL_Q; i >= 1; --i) { z += regHisto[i]; z *= 0.5; } z += m * sigma(regHisto[0] / m); double E = Math.round(HLL_ALPHA_INF * m * m / z); return new CountResult((long)E, true); } HllhdrV5();   HllhdrV5(byte[] repr);   }