Search in sources :

Example 1 with SequenceSingleProcessStreamReceiver

use of org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver in project siddhi by wso2.

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

Example 2 with SequenceSingleProcessStreamReceiver

use of org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver in project siddhi by wso2.

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.wso2.siddhi.core.query.input.ProcessStreamReceiver) SequenceSingleProcessStreamReceiver(org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver) SequenceMultiProcessStreamReceiver(org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) SequenceMultiProcessStreamReceiver(org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver) SequenceSingleProcessStreamReceiver(org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver)

Aggregations

ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)2 SequenceMultiProcessStreamReceiver (org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceMultiProcessStreamReceiver)2 SequenceSingleProcessStreamReceiver (org.wso2.siddhi.core.query.input.stream.state.receiver.SequenceSingleProcessStreamReceiver)2 HashMap (java.util.HashMap)1 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)1 AbsentStreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)1 StateStreamRuntime (org.wso2.siddhi.core.query.input.stream.state.StateStreamRuntime)1 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)1 PatternMultiProcessStreamReceiver (org.wso2.siddhi.core.query.input.stream.state.receiver.PatternMultiProcessStreamReceiver)1 PatternSingleProcessStreamReceiver (org.wso2.siddhi.core.query.input.stream.state.receiver.PatternSingleProcessStreamReceiver)1 CountInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime)1 EveryInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime)1 InnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.InnerStateRuntime)1 LogicalInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.LogicalInnerStateRuntime)1 NextInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.NextInnerStateRuntime)1 StreamInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.StreamInnerStateRuntime)1 AbsentStreamStateElement (org.wso2.siddhi.query.api.execution.query.input.state.AbsentStreamStateElement)1 CountStateElement (org.wso2.siddhi.query.api.execution.query.input.state.CountStateElement)1 EveryStateElement (org.wso2.siddhi.query.api.execution.query.input.state.EveryStateElement)1 LogicalStateElement (org.wso2.siddhi.query.api.execution.query.input.state.LogicalStateElement)1