use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class Querier method shouldBuffer.
/**
* Returns if this query should buffer before emitting results. You can use this to wait for the final results
* for your window (or your final results if you have no window) in your Join or Combine stage after a query is
* {@link #isDone()} or {@link #isClosed()}.
*
* @return A boolean that is true if the query results should be buffered.
*/
public boolean shouldBuffer() {
Window window = runningQuery.getQuery().getWindow();
boolean noWindow = window == null;
// query is not yet done. So this tells the driver to buffer the query to wait for more potential results.
if (noWindow && isRaw()) {
return runningQuery.isTimedOut();
}
// No window (and not raw) is a duration based query => do buffer. Otherwise, buffer if the window is time based.
return noWindow || window.isTimeBased();
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class WindowingOperations method findScheme.
/**
* Create a windowing {@link Scheme} for this particular {@link Query}.
*
* @param query The configured, initialized query to find a scheme for.
* @param strategy The aggregation strategy to use for in the windowing scheme.
* @param config The {@link BulletConfig} to use for configuration.
* @return A windowing scheme to use for this query.
*/
public static Scheme findScheme(Query query, Strategy strategy, BulletConfig config) {
/*
* TODO: Support other windows
* The windows we support at the moment:
* 1. No window -> Basic
* 2. Window is emit RECORD and include RECORD -> Reactive
* 3. Window is emit TIME and include ALL -> Additive Tumbling
* 4. All other windows -> Tumbling (RAW can be Tumbling too)
*/
Window window = query.getWindow();
if (window == null) {
return new Basic(strategy, null, config);
}
Window.Classification classification = window.getType();
if (classification == Window.Classification.RECORD_RECORD) {
return new Reactive(strategy, window, config);
}
if (classification == Window.Classification.TIME_ALL) {
return new AdditiveTumbling(strategy, window, config);
}
return new Tumbling(strategy, window, config);
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class WindowingOperationsTest method testNotForcingNonRawToTumbling.
@Test
public void testNotForcingNonRawToTumbling() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Window window = WindowUtils.makeReactiveWindow();
window.configure(config);
query.setWindow(window);
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.GROUP);
query.setAggregation(aggregation);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Reactive.class);
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class WindowingOperationsTest method testAdditiveTumblingWindow.
@Test
public void testAdditiveTumblingWindow() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Window window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
window.configure(config);
query.setWindow(window);
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.GROUP);
query.setAggregation(aggregation);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), AdditiveTumbling.class);
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class WindowingOperationsTest method testOtherWindowsForcedToTumbling.
@Test
public void testOtherWindowsForcedToTumbling() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Window window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.RECORD, 4);
window.configure(config);
query.setWindow(window);
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.COUNT_DISTINCT);
query.setAggregation(aggregation);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Tumbling.class);
}
Aggregations