Search in sources :

Example 21 with Query

use of com.yahoo.bullet.parsing.Query in project bullet-core by yahoo.

the class WindowingOperationsTest method testTumblingWindow.

@Test
public void testTumblingWindow() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    Window window = WindowUtils.makeTumblingWindow(1000);
    window.configure(config);
    query.setWindow(window);
    Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Tumbling.class);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 22 with Query

use of com.yahoo.bullet.parsing.Query in project bullet-core by yahoo.

the class WindowingOperationsTest method testNoWindow.

@Test
public void testNoWindow() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Basic.class);
}
Also used : Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 23 with Query

use of com.yahoo.bullet.parsing.Query in project bullet-core by yahoo.

the class WindowingOperationsTest method testNotForcingRawToReactive.

@Test
public void testNotForcingRawToReactive() {
    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.RAW);
    query.setAggregation(aggregation);
    Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), AdditiveTumbling.class);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Aggregation(com.yahoo.bullet.parsing.Aggregation) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 24 with Query

use of com.yahoo.bullet.parsing.Query in project bullet-core by yahoo.

the class Querier method initialize.

// ********************************* Monoidal Interface Overrides *********************************
/**
 * Starts the query.
 */
@Override
@SuppressWarnings("unchecked")
public Optional<List<BulletError>> initialize() {
    // Is an empty map if metadata was disabled
    metaKeys = (Map<String, String>) config.getAs(BulletConfig.RESULT_METADATA_METRICS, Map.class);
    Boolean shouldInjectTimestamp = config.getAs(BulletConfig.RECORD_INJECT_TIMESTAMP, Boolean.class);
    if (shouldInjectTimestamp) {
        timestampKey = config.getAs(BulletConfig.RECORD_INJECT_TIMESTAMP_KEY, String.class);
    }
    boolean isRateLimitEnabled = config.getAs(BulletConfig.RATE_LIMIT_ENABLE, Boolean.class);
    if (isRateLimitEnabled) {
        int maxEmit = config.getAs(BulletConfig.RATE_LIMIT_MAX_EMIT_COUNT, Integer.class);
        int timeInterval = config.getAs(BulletConfig.RATE_LIMIT_TIME_INTERVAL, Integer.class);
        rateLimit = new RateLimiter(maxEmit, timeInterval);
    }
    Optional<List<BulletError>> errors;
    errors = runningQuery.initialize();
    if (errors.isPresent()) {
        return errors;
    }
    Query query = this.runningQuery.getQuery();
    // Aggregation and Strategy are guaranteed to not be null.
    Strategy strategy = AggregationOperations.findStrategy(query.getAggregation(), config);
    errors = strategy.initialize();
    if (errors.isPresent()) {
        return errors;
    }
    // Scheme is guaranteed to not be null.
    window = WindowingOperations.findScheme(query, strategy, config);
    return window.initialize();
}
Also used : Query(com.yahoo.bullet.parsing.Query) Strategy(com.yahoo.bullet.aggregations.Strategy) List(java.util.List)

Aggregations

Query (com.yahoo.bullet.parsing.Query)24 Test (org.testng.annotations.Test)22 BulletConfig (com.yahoo.bullet.common.BulletConfig)20 QueryUtils.makeAggregationQuery (com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery)16 QueryUtils.makeProjectionFilterQuery (com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery)14 QueryUtils.makeRawFullQuery (com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery)14 Aggregation (com.yahoo.bullet.parsing.Aggregation)12 Window (com.yahoo.bullet.parsing.Window)6 List (java.util.List)4 Booleans.asList (com.google.common.primitives.Booleans.asList)3 ArrayList (java.util.ArrayList)3 Collections.emptyList (java.util.Collections.emptyList)3 Collections.singletonList (java.util.Collections.singletonList)3 BulletRecord (com.yahoo.bullet.record.BulletRecord)2 Strategy (com.yahoo.bullet.aggregations.Strategy)1 BulletError (com.yahoo.bullet.common.BulletError)1 Clip (com.yahoo.bullet.result.Clip)1 Meta (com.yahoo.bullet.result.Meta)1