Search in sources :

Example 1 with SequenceMultiProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver 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 2 with SequenceMultiProcessStreamReceiver

use of org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver in project ballerina by ballerina-lang.

the class StateInputStreamParser method parseInputStream.

public static StateStreamRuntime parseInputStream(StateInputStream stateInputStream, SiddhiAppContext siddhiAppContext, MetaStateEvent metaStateEvent, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, List<VariableExpressionExecutor> variableExpressionExecutors, LatencyTracker latencyTracker, String queryName) {
    Map<String, ProcessStreamReceiver> processStreamReceiverMap = new HashMap<String, ProcessStreamReceiver>();
    StateStreamRuntime stateStreamRuntime = new StateStreamRuntime(siddhiAppContext, metaStateEvent);
    String defaultLockKey = "";
    for (String streamId : stateInputStream.getAllStreamIds()) {
        int streamCount = stateInputStream.getStreamCount(streamId);
        if (streamCount == 1) {
            if (stateInputStream.getStateType() == StateInputStream.Type.SEQUENCE) {
                processStreamReceiverMap.put(streamId, new SequenceSingleProcessStreamReceiver(streamId, stateStreamRuntime, defaultLockKey, latencyTracker, queryName, siddhiAppContext));
            } else {
                processStreamReceiverMap.put(streamId, new PatternSingleProcessStreamReceiver(streamId, defaultLockKey, latencyTracker, queryName, siddhiAppContext));
            }
        } else {
            if (stateInputStream.getStateType() == StateInputStream.Type.SEQUENCE) {
                processStreamReceiverMap.put(streamId, new SequenceMultiProcessStreamReceiver(streamId, streamCount, stateStreamRuntime, latencyTracker, queryName, siddhiAppContext));
            } else {
                processStreamReceiverMap.put(streamId, new PatternMultiProcessStreamReceiver(streamId, streamCount, latencyTracker, queryName, siddhiAppContext));
            }
        }
    }
    StateElement stateElement = stateInputStream.getStateElement();
    InnerStateRuntime innerStateRuntime = parse(stateElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, siddhiAppContext, variableExpressionExecutors, processStreamReceiverMap, null, null, stateInputStream.getStateType(), new ArrayList<Map.Entry<Long, Set<Integer>>>(), latencyTracker, queryName);
    stateStreamRuntime.setInnerStateRuntime(innerStateRuntime);
    ((StreamPreStateProcessor) innerStateRuntime.getFirstProcessor()).setThisLastProcessor((StreamPostStateProcessor) 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) PatternMultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.PatternMultiProcessStreamReceiver) PatternSingleProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.PatternSingleProcessStreamReceiver) PatternSingleProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.PatternSingleProcessStreamReceiver) HashMap(java.util.HashMap) EveryStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement) LogicalStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.LogicalStateElement) StateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement) AbsentStreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement) NextStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.NextStateElement) CountStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement) StreamStateElement(org.ballerinalang.siddhi.query.api.execution.query.input.state.StreamStateElement) AbsentStreamPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor) StreamPreStateProcessor(org.ballerinalang.siddhi.core.query.input.stream.state.StreamPreStateProcessor) SequenceSingleProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver) SequenceMultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver) PatternMultiProcessStreamReceiver(org.ballerinalang.siddhi.core.query.input.stream.state.receiver.PatternMultiProcessStreamReceiver) InnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.InnerStateRuntime) CountInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime) LogicalInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.LogicalInnerStateRuntime) StreamInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.StreamInnerStateRuntime) EveryInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime) NextInnerStateRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.runtime.NextInnerStateRuntime) StateStreamRuntime(org.ballerinalang.siddhi.core.query.input.stream.state.StateStreamRuntime)

Aggregations

ProcessStreamReceiver (org.ballerinalang.siddhi.core.query.input.ProcessStreamReceiver)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 HashMap (java.util.HashMap)1 SingleStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime)1 AbsentStreamPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)1 StateStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.StateStreamRuntime)1 StreamPreStateProcessor (org.ballerinalang.siddhi.core.query.input.stream.state.StreamPreStateProcessor)1 PatternMultiProcessStreamReceiver (org.ballerinalang.siddhi.core.query.input.stream.state.receiver.PatternMultiProcessStreamReceiver)1 PatternSingleProcessStreamReceiver (org.ballerinalang.siddhi.core.query.input.stream.state.receiver.PatternSingleProcessStreamReceiver)1 CountInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime)1 EveryInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime)1 InnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.InnerStateRuntime)1 LogicalInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.LogicalInnerStateRuntime)1 NextInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.NextInnerStateRuntime)1 StreamInnerStateRuntime (org.ballerinalang.siddhi.core.query.input.stream.state.runtime.StreamInnerStateRuntime)1 AbsentStreamStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)1 CountStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.CountStateElement)1 EveryStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.EveryStateElement)1 LogicalStateElement (org.ballerinalang.siddhi.query.api.execution.query.input.state.LogicalStateElement)1