Search in sources :

Example 1 with PassThroughOutputRateLimiter

use of io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter in project siddhi by wso2.

the class OnDemandQueryParser method populateFindOnDemandQueryRuntime.

private static void populateFindOnDemandQueryRuntime(FindOnDemandQueryRuntime findOnDemandQueryRuntime, MatchingMetaInfoHolder metaStreamInfoHolder, Selector selector, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, Map<String, Window> windowMap, int metaPosition, boolean groupBy, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    ReturnStream returnStream = new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS);
    QuerySelector querySelector = SelectorParser.parse(selector, returnStream, metaStreamInfoHolder.getMetaStateEvent(), tableMap, variableExpressionExecutors, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContext);
    PassThroughOutputRateLimiter rateLimiter = new PassThroughOutputRateLimiter(siddhiQueryContext.getName());
    rateLimiter.init(lockWrapper, groupBy, siddhiQueryContext);
    OutputCallback outputCallback = OutputParser.constructOutputCallback(returnStream, metaStreamInfoHolder.getMetaStateEvent().getOutputStreamDefinition(), tableMap, windowMap, true, siddhiQueryContext);
    rateLimiter.setOutputCallback(outputCallback);
    querySelector.setNextProcessor(rateLimiter);
    QueryParserHelper.reduceMetaComplexEvent(metaStreamInfoHolder.getMetaStateEvent());
    QueryParserHelper.updateVariablePosition(metaStreamInfoHolder.getMetaStateEvent(), variableExpressionExecutors);
    querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent()));
    findOnDemandQueryRuntime.setStateEventFactory(new StateEventFactory(metaStreamInfoHolder.getMetaStateEvent()));
    findOnDemandQueryRuntime.setSelector(querySelector);
    findOnDemandQueryRuntime.setOutputAttributes(metaStreamInfoHolder.getMetaStateEvent().getOutputStreamDefinition().getAttributeList());
}
Also used : StateEventFactory(io.siddhi.core.event.state.StateEventFactory) QuerySelector(io.siddhi.core.query.selector.QuerySelector) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) PassThroughOutputRateLimiter(io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter) OutputCallback(io.siddhi.core.query.output.callback.OutputCallback)

Example 2 with PassThroughOutputRateLimiter

use of io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter in project siddhi by wso2.

the class OnDemandQueryParser method getQuerySelector.

private static QuerySelector getQuerySelector(MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, Map<String, Window> windowMap, int metaPosition, OnDemandQuery onDemandQuery, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    QuerySelector querySelector = SelectorParser.parse(onDemandQuery.getSelector(), onDemandQuery.getOutputStream(), matchingMetaInfoHolder.getMetaStateEvent(), tableMap, variableExpressionExecutors, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContext);
    PassThroughOutputRateLimiter rateLimiter = new PassThroughOutputRateLimiter(siddhiQueryContext.getName());
    rateLimiter.init(lockWrapper, !onDemandQuery.getSelector().getGroupByList().isEmpty(), siddhiQueryContext);
    OutputCallback outputCallback = OutputParser.constructOutputCallback(onDemandQuery.getOutputStream(), matchingMetaInfoHolder.getMetaStateEvent().getOutputStreamDefinition(), tableMap, windowMap, true, siddhiQueryContext);
    rateLimiter.setOutputCallback(outputCallback);
    querySelector.setNextProcessor(rateLimiter);
    QueryParserHelper.reduceMetaComplexEvent(matchingMetaInfoHolder.getMetaStateEvent());
    QueryParserHelper.updateVariablePosition(matchingMetaInfoHolder.getMetaStateEvent(), variableExpressionExecutors);
    querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(matchingMetaInfoHolder.getMetaStateEvent()));
    return querySelector;
}
Also used : QuerySelector(io.siddhi.core.query.selector.QuerySelector) PassThroughOutputRateLimiter(io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter) OutputCallback(io.siddhi.core.query.output.callback.OutputCallback)

Aggregations

OutputCallback (io.siddhi.core.query.output.callback.OutputCallback)2 PassThroughOutputRateLimiter (io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter)2 QuerySelector (io.siddhi.core.query.selector.QuerySelector)2 StateEventFactory (io.siddhi.core.event.state.StateEventFactory)1 ReturnStream (io.siddhi.query.api.execution.query.output.stream.ReturnStream)1