use of com.yahoo.sketches.hll.HllSketch in project Gaffer by gchq.
the class HllpSketchJsonSerialisationTest method testValidHyperLogLogPlusSketchSerialisedCorrectly.
@Test
public void testValidHyperLogLogPlusSketchSerialisedCorrectly() throws IOException {
// Given
final String testString = "TestString";
final HllSketch sketch = new HllSketch(10);
sketch.update(testString);
// When / Then
runTestWithSketch(sketch);
}
use of com.yahoo.sketches.hll.HllSketch in project Gaffer by gchq.
the class HllpSketchJsonSerialisationTest method testEmptyHyperLogLogPlusSketchIsSerialised.
@Test
public void testEmptyHyperLogLogPlusSketchIsSerialised() throws IOException {
// Given
final HllSketch sketch = new HllSketch(10);
// When / Then
runTestWithSketch(sketch);
}
use of com.yahoo.sketches.hll.HllSketch in project Gaffer by gchq.
the class IterableToHllSketchTest method shouldCreateHllSketch.
@Test
public void shouldCreateHllSketch() {
// Given
IterableToHllSketch iterableToHllSketch = new IterableToHllSketch();
List<Object> input = Arrays.asList("one", "two", "three", "four", "five");
// When
HllSketch result = iterableToHllSketch.apply(input);
// Then
assertThat(result.getEstimate()).isCloseTo(5, Percentage.withPercentage(0.001));
}
use of com.yahoo.sketches.hll.HllSketch in project Gaffer by gchq.
the class IterableToHllSketchTest method shouldCreateHllSketchCardinality.
@Test
public void shouldCreateHllSketchCardinality() {
// Given
IterableToHllSketch iterableToHllSketch = new IterableToHllSketch();
List<Object> input = Arrays.asList("one", "one", "two", "two", "three");
// When
HllSketch result = iterableToHllSketch.apply(input);
// Then
assertThat(result.getEstimate()).isCloseTo(3, Percentage.withPercentage(0.001));
}
use of com.yahoo.sketches.hll.HllSketch in project Gaffer by gchq.
the class HllSketchIsLessThanTest method setup.
@BeforeAll
public static void setup() {
hllSketchWithCardinality5 = new HllSketch(10);
for (int i = 1; i <= 5; i++) {
hllSketchWithCardinality5.update(i);
}
assertEquals(5d, hllSketchWithCardinality5.getEstimate(), DELTA);
hllSketchWithCardinality18 = new HllSketch(10);
for (int i = 1; i <= 18; i++) {
hllSketchWithCardinality18.update(i);
}
assertEquals(18d, hllSketchWithCardinality18.getEstimate(), DELTA);
hllSketchWithCardinality32 = new HllSketch(10);
for (int i = 1; i <= 32; i++) {
hllSketchWithCardinality32.update(i);
}
assertEquals(32d, hllSketchWithCardinality32.getEstimate(), DELTA);
}
Aggregations