use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithoutWindowsThatAreTimedOutAreTimeBased.
@Test
public void testRawQueriesWithoutWindowsThatAreTimedOutAreTimeBased() {
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);
RunningQuery runningQuery = spy(new RunningQuery("", query));
doAnswer(returnsElementsOf(asList(false, true))).when(runningQuery).isTimedOut();
Querier querier = new Querier(Querier.Mode.ALL, runningQuery, config);
querier.initialize();
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(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.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testTimes.
@Test
public void testTimes() {
BulletConfig defaults = new BulletConfig();
Map<String, String> names = (Map<String, String>) defaults.get(BulletConfig.RESULT_METADATA_METRICS);
long startTime = System.currentTimeMillis();
Querier querier = make(Querier.Mode.ALL, "", "{'aggregation' : {}}", emptyMap());
Map<String, Object> meta = querier.getMetadata().asMap();
Assert.assertEquals(meta.size(), 2);
Map<String, Object> queryMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.QUERY_METADATA.getName()));
Map<String, Object> windowMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.WINDOW_METADATA.getName()));
long creationTime = ((Number) queryMeta.get(names.get(Meta.Concept.QUERY_RECEIVE_TIME.getName()))).longValue();
long emitTime = ((Number) windowMeta.get(names.get(Meta.Concept.WINDOW_EMIT_TIME.getName()))).longValue();
long endTime = System.currentTimeMillis();
Assert.assertTrue(creationTime >= startTime && creationTime <= endTime);
Assert.assertTrue(emitTime >= startTime && emitTime <= endTime);
Clip finalResult = querier.finish();
Assert.assertNotNull(finalResult);
Assert.assertTrue(finalResult.getRecords().isEmpty());
meta = finalResult.getMeta().asMap();
queryMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.QUERY_METADATA.getName()));
windowMeta = (Map<String, Object>) meta.get(names.get(Meta.Concept.WINDOW_METADATA.getName()));
creationTime = ((Number) queryMeta.get(names.get(Meta.Concept.QUERY_RECEIVE_TIME.getName()))).longValue();
emitTime = ((Number) windowMeta.get(names.get(Meta.Concept.WINDOW_EMIT_TIME.getName()))).longValue();
long finishTime = ((Number) queryMeta.get(names.get(Meta.Concept.QUERY_FINISH_TIME.getName()))).longValue();
endTime = System.currentTimeMillis();
Assert.assertTrue(creationTime >= startTime && creationTime <= finishTime);
Assert.assertTrue(emitTime >= startTime && emitTime <= finishTime);
Assert.assertTrue(finishTime <= endTime);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testQueryAsString.
@Test
public void testQueryAsString() {
Querier querier = make(Querier.Mode.ALL, "ahdf3", "{}", emptyMap());
Assert.assertEquals(querier.toString(), "ahdf3 : {}");
BulletConfig config = new BulletConfig();
Query query = new Query();
query.configure(config);
query.initialize();
querier = make(Querier.Mode.ALL, "ahdf3", query, config);
Assert.assertEquals(querier.toString(), "ahdf3 : " + query.toString());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QuerierTest method testDisabledQueryMeta.
@Test
public void testDisabledQueryMeta() {
BulletConfig defaults = new BulletConfig();
defaults.set(BulletConfig.RESULT_METADATA_METRICS, emptyMap());
Querier querier = make(Querier.Mode.ALL, "", "{'aggregation' : {}}", defaults);
Assert.assertTrue(querier.getMetadata().asMap().isEmpty());
Clip result = querier.finish();
Assert.assertNotNull(result);
Assert.assertTrue(result.getRecords().isEmpty());
Assert.assertTrue(result.getMeta().asMap().isEmpty());
}
use of com.yahoo.bullet.common.BulletConfig 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();
Query query = new Query();
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.COUNT_DISTINCT);
aggregation.setFields(singletonMap("foo", "bar"));
query.setAggregation(aggregation);
query.setWindow(WindowUtils.makeWindow(Window.Unit.TIME, 1));
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());
}
Aggregations