use of com.yahoo.bullet.query.Window 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.Window 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.Window in project bullet-core by yahoo.
the class QuerierTest method testMetadataDisabled.
@Test
public void testMetadataDisabled() {
BulletConfig config = new BulletConfig();
config.set(BulletConfig.RESULT_METADATA_ENABLE, false);
// Should clear out the default metadata
config.validate();
CountDistinct aggregation = new CountDistinct(Collections.singletonList("foo"), "count");
Window window = WindowUtils.makeTumblingWindow(1);
Query query = new Query(new Projection(), null, aggregation, null, window, null);
query.configure(config);
Querier querier = make(Querier.Mode.PARTITION, query, config);
querier.consume(RecordBox.get().add("foo", "A").getRecord());
Assert.assertTrue(querier.getMetadata().asMap().isEmpty());
}
use of com.yahoo.bullet.query.Window in project bullet-core by yahoo.
the class RunningQueryTest method testCreatingWithQuery.
@Test
public void testCreatingWithQuery() {
BulletConfig config = new BulletConfig();
Query query = new Query(new Projection(), null, new Raw(null), null, new Window(), null);
query.configure(config);
RunningQuery runningQuery = new RunningQuery("foo", query, new Metadata(null, "bar"));
Assert.assertEquals(runningQuery.getId(), "foo");
Assert.assertNotNull(runningQuery.getQuery());
Assert.assertEquals(runningQuery.getQueryString(), "bar");
Assert.assertEquals(runningQuery.toString(), query.toString());
}
use of com.yahoo.bullet.query.Window in project bullet-core by yahoo.
the class RunningQueryTest method testTimingOut.
@Test
public void testTimingOut() throws Exception {
BulletConfig config = new BulletConfig();
Query query = new Query(new Projection(), null, new Raw(null), null, new Window(), 1L);
query.configure(config);
RunningQuery runningQuery = new RunningQuery("foo", query, new Metadata(null, null));
// Sleep to make sure it's 1 ms
Thread.sleep(1);
Assert.assertTrue(runningQuery.isTimedOut());
}
Aggregations