Search in sources :

Example 36 with HyperLogLogPlus

use of com.clearspring.analytics.stream.cardinality.HyperLogLogPlus in project Gaffer by gchq.

the class HyperLogLogPlusJsonSerialisationTest method testNullHyperLogLogPlusSketchIsSerialisedAsNullString.

@Test
public void testNullHyperLogLogPlusSketchIsSerialisedAsNullString() throws JsonProcessingException {
    // Given
    final HyperLogLogPlus sketch = null;
    // When
    final String sketchAsString = mapper.writeValueAsString(sketch);
    // Then - Serialisation framework will serialise nulls as 'null' string.
    assertEquals("null", sketchAsString);
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) Test(org.junit.Test)

Example 37 with HyperLogLogPlus

use of com.clearspring.analytics.stream.cardinality.HyperLogLogPlus in project Gaffer by gchq.

the class HyperLogLogPlusAggregatorTest method shouldBeNotEqualWhenSecondAggregatorsHasNullHllp.

@Test
public void shouldBeNotEqualWhenSecondAggregatorsHasNullHllp() throws IOException {
    // Given
    final HyperLogLogPlusAggregator aggregator1 = new HyperLogLogPlusAggregator();
    final HyperLogLogPlusAggregator aggregator2 = new HyperLogLogPlusAggregator();
    final HyperLogLogPlus hllp1 = new HyperLogLogPlus(5, 5);
    hllp1.offer("A");
    hllp1.offer("B");
    aggregator1._aggregate(hllp1);
    // Then
    assertNotEquals(aggregator1, aggregator2);
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 38 with HyperLogLogPlus

use of com.clearspring.analytics.stream.cardinality.HyperLogLogPlus in project Gaffer by gchq.

the class HyperLogLogPlusAggregatorTest method shouldBeNotEqualWhenFirstAggregatorsHasNullHllp.

@Test
public void shouldBeNotEqualWhenFirstAggregatorsHasNullHllp() throws IOException {
    // Given
    final HyperLogLogPlusAggregator aggregator1 = new HyperLogLogPlusAggregator();
    final HyperLogLogPlusAggregator aggregator2 = new HyperLogLogPlusAggregator();
    final HyperLogLogPlus hllp2 = new HyperLogLogPlus(5, 5);
    hllp2.offer("A");
    hllp2.offer("C");
    aggregator2._aggregate(hllp2);
    // Then
    assertNotEquals(aggregator1, aggregator2);
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 39 with HyperLogLogPlus

use of com.clearspring.analytics.stream.cardinality.HyperLogLogPlus in project Gaffer by gchq.

the class HyperLogLogPlusAggregatorTest method setupHllp.

private void setupHllp(final int p, final int sp) {
    hyperLogLogPlus1 = new HyperLogLogPlus(p, sp);
    hyperLogLogPlus1.offer("A");
    hyperLogLogPlus1.offer("B");
    hyperLogLogPlus2 = new HyperLogLogPlus(p, sp);
    hyperLogLogPlus2.offer("C");
    hyperLogLogPlus2.offer("D");
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)

Example 40 with HyperLogLogPlus

use of com.clearspring.analytics.stream.cardinality.HyperLogLogPlus in project Gaffer by gchq.

the class HyperLogLogPlusAggregatorTest method shouldBeNotEqualWhenBothAggregatorsHaveSketchesWithDifferentPAndSpValues.

@Test
public void shouldBeNotEqualWhenBothAggregatorsHaveSketchesWithDifferentPAndSpValues() throws IOException {
    // Given
    final HyperLogLogPlusAggregator aggregator1 = new HyperLogLogPlusAggregator();
    final HyperLogLogPlusAggregator aggregator2 = new HyperLogLogPlusAggregator();
    final HyperLogLogPlus hllp1 = new HyperLogLogPlus(5, 5);
    hllp1.offer("A");
    hllp1.offer("B");
    final HyperLogLogPlus hllp2 = new HyperLogLogPlus(6, 6);
    hllp2.offer("A");
    hllp2.offer("B");
    aggregator1._aggregate(hllp1);
    aggregator2._aggregate(hllp2);
    // Then
    assertNotEquals(aggregator1, aggregator2);
}
Also used : HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Aggregations

HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)58 Test (org.junit.jupiter.api.Test)19 Test (org.junit.Test)14 Entity (uk.gov.gchq.gaffer.data.element.Entity)8 AggregateFunctionTest (uk.gov.gchq.gaffer.function.AggregateFunctionTest)6 User (uk.gov.gchq.gaffer.user.User)6 Edge (uk.gov.gchq.gaffer.data.element.Edge)5 Element (uk.gov.gchq.gaffer.data.element.Element)5 Graph (uk.gov.gchq.gaffer.graph.Graph)5 FunctionTest (uk.gov.gchq.koryphe.function.FunctionTest)5 ArrayList (java.util.ArrayList)4 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)4 HashSet (java.util.HashSet)3 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)3 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)3 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)3 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)3 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)3 CardinalityMergeException (com.clearspring.analytics.stream.cardinality.CardinalityMergeException)2 TreeNode (com.fasterxml.jackson.core.TreeNode)2