Search in sources :

Example 1 with ComplexEventPopulater

use of io.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.

the class OnDemandQueryParser method constructOnDemandQueryRuntime.

private static OnDemandQueryRuntime constructOnDemandQueryRuntime(AggregationRuntime aggregation, OnDemandQuery onDemandQuery, Map<String, Table> tableMap, Map<String, Window> windowMap, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    int metaPosition;
    metaStreamEvent.setEventType(EventType.AGGREGATE);
    initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
    CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, onDemandQuery.getSelector().getGroupByList(), metaStreamInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
    ((IncrementalAggregateCompileCondition) compiledCondition).init();
    metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
    FindOnDemandQueryRuntime findOnDemandQueryRuntime = new FindOnDemandQueryRuntime(aggregation, compiledCondition, siddhiQueryContext.getName(), metaStreamEvent, siddhiQueryContext);
    metaPosition = 1;
    populateFindOnDemandQueryRuntime(findOnDemandQueryRuntime, metaStreamInfoHolder, onDemandQuery.getSelector(), variableExpressionExecutors, tableMap, windowMap, metaPosition, !onDemandQuery.getSelector().getGroupByList().isEmpty(), lockWrapper, siddhiQueryContext);
    ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
    ((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
    return findOnDemandQueryRuntime;
}
Also used : CompiledCondition(io.siddhi.core.util.collection.operator.CompiledCondition) FindOnDemandQueryRuntime(io.siddhi.core.query.FindOnDemandQueryRuntime) MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) IncrementalAggregateCompileCondition(io.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) ComplexEventPopulater(io.siddhi.core.event.stream.populater.ComplexEventPopulater)

Example 2 with ComplexEventPopulater

use of io.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.

the class QueryParserHelper method initSingleStreamRuntime.

private static void initSingleStreamRuntime(SingleStreamRuntime singleStreamRuntime, int streamEventChainIndex, MetaComplexEvent metaComplexEvent, StateEventFactory stateEventFactory, LockWrapper lockWrapper, String queryName) {
    MetaStreamEvent metaStreamEvent;
    if (metaComplexEvent instanceof MetaStateEvent) {
        metaStreamEvent = ((MetaStateEvent) metaComplexEvent).getMetaStreamEvent(streamEventChainIndex);
    } else {
        metaStreamEvent = (MetaStreamEvent) metaComplexEvent;
    }
    StreamEventFactory streamEventFactory = new StreamEventFactory(metaStreamEvent);
    ProcessStreamReceiver processStreamReceiver = singleStreamRuntime.getProcessStreamReceiver();
    processStreamReceiver.setMetaStreamEvent(metaStreamEvent);
    processStreamReceiver.setStreamEventFactory(streamEventFactory);
    processStreamReceiver.setLockWrapper(lockWrapper);
    processStreamReceiver.init();
    Processor processor = singleStreamRuntime.getProcessorChain();
    while (processor != null) {
        if (processor instanceof SchedulingProcessor) {
            ((SchedulingProcessor) processor).getScheduler().setStreamEventFactory(streamEventFactory);
            ((SchedulingProcessor) processor).getScheduler().init(lockWrapper, queryName);
        }
        if (processor instanceof AbstractStreamProcessor) {
            ((AbstractStreamProcessor) processor).setStreamEventCloner(new StreamEventCloner(metaStreamEvent, streamEventFactory));
            ((AbstractStreamProcessor) processor).constructStreamEventPopulater(metaStreamEvent, streamEventChainIndex);
        }
        if (stateEventFactory != null && processor instanceof JoinProcessor) {
            if (((JoinProcessor) processor).getCompiledCondition() instanceof IncrementalAggregateCompileCondition) {
                IncrementalAggregateCompileCondition compiledCondition = (IncrementalAggregateCompileCondition) ((JoinProcessor) processor).getCompiledCondition();
                compiledCondition.init();
                ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamEvent, 0, compiledCondition.getAdditionalAttributes());
                compiledCondition.setComplexEventPopulater(complexEventPopulater);
            }
            ((JoinProcessor) processor).setStateEventFactory(stateEventFactory);
        }
        if (stateEventFactory != null && processor instanceof StreamPreStateProcessor) {
            ((StreamPreStateProcessor) processor).setStateEventFactory(stateEventFactory);
            ((StreamPreStateProcessor) processor).setStreamEventFactory(streamEventFactory);
            ((StreamPreStateProcessor) processor).setStreamEventCloner(new StreamEventCloner(metaStreamEvent, streamEventFactory));
            if (metaComplexEvent instanceof MetaStateEvent) {
                ((StreamPreStateProcessor) processor).setStateEventCloner(new StateEventCloner(((MetaStateEvent) metaComplexEvent), stateEventFactory));
            }
        }
        processor = processor.getNextProcessor();
    }
}
Also used : ProcessStreamReceiver(io.siddhi.core.query.input.ProcessStreamReceiver) AbstractStreamProcessor(io.siddhi.core.query.processor.stream.AbstractStreamProcessor) Processor(io.siddhi.core.query.processor.Processor) SchedulingProcessor(io.siddhi.core.query.processor.SchedulingProcessor) StreamPreStateProcessor(io.siddhi.core.query.input.stream.state.StreamPreStateProcessor) JoinProcessor(io.siddhi.core.query.input.stream.join.JoinProcessor) AbstractStreamProcessor(io.siddhi.core.query.processor.stream.AbstractStreamProcessor) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) IncrementalAggregateCompileCondition(io.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) ComplexEventPopulater(io.siddhi.core.event.stream.populater.ComplexEventPopulater) StreamPreStateProcessor(io.siddhi.core.query.input.stream.state.StreamPreStateProcessor) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) SchedulingProcessor(io.siddhi.core.query.processor.SchedulingProcessor) StreamEventCloner(io.siddhi.core.event.stream.StreamEventCloner) JoinProcessor(io.siddhi.core.query.input.stream.join.JoinProcessor) StateEventCloner(io.siddhi.core.event.state.StateEventCloner) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

ComplexEventPopulater (io.siddhi.core.event.stream.populater.ComplexEventPopulater)2 IncrementalAggregateCompileCondition (io.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition)2 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)1 StateEventCloner (io.siddhi.core.event.state.StateEventCloner)1 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1 StreamEventCloner (io.siddhi.core.event.stream.StreamEventCloner)1 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)1 FindOnDemandQueryRuntime (io.siddhi.core.query.FindOnDemandQueryRuntime)1 ProcessStreamReceiver (io.siddhi.core.query.input.ProcessStreamReceiver)1 JoinProcessor (io.siddhi.core.query.input.stream.join.JoinProcessor)1 StreamPreStateProcessor (io.siddhi.core.query.input.stream.state.StreamPreStateProcessor)1 Processor (io.siddhi.core.query.processor.Processor)1 SchedulingProcessor (io.siddhi.core.query.processor.SchedulingProcessor)1 AbstractStreamProcessor (io.siddhi.core.query.processor.stream.AbstractStreamProcessor)1 CompiledCondition (io.siddhi.core.util.collection.operator.CompiledCondition)1 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)1