@Test public void requireThatEstimateIsCorrectForSparseSketch() { SparseSketch sketch = new SparseSketch(); HyperLogLogEstimator estimator = new HyperLogLogEstimator(10); long estimate = estimator.estimateCount(sketch); assertEquals(0, estimate); for (int i = 1; i <= HyperLogLog.SPARSE_SKETCH_CONVERSION_THRESHOLD; i++) { sketch.aggregate(i); estimate = estimator.estimateCount(sketch); assertEquals(i, estimate); } }
@Override public long estimateCount(Sketch<?> sketch) { if (sketch instanceof NormalSketch) { return estimateCount((NormalSketch) sketch); } else { return estimateCount((SparseSketch) sketch); } }
HyperLogLogEstimator implements UniqueCountEstimator<Sketch<?>> { @Override public long estimateCount(Sketch<?> sketch) { if (sketch instanceof NormalSketch) { return estimateCount((NormalSketch) sketch); } else { return estimateCount((SparseSketch) sketch); } } }
HyperLogLogEstimator implements UniqueCountEstimator<Sketch<?>> { @Override public long estimateCount(Sketch<?> sketch) { if (sketch instanceof NormalSketch) { return estimateCount((NormalSketch) sketch); } else { return estimateCount((SparseSketch) sketch); } } HyperLogLogEstimator(int precision);  HyperLogLogEstimator(); }
HyperLogLogEstimator implements UniqueCountEstimator<Sketch<?>> { @Override public long estimateCount(Sketch<?> sketch) { if (sketch instanceof NormalSketch) { return estimateCount((NormalSketch) sketch); } else { return estimateCount((SparseSketch) sketch); } } HyperLogLogEstimator(int precision);  HyperLogLogEstimator(); @Override long estimateCount(Sketch<?> sketch); }
HyperLogLogEstimator implements UniqueCountEstimator<Sketch<?>> { @Override public long estimateCount(Sketch<?> sketch) { if (sketch instanceof NormalSketch) { return estimateCount((NormalSketch) sketch); } else { return estimateCount((SparseSketch) sketch); } } HyperLogLogEstimator(int precision);  HyperLogLogEstimator(); @Override long estimateCount(Sketch<?> sketch);  }