use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QuerierTest method testLogicFilterOr.
@Test
public void testLogicFilterOr() {
// legacy test
Expression filter = new BinaryExpression(new BinaryExpression(new FieldExpression("field"), new ValueExpression("abc"), Operation.EQUALS), new BinaryExpression(new FieldExpression("id"), new ValueExpression("1"), Operation.EQUALS), Operation.OR);
Query query = new Query(new Projection(), filter, new Raw(null), null, new Window(), null);
Querier querier = make(Querier.Mode.PARTITION, query);
querier.consume(RecordBox.get().add("field", "abc").add("id", "2").getRecord());
Assert.assertTrue(querier.hasNewData());
querier.consume(RecordBox.get().add("field", "abc").add("id", "1").getRecord());
Assert.assertTrue(querier.hasNewData());
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QuerierTest method testOrderBy.
@Test
public void testOrderBy() {
Expression filter = new UnaryExpression(new FieldExpression("a"), Operation.IS_NOT_NULL);
OrderBy orderBy = new OrderBy(Collections.singletonList(new OrderBy.SortItem(new FieldExpression("a"), OrderBy.Direction.DESC)));
Query query = new Query(new Projection(), filter, new Raw(500), Collections.singletonList(orderBy), new Window(), null);
Querier querier = make(Querier.Mode.ALL, query);
IntStream.range(0, 4).forEach(i -> querier.consume(RecordBox.get().add("a", 10 - i).add("b", i + 10).getRecord()));
List<BulletRecord> result = querier.getResult().getRecords();
Assert.assertEquals(result.size(), 4);
Assert.assertEquals(result.get(0).typedGet("a").getValue(), 10);
Assert.assertEquals(result.get(0).typedGet("b").getValue(), 10);
Assert.assertEquals(result.get(1).typedGet("a").getValue(), 9);
Assert.assertEquals(result.get(1).typedGet("b").getValue(), 11);
Assert.assertEquals(result.get(2).typedGet("a").getValue(), 8);
Assert.assertEquals(result.get(2).typedGet("b").getValue(), 12);
Assert.assertEquals(result.get(3).typedGet("a").getValue(), 7);
Assert.assertEquals(result.get(3).typedGet("b").getValue(), 13);
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QuerierTest method testFiltering.
@Test
public void testFiltering() {
Expression filter = new BinaryExpression(new FieldExpression("field"), new ListExpression(Arrays.asList(new ValueExpression("foo"), new ValueExpression("bar"))), Operation.EQUALS_ANY);
Window window = WindowUtils.makeSlidingWindow(1);
Query query = new Query(new Projection(), filter, new Raw(null), null, window, null);
Querier querier = make(Querier.Mode.PARTITION, query);
querier.consume(RecordBox.get().add("field", "foo").getRecord());
Assert.assertTrue(querier.isClosed());
querier.reset();
querier.consume(RecordBox.get().add("field", "bar").getRecord());
Assert.assertTrue(querier.isClosed());
querier.reset();
querier.consume(RecordBox.get().add("field", "baz").getRecord());
Assert.assertFalse(querier.isClosed());
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class RawStrategyTest method makeRaw.
private static RawStrategy makeRaw(int size, int maxSize) {
Aggregation aggregation = new Raw(size);
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, maxSize);
config.validate();
return (RawStrategy) aggregation.getStrategy(config);
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class PubSubMessageTest method testReadingDataAsDifferentTypes.
@Test
public void testReadingDataAsDifferentTypes() {
String string = getRandomString();
byte[] bytes = getRandomBytes();
Query query = new Query(new Projection(), null, new Raw(1), null, new Window(), Long.MAX_VALUE);
PubSubMessage message;
message = new PubSubMessage("foo", string);
Assert.assertEquals(message.getContent(), string);
Assert.assertEquals(message.getContentAsString(), string);
message = new PubSubMessage("foo", bytes);
Assert.assertEquals(message.getContent(), bytes);
Assert.assertEquals(message.getContentAsByteArray(), bytes);
message = new PubSubMessage("foo", query);
Assert.assertSame(message.getContent(), query);
Assert.assertSame(message.getContentAsQuery(), query);
}
Aggregations