Search in sources :

Example 6 with LongsSketch

use of com.yahoo.sketches.frequencies.LongsSketch in project Gaffer by gchq.

the class LongsSketchAggregatorTest method setup.

@Before
public void setup() {
    sketch1 = new LongsSketch(32);
    sketch1.update(1L);
    sketch1.update(2L);
    sketch1.update(3L);
    sketch2 = new LongsSketch(32);
    sketch2.update(4L);
    sketch2.update(5L);
    sketch2.update(6L);
    sketch2.update(7L);
    sketch2.update(3L);
}
Also used : LongsSketch(com.yahoo.sketches.frequencies.LongsSketch) Before(org.junit.Before)

Example 7 with LongsSketch

use of com.yahoo.sketches.frequencies.LongsSketch in project Gaffer by gchq.

the class LongsSketchAggregatorTest method testAggregate.

@Test
public void testAggregate() {
    final LongsSketchAggregator sketchAggregator = new LongsSketchAggregator();
    sketchAggregator.init();
    sketchAggregator._aggregate(sketch1);
    LongsSketch currentState = sketchAggregator._state();
    assertEquals(1L, currentState.getEstimate(1L));
    sketchAggregator._aggregate(sketch2);
    currentState = sketchAggregator._state();
    assertEquals(1L, currentState.getEstimate(1L));
    assertEquals(2L, currentState.getEstimate(3L));
}
Also used : LongsSketch(com.yahoo.sketches.frequencies.LongsSketch) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 8 with LongsSketch

use of com.yahoo.sketches.frequencies.LongsSketch in project Gaffer by gchq.

the class LongsSketchAggregatorTest method testEquals.

@Test
public void testEquals() {
    final LongsSketch sketch1 = new LongsSketch(32);
    sketch1.update(1L);
    final LongsSketchAggregator sketchAggregator1 = new LongsSketchAggregator();
    sketchAggregator1.aggregate(new LongsSketch[] { sketch1 });
    final LongsSketch sketch2 = new LongsSketch(32);
    sketch2.update(1L);
    final LongsSketchAggregator sketchAggregator2 = new LongsSketchAggregator();
    sketchAggregator2.aggregate(new LongsSketch[] { sketch2 });
    assertEquals(sketchAggregator1, sketchAggregator2);
    sketch2.update(2L);
    sketchAggregator2.aggregate(new LongsSketch[] { sketch2 });
    assertNotEquals(sketchAggregator1, sketchAggregator2);
}
Also used : LongsSketch(com.yahoo.sketches.frequencies.LongsSketch) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Aggregations

LongsSketch (com.yahoo.sketches.frequencies.LongsSketch)8 Test (org.junit.Test)4 AggregateFunctionTest (uk.gov.gchq.gaffer.function.AggregateFunctionTest)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)2 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 Element (uk.gov.gchq.gaffer.data.element.Element)1 DataGenerator10 (uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator10)1 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 GetAllEdges (uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges)1 User (uk.gov.gchq.gaffer.user.User)1