Search in sources :

Example 1 with ProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver in project ballerina by ballerina-lang.

the class InputStreamParser method parse.

/**
 * Parse an InputStream returning corresponding StreamRuntime.
 *
 * @param inputStream                input stream to be parsed
 * @param siddhiAppContext           associated siddhi siddhiAppContext
 * @param streamDefinitionMap        map containing user given stream definitions
 * @param tableDefinitionMap         table definition map
 * @param windowDefinitionMap        window definition map
 * @param aggregationDefinitionMap   aggregation definition map
 * @param tableMap                   Table Map
 * @param windowMap                  event window map
 * @param aggregationMap             aggregator map
 * @param executors                  List to hold VariableExpressionExecutors to update after query parsing
 * @param latencyTracker             latency tracker
 * @param outputExpectsExpiredEvents is output expects ExpiredEvents
 * @param queryName                  query name of input stream belongs to.
 * @return StreamRuntime
 */
public static StreamRuntime parse(InputStream inputStream, SiddhiAppContext siddhiAppContext, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, Map<String, Window> windowMap, Map<String, AggregationRuntime> aggregationMap, List<VariableExpressionExecutor> executors, LatencyTracker latencyTracker, boolean outputExpectsExpiredEvents, String queryName) {
    if (inputStream instanceof BasicSingleInputStream || inputStream instanceof SingleInputStream) {
        SingleInputStream singleInputStream = (SingleInputStream) inputStream;
        Window window = windowMap.get(singleInputStream.getStreamId());
        // If stream is from window, allow batch
        boolean batchProcessingAllowed = window != null;
        // processing
        ProcessStreamReceiver processStreamReceiver = new ProcessStreamReceiver(singleInputStream.getStreamId(), latencyTracker, queryName, siddhiAppContext);
        processStreamReceiver.setBatchProcessingAllowed(batchProcessingAllowed);
        return SingleInputStreamParser.parseInputStream((SingleInputStream) inputStream, siddhiAppContext, executors, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, new MetaStreamEvent(), processStreamReceiver, true, outputExpectsExpiredEvents, queryName);
    } else if (inputStream instanceof JoinInputStream) {
        return JoinInputStreamParser.parseInputStream(((JoinInputStream) inputStream), siddhiAppContext, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, windowMap, aggregationMap, executors, latencyTracker, outputExpectsExpiredEvents, queryName);
    } else if (inputStream instanceof StateInputStream) {
        MetaStateEvent metaStateEvent = new MetaStateEvent(inputStream.getAllStreamIds().size());
        return StateInputStreamParser.parseInputStream(((StateInputStream) inputStream), siddhiAppContext, metaStateEvent, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, executors, latencyTracker, queryName);
    } else {
        throw new OperationNotSupportedException();
    }
}
Also used : Window(org.ballerinalang.siddhi.core.window.Window) OperationNotSupportedException(org.ballerinalang.siddhi.core.exception.OperationNotSupportedException) ProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver) BasicSingleInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) SingleInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.SingleInputStream) JoinInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.JoinInputStream) BasicSingleInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) StateInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.StateInputStream) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(org.ballerinalang.siddhi.core.event.state.MetaStateEvent)

Example 2 with ProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver in project ballerina by ballerina-lang.

the class JoinInputStreamParser method parseInputStream.

public static StreamRuntime parseInputStream(JoinInputStream joinInputStream, SiddhiAppContext siddhiAppContext, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, Map<String, Window> windowMap, Map<String, AggregationRuntime> aggregationMap, List<VariableExpressionExecutor> executors, LatencyTracker latencyTracker, boolean outputExpectsExpiredEvents, String queryName) {
    try {
        ProcessStreamReceiver leftProcessStreamReceiver;
        ProcessStreamReceiver rightProcessStreamReceiver;
        MetaStreamEvent leftMetaStreamEvent = new MetaStreamEvent();
        MetaStreamEvent rightMetaStreamEvent = new MetaStreamEvent();
        String leftInputStreamId = ((SingleInputStream) joinInputStream.getLeftInputStream()).getStreamId();
        String rightInputStreamId = ((SingleInputStream) joinInputStream.getRightInputStream()).getStreamId();
        boolean leftOuterJoinProcessor = false;
        boolean rightOuterJoinProcessor = false;
        if (joinInputStream.getAllStreamIds().size() == 2) {
            setEventType(streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, leftMetaStreamEvent, leftInputStreamId);
            setEventType(streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, rightMetaStreamEvent, rightInputStreamId);
            leftProcessStreamReceiver = new ProcessStreamReceiver(leftInputStreamId, latencyTracker, queryName, siddhiAppContext);
            leftProcessStreamReceiver.setBatchProcessingAllowed(leftMetaStreamEvent.getEventType() == WINDOW);
            rightProcessStreamReceiver = new ProcessStreamReceiver(rightInputStreamId, latencyTracker, queryName, siddhiAppContext);
            rightProcessStreamReceiver.setBatchProcessingAllowed(rightMetaStreamEvent.getEventType() == WINDOW);
            if ((leftMetaStreamEvent.getEventType() == TABLE || leftMetaStreamEvent.getEventType() == AGGREGATE) && (rightMetaStreamEvent.getEventType() == TABLE || rightMetaStreamEvent.getEventType() == AGGREGATE)) {
                throw new SiddhiAppCreationException("Both inputs of join " + leftInputStreamId + " and " + rightInputStreamId + " are from static sources");
            }
            if (leftMetaStreamEvent.getEventType() != AGGREGATE && rightMetaStreamEvent.getEventType() != AGGREGATE) {
                if (joinInputStream.getPer() != null) {
                    throw new SiddhiAppCreationException("When joining " + leftInputStreamId + " and " + rightInputStreamId + " 'per' cannot be used as neither of them is an aggregation ");
                } else if (joinInputStream.getWithin() != null) {
                    throw new SiddhiAppCreationException("When joining " + leftInputStreamId + " and " + rightInputStreamId + " 'within' cannot be used as neither of them is an aggregation ");
                }
            }
        } else {
            if (windowDefinitionMap.containsKey(joinInputStream.getAllStreamIds().get(0))) {
                leftMetaStreamEvent.setEventType(WINDOW);
                rightMetaStreamEvent.setEventType(WINDOW);
                rightProcessStreamReceiver = new MultiProcessStreamReceiver(joinInputStream.getAllStreamIds().get(0), 1, latencyTracker, queryName, siddhiAppContext);
                rightProcessStreamReceiver.setBatchProcessingAllowed(true);
                leftProcessStreamReceiver = rightProcessStreamReceiver;
            } else if (streamDefinitionMap.containsKey(joinInputStream.getAllStreamIds().get(0))) {
                rightProcessStreamReceiver = new MultiProcessStreamReceiver(joinInputStream.getAllStreamIds().get(0), 2, latencyTracker, queryName, siddhiAppContext);
                leftProcessStreamReceiver = rightProcessStreamReceiver;
            } else {
                throw new SiddhiAppCreationException("Input of join is from static source " + leftInputStreamId + " and " + rightInputStreamId);
            }
        }
        SingleStreamRuntime leftStreamRuntime = SingleInputStreamParser.parseInputStream((SingleInputStream) joinInputStream.getLeftInputStream(), siddhiAppContext, executors, streamDefinitionMap, leftMetaStreamEvent.getEventType() != TABLE ? null : tableDefinitionMap, leftMetaStreamEvent.getEventType() != WINDOW ? null : windowDefinitionMap, leftMetaStreamEvent.getEventType() != AGGREGATE ? null : aggregationDefinitionMap, tableMap, leftMetaStreamEvent, leftProcessStreamReceiver, true, outputExpectsExpiredEvents, queryName);
        for (VariableExpressionExecutor variableExpressionExecutor : executors) {
            variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = 0;
        }
        int size = executors.size();
        SingleStreamRuntime rightStreamRuntime = SingleInputStreamParser.parseInputStream((SingleInputStream) joinInputStream.getRightInputStream(), siddhiAppContext, executors, streamDefinitionMap, rightMetaStreamEvent.getEventType() != TABLE ? null : tableDefinitionMap, rightMetaStreamEvent.getEventType() != WINDOW ? null : windowDefinitionMap, rightMetaStreamEvent.getEventType() != AGGREGATE ? null : aggregationDefinitionMap, tableMap, rightMetaStreamEvent, rightProcessStreamReceiver, true, outputExpectsExpiredEvents, queryName);
        for (int i = size; i < executors.size(); i++) {
            VariableExpressionExecutor variableExpressionExecutor = executors.get(i);
            variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = 1;
        }
        setStreamRuntimeProcessorChain(leftMetaStreamEvent, leftStreamRuntime, leftInputStreamId, tableMap, windowMap, aggregationMap, executors, outputExpectsExpiredEvents, queryName, joinInputStream.getWithin(), joinInputStream.getPer(), siddhiAppContext, joinInputStream.getLeftInputStream());
        setStreamRuntimeProcessorChain(rightMetaStreamEvent, rightStreamRuntime, rightInputStreamId, tableMap, windowMap, aggregationMap, executors, outputExpectsExpiredEvents, queryName, joinInputStream.getWithin(), joinInputStream.getPer(), siddhiAppContext, joinInputStream.getRightInputStream());
        MetaStateEvent metaStateEvent = new MetaStateEvent(2);
        metaStateEvent.addEvent(leftMetaStreamEvent);
        metaStateEvent.addEvent(rightMetaStreamEvent);
        switch(joinInputStream.getType()) {
            case FULL_OUTER_JOIN:
                leftOuterJoinProcessor = true;
                rightOuterJoinProcessor = true;
                break;
            case RIGHT_OUTER_JOIN:
                rightOuterJoinProcessor = true;
                break;
            case LEFT_OUTER_JOIN:
                leftOuterJoinProcessor = true;
                break;
        }
        JoinProcessor leftPreJoinProcessor = new JoinProcessor(true, true, leftOuterJoinProcessor, 0);
        JoinProcessor leftPostJoinProcessor = new JoinProcessor(true, false, leftOuterJoinProcessor, 0);
        FindableProcessor leftFindableProcessor = insertJoinProcessorsAndGetFindable(leftPreJoinProcessor, leftPostJoinProcessor, leftStreamRuntime, siddhiAppContext, outputExpectsExpiredEvents, queryName, joinInputStream.getLeftInputStream());
        JoinProcessor rightPreJoinProcessor = new JoinProcessor(false, true, rightOuterJoinProcessor, 1);
        JoinProcessor rightPostJoinProcessor = new JoinProcessor(false, false, rightOuterJoinProcessor, 1);
        FindableProcessor rightFindableProcessor = insertJoinProcessorsAndGetFindable(rightPreJoinProcessor, rightPostJoinProcessor, rightStreamRuntime, siddhiAppContext, outputExpectsExpiredEvents, queryName, joinInputStream.getRightInputStream());
        leftPreJoinProcessor.setFindableProcessor(rightFindableProcessor);
        leftPostJoinProcessor.setFindableProcessor(rightFindableProcessor);
        rightPreJoinProcessor.setFindableProcessor(leftFindableProcessor);
        rightPostJoinProcessor.setFindableProcessor(leftFindableProcessor);
        Expression compareCondition = joinInputStream.getOnCompare();
        if (compareCondition == null) {
            compareCondition = Expression.value(true);
        }
        MatchingMetaInfoHolder rightMatchingMetaInfoHolder = MatcherParser.constructMatchingMetaStateHolder(metaStateEvent, 0, rightMetaStreamEvent.getLastInputDefinition(), UNKNOWN_STATE);
        CompiledCondition leftCompiledCondition = rightFindableProcessor.compileCondition(compareCondition, rightMatchingMetaInfoHolder, siddhiAppContext, executors, tableMap, queryName);
        MatchingMetaInfoHolder leftMatchingMetaInfoHolder = MatcherParser.constructMatchingMetaStateHolder(metaStateEvent, 1, leftMetaStreamEvent.getLastInputDefinition(), UNKNOWN_STATE);
        CompiledCondition rightCompiledCondition = leftFindableProcessor.compileCondition(compareCondition, leftMatchingMetaInfoHolder, siddhiAppContext, executors, tableMap, queryName);
        if (joinInputStream.getTrigger() != JoinInputStream.EventTrigger.LEFT) {
            populateJoinProcessors(rightMetaStreamEvent, rightInputStreamId, rightPreJoinProcessor, rightPostJoinProcessor, rightCompiledCondition);
        }
        if (joinInputStream.getTrigger() != JoinInputStream.EventTrigger.RIGHT) {
            populateJoinProcessors(leftMetaStreamEvent, leftInputStreamId, leftPreJoinProcessor, leftPostJoinProcessor, leftCompiledCondition);
        }
        JoinStreamRuntime joinStreamRuntime = new JoinStreamRuntime(siddhiAppContext, metaStateEvent);
        joinStreamRuntime.addRuntime(leftStreamRuntime);
        joinStreamRuntime.addRuntime(rightStreamRuntime);
        return joinStreamRuntime;
    } catch (Throwable t) {
        ExceptionUtil.populateQueryContext(t, joinInputStream, siddhiAppContext);
        throw t;
    }
}
Also used : ProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver) MultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.MultiProcessStreamReceiver) FindableProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.FindableProcessor) SiddhiAppCreationException(org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException) SingleStreamRuntime(org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime) JoinStreamRuntime(org.ballerinalang.siddhi.core.query.input.stream.join.JoinStreamRuntime) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor) MultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.MultiProcessStreamReceiver) MetaStateEvent(org.ballerinalang.siddhi.core.event.state.MetaStateEvent) CompiledCondition(org.ballerinalang.siddhi.core.util.collection.operator.CompiledCondition) Expression(org.ballerinalang.siddhi.query.api.expression.Expression) SingleInputStream(org.ballerinalang.siddhi.query.api.execution.query.input.stream.SingleInputStream) MatchingMetaInfoHolder(org.ballerinalang.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) JoinProcessor(org.ballerinalang.siddhi.core.query.input.stream.join.JoinProcessor) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)

Example 3 with ProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver in project ballerina by ballerina-lang.

the class QueryParserHelper method initSingleStreamRuntime.

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

Example 4 with ProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver in project ballerina by ballerina-lang.

the class StateStreamRuntime method clone.

@Override
public StreamRuntime clone(String key) {
    StateStreamRuntime stateStreamRuntime = new StateStreamRuntime(siddhiAppContext, metaStateEvent);
    stateStreamRuntime.innerStateRuntime = this.innerStateRuntime.clone(key);
    for (SingleStreamRuntime singleStreamRuntime : stateStreamRuntime.getSingleStreamRuntimes()) {
        ProcessStreamReceiver processStreamReceiver = singleStreamRuntime.getProcessStreamReceiver();
        if (processStreamReceiver instanceof SequenceMultiProcessStreamReceiver) {
            ((SequenceMultiProcessStreamReceiver) processStreamReceiver).setStateStreamRuntime(stateStreamRuntime);
        } else if (processStreamReceiver instanceof SequenceSingleProcessStreamReceiver) {
            ((SequenceSingleProcessStreamReceiver) processStreamReceiver).setStateStreamRuntime(stateStreamRuntime);
        }
    }
    ((StreamPreStateProcessor) stateStreamRuntime.innerStateRuntime.getFirstProcessor()).setThisLastProcessor((StreamPostStateProcessor) stateStreamRuntime.innerStateRuntime.getLastProcessor());
    return stateStreamRuntime;
}
Also used : ProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver) SequenceMultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver) SequenceSingleProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver) SingleStreamRuntime(org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime) SequenceMultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver) SequenceSingleProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver)

Example 5 with ProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver in project ballerina by ballerina-lang.

the class SingleStreamRuntime method clone.

@Override
public StreamRuntime clone(String key) {
    ProcessStreamReceiver clonedProcessStreamReceiver = this.processStreamReceiver.clone(key);
    EntryValveProcessor entryValveProcessor = null;
    SchedulingProcessor schedulingProcessor;
    Processor clonedProcessorChain = null;
    if (processorChain != null) {
        if (!(processorChain instanceof QuerySelector || processorChain instanceof OutputRateLimiter)) {
            clonedProcessorChain = processorChain.cloneProcessor(key);
            if (clonedProcessorChain instanceof EntryValveProcessor) {
                entryValveProcessor = (EntryValveProcessor) clonedProcessorChain;
            }
        }
        Processor processor = processorChain.getNextProcessor();
        while (processor != null) {
            if (!(processor instanceof QuerySelector || processor instanceof OutputRateLimiter)) {
                Processor clonedProcessor = processor.cloneProcessor(key);
                clonedProcessorChain.setToLast(clonedProcessor);
                if (clonedProcessor instanceof EntryValveProcessor) {
                    entryValveProcessor = (EntryValveProcessor) clonedProcessor;
                } else if (clonedProcessor instanceof SchedulingProcessor) {
                    schedulingProcessor = (SchedulingProcessor) clonedProcessor;
                    schedulingProcessor.setScheduler(((SchedulingProcessor) processor).getScheduler().clone(key, entryValveProcessor));
                }
            }
            processor = processor.getNextProcessor();
        }
    }
    return new SingleStreamRuntime(clonedProcessStreamReceiver, clonedProcessorChain, metaComplexEvent);
}
Also used : ProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver) SchedulingProcessor(org.ballerinalang.siddhi.core.query.processor.SchedulingProcessor) Processor(org.ballerinalang.siddhi.core.query.processor.Processor) SchedulingProcessor(org.ballerinalang.siddhi.core.query.processor.SchedulingProcessor) OutputRateLimiter(org.ballerinalang.siddhi.core.query.output.ratelimit.OutputRateLimiter) QuerySelector(org.ballerinalang.siddhi.core.query.selector.QuerySelector)

Aggregations

ProcessStreamReceiver (org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver)8 MetaStateEvent (org.ballerinalang.siddhi.core.event.state.MetaStateEvent)3 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)3 SingleStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime)3 SiddhiAppCreationException (org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException)2 JoinProcessor (org.ballerinalang.siddhi.core.query.input.stream.join.JoinProcessor)2 StreamPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.StreamPreStateProcessor)2 SequenceMultiProcessStreamReceiver (org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver)2 SequenceSingleProcessStreamReceiver (org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver)2 Processor (org.ballerinalang.siddhi.core.query.processor.Processor)2 SchedulingProcessor (org.ballerinalang.siddhi.core.query.processor.SchedulingProcessor)2 SingleInputStream (org.ballerinalang.siddhi.query.api.execution.query.input.stream.SingleInputStream)2 HashMap (java.util.HashMap)1 AggregationRuntime (org.ballerinalang.siddhi.core.aggregation.AggregationRuntime)1 StateEventCloner (org.ballerinalang.siddhi.core.event.state.StateEventCloner)1 StreamEventCloner (org.ballerinalang.siddhi.core.event.stream.StreamEventCloner)1 StreamEventPool (org.ballerinalang.siddhi.core.event.stream.StreamEventPool)1 ComplexEventPopulater (org.ballerinalang.siddhi.core.event.stream.populater.ComplexEventPopulater)1 OperationNotSupportedException (org.ballerinalang.siddhi.core.exception.OperationNotSupportedException)1 VariableExpressionExecutor (org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor)1