use of org.wso2.siddhi.core.event.state.MetaStateEvent in project siddhi by wso2.
the class StoreQueryParser method generateMatchingMetaInfoHolder.
private static MatchingMetaInfoHolder generateMatchingMetaInfoHolder(MetaStreamEvent metaStreamEvent, AbstractDefinition definition) {
MetaStateEvent metaStateEvent = new MetaStateEvent(1);
metaStateEvent.addEvent(metaStreamEvent);
return new MatchingMetaInfoHolder(metaStateEvent, -1, 0, definition, definition, 0);
}
use of org.wso2.siddhi.core.event.state.MetaStateEvent in project siddhi by wso2.
the class QueryParserHelper method updateVariablePosition.
public static void updateVariablePosition(MetaComplexEvent metaComplexEvent, List<VariableExpressionExecutor> variableExpressionExecutorList) {
for (VariableExpressionExecutor variableExpressionExecutor : variableExpressionExecutorList) {
int streamEventChainIndex = variableExpressionExecutor.getPosition()[STREAM_EVENT_CHAIN_INDEX];
if (streamEventChainIndex == HAVING_STATE) {
if (metaComplexEvent instanceof MetaStreamEvent) {
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = OUTPUT_DATA_INDEX;
} else {
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = STATE_OUTPUT_DATA_INDEX;
}
variableExpressionExecutor.getPosition()[STREAM_EVENT_CHAIN_INDEX] = UNKNOWN_STATE;
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_INDEX_IN_TYPE] = metaComplexEvent.getOutputStreamDefinition().getAttributeList().indexOf(variableExpressionExecutor.getAttribute());
continue;
} else if (metaComplexEvent instanceof MetaStreamEvent && streamEventChainIndex >= 1) {
// VariableExpressionExecutor on Event table
continue;
} else if (metaComplexEvent instanceof MetaStateEvent && streamEventChainIndex >= ((MetaStateEvent) metaComplexEvent).getMetaStreamEvents().length) {
// for VariableExpressionExecutor on Event table
continue;
}
MetaStreamEvent metaStreamEvent;
if (metaComplexEvent instanceof MetaStreamEvent) {
metaStreamEvent = (MetaStreamEvent) metaComplexEvent;
} else {
metaStreamEvent = ((MetaStateEvent) metaComplexEvent).getMetaStreamEvent(streamEventChainIndex);
}
if (metaStreamEvent.getOutputData().contains(variableExpressionExecutor.getAttribute())) {
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = OUTPUT_DATA_INDEX;
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_INDEX_IN_TYPE] = metaStreamEvent.getOutputData().indexOf(variableExpressionExecutor.getAttribute());
} else if (metaStreamEvent.getOnAfterWindowData().contains(variableExpressionExecutor.getAttribute())) {
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = ON_AFTER_WINDOW_DATA_INDEX;
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_INDEX_IN_TYPE] = metaStreamEvent.getOnAfterWindowData().indexOf(variableExpressionExecutor.getAttribute());
} else if (metaStreamEvent.getBeforeWindowData().contains(variableExpressionExecutor.getAttribute())) {
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = BEFORE_WINDOW_DATA_INDEX;
variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_INDEX_IN_TYPE] = metaStreamEvent.getBeforeWindowData().indexOf(variableExpressionExecutor.getAttribute());
}
}
}
use of org.wso2.siddhi.core.event.state.MetaStateEvent in project siddhi by wso2.
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();
}
}
use of org.wso2.siddhi.core.event.state.MetaStateEvent in project siddhi by wso2.
the class PartitionRuntime method addPartitionReceiver.
public void addPartitionReceiver(QueryRuntime queryRuntime, List<VariableExpressionExecutor> executors, MetaStateEvent metaEvent) {
Query query = queryRuntime.getQuery();
List<List<PartitionExecutor>> partitionExecutors = new StreamPartitioner(query.getInputStream(), partition, metaEvent, executors, siddhiAppContext, null).getPartitionExecutorLists();
if (queryRuntime.getStreamRuntime() instanceof SingleStreamRuntime) {
SingleInputStream singleInputStream = (SingleInputStream) query.getInputStream();
addPartitionReceiver(singleInputStream.getStreamId(), singleInputStream.isInnerStream(), metaEvent.getMetaStreamEvent(0), partitionExecutors.get(0));
} else if (queryRuntime.getStreamRuntime() instanceof JoinStreamRuntime) {
SingleInputStream leftSingleInputStream = (SingleInputStream) ((JoinInputStream) query.getInputStream()).getLeftInputStream();
addPartitionReceiver(leftSingleInputStream.getStreamId(), leftSingleInputStream.isInnerStream(), metaEvent.getMetaStreamEvent(0), partitionExecutors.get(0));
SingleInputStream rightSingleInputStream = (SingleInputStream) ((JoinInputStream) query.getInputStream()).getRightInputStream();
addPartitionReceiver(rightSingleInputStream.getStreamId(), rightSingleInputStream.isInnerStream(), metaEvent.getMetaStreamEvent(1), partitionExecutors.get(1));
} else if (queryRuntime.getStreamRuntime() instanceof StateStreamRuntime) {
StateElement stateElement = ((StateInputStream) query.getInputStream()).getStateElement();
addPartitionReceiverForStateElement(stateElement, metaEvent, partitionExecutors, 0);
}
}
use of org.wso2.siddhi.core.event.state.MetaStateEvent in project siddhi by wso2.
the class StreamPartitioner method createJoinInputStreamExecutors.
private void createJoinInputStreamExecutors(JoinInputStream inputStream, Partition partition, MetaStateEvent metaEvent, List<VariableExpressionExecutor> executors, SiddhiAppContext siddhiAppContext, String queryName) {
createExecutors(inputStream.getLeftInputStream(), partition, metaEvent.getMetaStreamEvent(0), executors, siddhiAppContext, queryName);
int size = executors.size();
for (VariableExpressionExecutor variableExpressionExecutor : executors) {
variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = 0;
}
createExecutors(inputStream.getRightInputStream(), partition, metaEvent.getMetaStreamEvent(1), executors, siddhiAppContext, queryName);
for (int i = size; i < executors.size(); i++) {
executors.get(i).getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX] = 1;
}
}
Aggregations