use of com.yahoo.sketches.quantiles.DoublesUnion in project Gaffer by gchq.
the class DoublesUnionAggregatorTest method testCloneOfBusySketch.
@Test
public void testCloneOfBusySketch() {
final DoublesUnionAggregator unionAggregator = new DoublesUnionAggregator();
unionAggregator.init();
for (int i = 0; i < 100; i++) {
final DoublesUnion union = DoublesUnion.builder().build();
for (int j = 0; j < 100; j++) {
union.update(Math.random());
}
unionAggregator._aggregate(union);
}
final DoublesUnionAggregator clone = unionAggregator.statelessClone();
assertNotSame(unionAggregator, clone);
clone._aggregate(union1);
assertEquals(union1.getResult().getQuantile(0.5D), ((DoublesUnion) clone.state()[0]).getResult().getQuantile(0.5D), DELTA);
}
use of com.yahoo.sketches.quantiles.DoublesUnion in project Gaffer by gchq.
the class DoublesUnionSerialiserTest method testSerialiser.
private void testSerialiser(final DoublesUnion union) {
final double quantile1 = union.getResult().getQuantile(0.5D);
final byte[] unionSerialised;
try {
unionSerialised = SERIALISER.serialise(union);
} catch (final SerialisationException exception) {
fail("A SerialisationException occurred");
return;
}
final DoublesUnion unionDeserialised;
try {
unionDeserialised = SERIALISER.deserialise(unionSerialised);
} catch (final SerialisationException exception) {
fail("A SerialisationException occurred");
return;
}
assertEquals(quantile1, unionDeserialised.getResult().getQuantile(0.5D), DELTA);
}
Aggregations