Search in sources :

Example 1 with Strategy

use of com.yahoo.bullet.aggregations.Strategy 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

Strategy (com.yahoo.bullet.aggregations.Strategy)1 Query (com.yahoo.bullet.parsing.Query)1 List (java.util.List)1