use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testQueryAsString.
@Test
public void testQueryAsString() {
BulletConfig config = new BulletConfig();
Query query = makeRawQuery();
query.configure(config);
Querier querier = make(Querier.Mode.ALL, "foo", query, config);
Assert.assertEquals(querier.toString(), "foo : " + query.toString());
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method makeCountQueryWithAllWindow.
private static RunningQuery makeCountQueryWithAllWindow(BulletConfig config, int emitInterval) {
GroupAll groupAll = new GroupAll(singleton(new GroupOperation(GroupOperation.GroupOperationType.COUNT, null, "COUNT")));
Window window = WindowUtils.makeWindow(Window.Unit.TIME, emitInterval, Window.Unit.ALL, null);
Query query = new Query(new Projection(), null, groupAll, null, window, null);
query.configure(config);
RunningQuery runningQuery = spy(makeRunningQuery("", query));
Mockito.doReturn(false).when(runningQuery).isTimedOut();
return runningQuery;
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testCopyProjection.
@Test
public void testCopyProjection() {
Projection projection = new Projection(Collections.singletonList(new Field("mid", new FieldExpression("map_field", "id"))), true);
Query query = new Query(projection, null, 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", "23"));
BulletRecord expected = boxA.getRecord().copy();
expected.setString("mid", "23");
querier.consume(boxA.getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertEquals(querier.getData(), getListBytes(expected));
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithoutWindowsThatAreTimedOutAreStillRecordBased.
@Test
public void testRawQueriesWithoutWindowsThatAreTimedOutAreStillRecordBased() {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, 10);
config.validate();
Query query = makeRawQuery();
query.configure(config);
RunningQuery runningQuery = spy(makeRunningQuery("", query));
Mockito.doAnswer(AdditionalAnswers.returnsElementsOf(Arrays.asList(false, true))).when(runningQuery).isTimedOut();
Querier querier = new Querier(Querier.Mode.ALL, runningQuery, config);
Assert.assertFalse(querier.isClosed());
Assert.assertTrue(querier.shouldBuffer());
Assert.assertEquals(querier.getWindow().getClass(), Basic.class);
IntStream.range(0, 9).forEach(i -> querier.consume(RecordBox.get().getRecord()));
Assert.assertFalse(querier.isClosed());
// Now runningQuery is timed out but query is not done.
Assert.assertTrue(querier.shouldBuffer());
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithoutWindowsThatAreClosedAreRecordBased.
@Test
public void testRawQueriesWithoutWindowsThatAreClosedAreRecordBased() {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, 10);
config.validate();
Query query = makeRawQuery();
query.configure(config);
Querier querier = make(Querier.Mode.ALL, query, config);
Assert.assertFalse(querier.isClosed());
Assert.assertTrue(querier.shouldBuffer());
Assert.assertEquals(querier.getWindow().getClass(), Basic.class);
querier.consume(RecordBox.get().getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertTrue(querier.shouldBuffer());
IntStream.range(0, 9).forEach(i -> querier.consume(RecordBox.get().getRecord()));
Assert.assertTrue(querier.isClosed());
Assert.assertTrue(querier.shouldBuffer());
}
Aggregations