use of com.yahoo.bullet.record.BulletRecord 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.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testQueryDone.
@Test
public void testQueryDone() {
bolt = ComponentUtils.prepare(new DonableFilterBolt(), collector);
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeFieldFilterQuery("b235gf23b"), METADATA);
bolt.execute(query);
BulletRecord nonMatching = RecordBox.get().add("field", "foo").getRecord();
Tuple notMatching = makeRecordTuple(nonMatching);
bolt.execute(notMatching);
Tuple tick = TupleUtils.makeTuple(TupleClassifier.Type.TICK_TUPLE);
bolt.execute(tick);
bolt.execute(tick);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
Tuple expected = makeDataTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertFalse(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, expected));
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testNoConsumptionAfterDone.
@Test
public void testNoConsumptionAfterDone() {
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 5, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 3, expected));
collector = new CustomCollector();
// Will be done after 2 consumes (no ticks)
bolt = ComponentUtils.prepare(new DonableFilterBolt(2, 1, new BulletStormConfig()), collector);
bolt.execute(query);
bolt.execute(matching);
bolt.execute(matching);
// Now the query should be done, so it should not consume
bolt.execute(matching);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testBadJson.
@Test
public void testBadJson() {
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "'filters' : [], ", METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
Tuple expected = makeDataTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(collector.wasAcked(query));
Assert.assertTrue(collector.wasAcked(matching));
Assert.assertFalse(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, expected));
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testFilteringSlidingWindow.
@Test
public void testFilteringSlidingWindow() {
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 5, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 4, expected));
}
Aggregations