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;
}
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));
}
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);
}
Aggregations