@Test public void testDenseHllCount() throws Exception { HllhdrV4 hllhdr = new HllhdrV4(TestUtil.getResourceAsBytes("v4/dense_cached_55527.dat")); HllhdrV4.CountResult result = hllhdr.hllCount(); assertThat(result.valid).isTrue(); assertThat(result.count).isEqualTo(55527L); }
CountResult hllCount() { double m = registerSize(); double alpha = 0.7213 / (1 + 1.079 / m); SumResult sum; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { sum = denseSum(); } else if (encoding == HllEncoding.SPARSE.value) { sum = sparseSum(); if (!sum.valid) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double ez = sum.ez; double zl = Math.log(ez + 1); double beta = -0.370393911 * ez + 0.070471823 * zl + 0.17393686 * Math.pow(zl, 2) + 0.16339839 * Math.pow(zl, 3) + -0.09237745 * Math.pow(zl, 4) + 0.03738027 * Math.pow(zl, 5) + -0.005384159 * Math.pow(zl, 6) + 0.00042419 * Math.pow(zl, 7); double result = Math.round(alpha * m * (m - ez) * (1 / (sum.E + beta))); return new CountResult((long)result, true); }
HllhdrV4 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); double alpha = 0.7213 / (1 + 1.079 / m); SumResult sum; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { sum = denseSum(); } else if (encoding == HllEncoding.SPARSE.value) { sum = sparseSum(); if (!sum.valid) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double ez = sum.ez; double zl = Math.log(ez + 1); double beta = -0.370393911 * ez + 0.070471823 * zl + 0.17393686 * Math.pow(zl, 2) + 0.16339839 * Math.pow(zl, 3) + -0.09237745 * Math.pow(zl, 4) + 0.03738027 * Math.pow(zl, 5) + -0.005384159 * Math.pow(zl, 6) + 0.00042419 * Math.pow(zl, 7); double result = Math.round(alpha * m * (m - ez) * (1 / (sum.E + beta))); return new CountResult((long)result, true); } }
HllhdrV4 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); double alpha = 0.7213 / (1 + 1.079 / m); SumResult sum; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { sum = denseSum(); } else if (encoding == HllEncoding.SPARSE.value) { sum = sparseSum(); if (!sum.valid) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double ez = sum.ez; double zl = Math.log(ez + 1); double beta = -0.370393911 * ez + 0.070471823 * zl + 0.17393686 * Math.pow(zl, 2) + 0.16339839 * Math.pow(zl, 3) + -0.09237745 * Math.pow(zl, 4) + 0.03738027 * Math.pow(zl, 5) + -0.005384159 * Math.pow(zl, 6) + 0.00042419 * Math.pow(zl, 7); double result = Math.round(alpha * m * (m - ez) * (1 / (sum.E + beta))); return new CountResult((long)result, true); } HllhdrV4();   HllhdrV4(byte[] repr); }
HllhdrV4 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); double alpha = 0.7213 / (1 + 1.079 / m); SumResult sum; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { sum = denseSum(); } else if (encoding == HllEncoding.SPARSE.value) { sum = sparseSum(); if (!sum.valid) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double ez = sum.ez; double zl = Math.log(ez + 1); double beta = -0.370393911 * ez + 0.070471823 * zl + 0.17393686 * Math.pow(zl, 2) + 0.16339839 * Math.pow(zl, 3) + -0.09237745 * Math.pow(zl, 4) + 0.03738027 * Math.pow(zl, 5) + -0.005384159 * Math.pow(zl, 6) + 0.00042419 * Math.pow(zl, 7); double result = Math.round(alpha * m * (m - ez) * (1 / (sum.E + beta))); return new CountResult((long)result, true); } HllhdrV4();   HllhdrV4(byte[] repr);  }
HllhdrV4 extends HllByteBuffer { CountResult hllCount() { double m = registerSize(); double alpha = 0.7213 / (1 + 1.079 / m); SumResult sum; byte encoding = buffer[magic().length]; if (encoding == HllEncoding.DENSE.value) { sum = denseSum(); } else if (encoding == HllEncoding.SPARSE.value) { sum = sparseSum(); if (!sum.valid) { return new CountResult(0, false); } } else { throw new IllegalStateException("invalid encoding : " + encoding); } double ez = sum.ez; double zl = Math.log(ez + 1); double beta = -0.370393911 * ez + 0.070471823 * zl + 0.17393686 * Math.pow(zl, 2) + 0.16339839 * Math.pow(zl, 3) + -0.09237745 * Math.pow(zl, 4) + 0.03738027 * Math.pow(zl, 5) + -0.005384159 * Math.pow(zl, 6) + 0.00042419 * Math.pow(zl, 7); double result = Math.round(alpha * m * (m - ez) * (1 / (sum.E + beta))); return new CountResult((long)result, true); } HllhdrV4();   HllhdrV4(byte[] repr);   }