Search in sources :

Example 1 with GroupData

use of com.yahoo.bullet.aggregations.grouping.GroupData in project bullet-core by yahoo.

the class TupleSketch method getRecords.

@Override
public List<BulletRecord> getRecords() {
    merge();
    List<BulletRecord> result = new ArrayList<>();
    SketchIterator<GroupDataSummary> iterator = this.result.iterator();
    for (int count = 0; iterator.next() && count < maxSize; count++) {
        GroupData data = iterator.getSummary().getData();
        result.add(data.getAsBulletRecord());
    }
    return result;
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) ArrayList(java.util.ArrayList) GroupDataSummary(com.yahoo.bullet.aggregations.grouping.GroupDataSummary) GroupData(com.yahoo.bullet.aggregations.grouping.GroupData) CachingGroupData(com.yahoo.bullet.aggregations.grouping.CachingGroupData)

Example 2 with GroupData

use of com.yahoo.bullet.aggregations.grouping.GroupData in project bullet-storm by yahoo.

the class FilterBoltTest method testGroupAllCount.

@Test
public void testGroupAllCount() {
    // 15 Records will be consumed
    bolt = ComponentUtils.prepare(new DonableFilterBolt(15, new BulletStormConfig()), collector);
    Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeGroupFilterQuery("timestamp", asList("1", "2"), EQUALS, GROUP, 1, singletonList(new GroupOperation(COUNT, null, "cnt"))), METADATA);
    bolt.execute(query);
    BulletRecord record = RecordBox.get().add("timestamp", "1").getRecord();
    Tuple matching = makeRecordTuple(record);
    IntStream.range(0, 10).forEach(i -> bolt.execute(matching));
    BulletRecord another = RecordBox.get().getRecord();
    Tuple nonMatching = makeRecordTuple(another);
    IntStream.range(0, 5).forEach(i -> bolt.execute(nonMatching));
    bolt.execute(nonMatching);
    // Two to flush bolt
    Tuple tick = TupleUtils.makeTuple(TupleClassifier.Type.TICK_TUPLE);
    bolt.execute(tick);
    bolt.execute(tick);
    Assert.assertEquals(collector.getEmittedCount(), 1);
    GroupData actual = SerializerDeserializer.fromBytes(getRawPayloadOfNthTuple(1));
    BulletRecord expected = RecordBox.get().add("cnt", 10).getRecord();
    Assert.assertTrue(isEqual(actual, expected));
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) TupleUtils.makeTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeTuple) TupleUtils.makeRawTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) GroupOperation(com.yahoo.bullet.aggregations.grouping.GroupOperation) GroupData(com.yahoo.bullet.aggregations.grouping.GroupData) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 3 with GroupData

use of com.yahoo.bullet.aggregations.grouping.GroupData in project bullet-storm by yahoo.

the class JoinBoltTest method getGroupDataWithCount.

private static byte[] getGroupDataWithCount(String countField, int count) {
    GroupData groupData = new GroupData(new HashSet<>(singletonList(new GroupOperation(COUNT, null, countField))));
    IntStream.range(0, count).forEach(i -> groupData.consume(RecordBox.get().getRecord()));
    return SerializerDeserializer.toBytes(groupData);
}
Also used : GroupOperation(com.yahoo.bullet.aggregations.grouping.GroupOperation) GroupData(com.yahoo.bullet.aggregations.grouping.GroupData)

Aggregations

GroupData (com.yahoo.bullet.aggregations.grouping.GroupData)3 GroupOperation (com.yahoo.bullet.aggregations.grouping.GroupOperation)2 BulletRecord (com.yahoo.bullet.record.BulletRecord)2 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)1 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)1 TopKTest (com.yahoo.bullet.aggregations.TopKTest)1 CachingGroupData (com.yahoo.bullet.aggregations.grouping.CachingGroupData)1 GroupDataSummary (com.yahoo.bullet.aggregations.grouping.GroupDataSummary)1 TupleUtils.makeIDTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple)1 TupleUtils.makeRawTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple)1 TupleUtils.makeTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeTuple)1 ArrayList (java.util.ArrayList)1 Tuple (org.apache.storm.tuple.Tuple)1 Test (org.testng.annotations.Test)1