use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QueryUtils method makeRawQuery.
public static Query makeRawQuery(Integer size) {
Query query = new Query(new Projection(), null, new Raw(size), null, new Window(), null);
query.configure(new BulletConfig());
return query;
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QuerierTest method testLogicFilterAnd.
@Test
public void testLogicFilterAnd() {
// 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.AND);
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.assertFalse(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 testFilteringProjection.
@Test
public void testFilteringProjection() {
Projection projection = new Projection(Collections.singletonList(new Field("mid", new FieldExpression("map_field", "id"))), false);
Expression filter = new BinaryExpression(new FieldExpression("map_field", "id"), new ListExpression(Arrays.asList(new ValueExpression("1"), new ValueExpression("23"))), Operation.EQUALS_ANY);
Query query = new Query(projection, filter, new Raw(null), null, new Window(), null);
BulletConfig config = new BulletConfig();
query.configure(config);
Querier querier = new Querier(makeRunningQuery("", query), config);
RecordBox boxA = RecordBox.get().addMap("map_field", Pair.of("id", "3"));
querier.consume(boxA.getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertNull(querier.getData());
RecordBox boxB = RecordBox.get().addMap("map_field", Pair.of("id", "23"));
RecordBox expected = RecordBox.get().add("mid", "23");
querier.consume(boxB.getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertEquals(querier.getData(), getListBytes(expected.getRecord()));
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QuerierTest method testLogicFilterNot.
@Test
public void testLogicFilterNot() {
// legacy test
Expression filter = new BinaryExpression(new FieldExpression("field"), new ValueExpression("abc"), Operation.NOT_EQUALS);
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").getRecord());
Assert.assertFalse(querier.hasNewData());
querier.consume(RecordBox.get().add("field", "ddd").getRecord());
Assert.assertTrue(querier.hasNewData());
}
use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.
the class QuerierTest method testBasicWindowMaximumEmittedWithNonMatchingRecords.
@Test
public void testBasicWindowMaximumEmittedWithNonMatchingRecords() {
Expression filter = new BinaryExpression(new FieldExpression("mid"), new ListExpression(Arrays.asList(new ValueExpression("1"), new ValueExpression("23"))), Operation.EQUALS_ANY);
Query query = new Query(new Projection(), filter, new Raw(2), null, new Window(), null);
Querier querier = make(Querier.Mode.PARTITION, query);
byte[] expected = getListBytes(RecordBox.get().add("mid", "23").getRecord());
byte[] expectedTwice = getListBytes(RecordBox.get().add("mid", "23").getRecord(), RecordBox.get().add("mid", "23").getRecord());
querier.consume(RecordBox.get().add("mid", "23").getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.isDone());
Assert.assertTrue(querier.hasNewData());
Assert.assertEquals(querier.getData(), expected);
// Doesn't match
querier.consume(RecordBox.get().add("mid", "42").getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.isDone());
Assert.assertTrue(querier.hasNewData());
Assert.assertEquals(querier.getData(), expected);
querier.consume(RecordBox.get().add("mid", "23").getRecord());
Assert.assertTrue(querier.isClosed());
Assert.assertTrue(querier.isDone());
Assert.assertTrue(querier.hasNewData());
Assert.assertEquals(querier.getData(), expectedTwice);
// Nothing else is consumed because RAW is closed
IntStream.range(0, 10).mapToObj(i -> RecordBox.get().add("mid", "23").getRecord()).forEach(querier::consume);
Assert.assertTrue(querier.isClosed());
Assert.assertTrue(querier.isDone());
Assert.assertTrue(querier.hasNewData());
Assert.assertEquals(querier.getData(), expectedTwice);
querier.reset();
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.isDone());
Assert.assertFalse(querier.hasNewData());
Assert.assertNull(querier.getData());
}
Aggregations