use of com.yahoo.bullet.common.BulletConfig in project bullet-storm by yahoo.
the class JoinBoltTest method testDistribution.
@Test
public void testDistribution() {
BulletConfig bulletConfig = DistributionTest.makeConfiguration(10, 128);
Distribution distribution = DistributionTest.makeDistribution(bulletConfig, makeAttributes(Distribution.Type.PMF, 3), "field", 10, null);
IntStream.range(0, 50).mapToObj(i -> RecordBox.get().add("field", i).getRecord()).forEach(distribution::consume);
byte[] first = distribution.getData();
distribution = DistributionTest.makeDistribution(bulletConfig, makeAttributes(Distribution.Type.PMF, 3), "field", 10, null);
IntStream.range(50, 101).mapToObj(i -> RecordBox.get().add("field", i).getRecord()).forEach(distribution::consume);
byte[] second = distribution.getData();
bolt = new DonableJoinBolt(config, 2, true);
setup(bolt);
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeAggregationQuery(DISTRIBUTION, 10, Distribution.Type.PMF, "field", null, null, null, null, 3), EMPTY);
bolt.execute(query);
sendRawByteTuplesTo(bolt, "42", asList(first, second));
BulletRecord expectedA = RecordBox.get().add(RANGE_FIELD, NEGATIVE_INFINITY_START + SEPARATOR + 0.0 + END_EXCLUSIVE).add(COUNT_FIELD, 0.0).add(PROBABILITY_FIELD, 0.0).getRecord();
BulletRecord expectedB = RecordBox.get().add(RANGE_FIELD, START_INCLUSIVE + 0.0 + SEPARATOR + 50.0 + END_EXCLUSIVE).add(COUNT_FIELD, 50.0).add(PROBABILITY_FIELD, 50.0 / 101).getRecord();
BulletRecord expectedC = RecordBox.get().add(RANGE_FIELD, START_INCLUSIVE + 50.0 + SEPARATOR + 100.0 + END_EXCLUSIVE).add(COUNT_FIELD, 50.0).add(PROBABILITY_FIELD, 50.0 / 101).getRecord();
BulletRecord expectedD = RecordBox.get().add(RANGE_FIELD, START_INCLUSIVE + 100.0 + SEPARATOR + POSITIVE_INFINITY_END).add(COUNT_FIELD, 1.0).add(PROBABILITY_FIELD, 1.0 / 101).getRecord();
List<BulletRecord> results = asList(expectedA, expectedB, expectedC, expectedD);
Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(results).asJSON(), COMPLETED);
Tuple tick = TupleUtils.makeTuple(TupleClassifier.Type.TICK_TUPLE);
bolt.execute(tick);
for (int i = 0; i < BulletStormConfig.DEFAULT_JOIN_BOLT_QUERY_TICK_TIMEOUT - 1; ++i) {
bolt.execute(tick);
Assert.assertFalse(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
}
bolt.execute(tick);
Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.FEEDBACK_STREAM).count(), 1);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class GroupByTest method testAttributeOperationsUnknownOperation.
@Test
public void testAttributeOperationsUnknownOperation() {
Aggregation aggregation = makeAggregation(emptyMap(), 10, null);
aggregation.setAttributes(makeAttributes(makeGroupOperation(COUNT, null, "bar"), makeGroupOperation(COUNT_FIELD, "foo", "foo_avg")));
GroupBy groupBy = makeGroupBy(new BulletConfig(), aggregation, ALL_METADATA);
// The bad operation should have been thrown out.
Assert.assertFalse(groupBy.initialize().isPresent());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class GroupByTest method testAttributeOperationsDuplicateOperation.
@Test
public void testAttributeOperationsDuplicateOperation() {
Aggregation aggregation = makeAggregation(emptyMap(), 10, null);
aggregation.setAttributes(makeAttributes(makeGroupOperation(COUNT, null, null), makeGroupOperation(SUM, "foo", null), makeGroupOperation(COUNT, null, null), makeGroupOperation(SUM, "bar", null), makeGroupOperation(SUM, "foo", null), makeGroupOperation(SUM, "bar", null)));
GroupBy groupBy = makeGroupBy(new BulletConfig(), aggregation, ALL_METADATA);
// The bad ones should be removed.
Assert.assertFalse(groupBy.initialize().isPresent());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class RawTest method makeRaw.
private static Raw makeRaw(int size, int maxSize) {
Aggregation aggregation = new Aggregation();
aggregation.setSize(size);
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, maxSize);
Raw raw = new Raw(aggregation, config.validate());
raw.initialize();
return raw;
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithoutWindowsThatAreClosedAreNotTimeBased.
@Test
public void testRawQueriesWithoutWindowsThatAreClosedAreNotTimeBased() {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, 10);
config.validate();
Query query = new Query();
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.RAW);
query.setAggregation(aggregation);
query.configure(config);
Querier querier = make(Querier.Mode.ALL, query, config);
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.shouldBuffer());
Assert.assertEquals(querier.getWindow().getClass(), Basic.class);
querier.consume(RecordBox.get().getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.shouldBuffer());
IntStream.range(0, 9).forEach(i -> querier.consume(RecordBox.get().getRecord()));
Assert.assertTrue(querier.isClosed());
Assert.assertFalse(querier.shouldBuffer());
}
Aggregations