Search in sources :

Example 81 with BulletRecord

use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.

the class FilterBoltTest method testRateLimiting.

@Test
public void testRateLimiting() {
    config = new BulletStormConfig();
    RateLimitError rateLimitError = new RateLimitError(42.0, config);
    bolt = new RateLimitedFilterBolt(2, rateLimitError, config);
    bolt = ComponentUtils.prepare(new HashMap<>(), bolt, collector);
    Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 100, 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);
    Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
    Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
    bolt.execute(matching);
    Tuple error = TupleUtils.makeIDTuple(TupleClassifier.Type.ERROR_TUPLE, "42", rateLimitError);
    Assert.assertTrue(collector.wasNthEmitted(error, 3));
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) HashMap(java.util.HashMap) RateLimitError(com.yahoo.bullet.querying.RateLimitError) 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) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 82 with BulletRecord

use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.

the class FilterBoltTest method testMissingRateLimit.

@Test
public void testMissingRateLimit() {
    config = new BulletStormConfig();
    bolt = new RateLimitedFilterBolt(2, null, config);
    bolt = ComponentUtils.prepare(new HashMap<>(), bolt, collector);
    Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 100, 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);
    Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
    Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
    Assert.assertEquals(collector.getEmittedCount(), 2);
    bolt.execute(matching);
    Assert.assertEquals(collector.getEmittedCount(), 2);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) HashMap(java.util.HashMap) 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) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 83 with BulletRecord

use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.

the class FilterBoltTest method testFilteringUsingProjectedName.

@Test
public void testFilteringUsingProjectedName() {
    Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeProjectionFilterQuery("mid", singletonList("123"), EQUALS, Pair.of("field", "id"), Pair.of("map_field.id", "mid")), METADATA);
    bolt.execute(query);
    BulletRecord record = RecordBox.get().add("field", "b235gf23b").add("timestamp", 92L).addMap("map_field", Pair.of("id", "123"), Pair.of("bar", "foo")).getRecord();
    Tuple matching = makeRecordTuple(record);
    bolt.execute(matching);
    BulletRecord expectedRecord = RecordBox.get().add("id", "b235gf23b").add("mid", "123").getRecord();
    Tuple expected = makeDataTuple(TupleClassifier.Type.DATA_TUPLE, "42", expectedRecord);
    Assert.assertFalse(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 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) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 84 with BulletRecord

use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.

the class FilterBoltTest method testCompleteSignal.

@Test
public void testCompleteSignal() {
    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);
    Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
    Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
    Assert.assertEquals(collector.getEmittedCount(), 2);
    Tuple complete = makeIDTuple(TupleClassifier.Type.METADATA_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
    bolt.execute(complete);
    bolt.execute(matching);
    bolt.execute(matching);
    Assert.assertEquals(collector.getEmittedCount(), 2);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Metadata(com.yahoo.bullet.pubsub.Metadata) 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) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Example 85 with BulletRecord

use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.

the class FilterBoltTest method testKillSignal.

@Test
public void testKillSignal() {
    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);
    Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
    Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
    Assert.assertEquals(collector.getEmittedCount(), 2);
    Tuple kill = makeIDTuple(TupleClassifier.Type.METADATA_TUPLE, "42", new Metadata(Metadata.Signal.KILL, null));
    bolt.execute(kill);
    bolt.execute(matching);
    bolt.execute(matching);
    Assert.assertEquals(collector.getEmittedCount(), 2);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Metadata(com.yahoo.bullet.pubsub.Metadata) 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) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Aggregations

BulletRecord (com.yahoo.bullet.record.BulletRecord)210 Test (org.testng.annotations.Test)196 Tuple (org.apache.storm.tuple.Tuple)55 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)53 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)53 TopKTest (com.yahoo.bullet.aggregations.TopKTest)53 Clip (com.yahoo.bullet.result.Clip)53 HashMap (java.util.HashMap)53 Map (java.util.Map)53 BulletConfig (com.yahoo.bullet.common.BulletConfig)46 List (java.util.List)45 IntStream (java.util.stream.IntStream)45 Assert (org.testng.Assert)45 RecordBox (com.yahoo.bullet.result.RecordBox)43 Arrays.asList (java.util.Arrays.asList)40 Pair (org.apache.commons.lang3.tuple.Pair)40 AggregationUtils.makeAttributes (com.yahoo.bullet.parsing.AggregationUtils.makeAttributes)34 BulletError (com.yahoo.bullet.common.BulletError)33 Aggregation (com.yahoo.bullet.parsing.Aggregation)33 Concept (com.yahoo.bullet.result.Meta.Concept)33