use of org.ballerinalang.siddhi.core.event.stream.populater.ComplexEventPopulater 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();
}
}
use of org.ballerinalang.siddhi.core.event.stream.populater.ComplexEventPopulater in project ballerina by ballerina-lang.
the class StoreQueryParser method constructStoreQueryRuntime.
private static StoreQueryRuntime constructStoreQueryRuntime(AggregationRuntime aggregation, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
int metaPosition;
metaStreamEvent.setEventType(EventType.AGGREGATE);
initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, metaStreamInfoHolder, variableExpressionExecutors, tableMap, queryName, siddhiAppContext);
metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
FindStoreQueryRuntime findStoreQueryRuntime = new FindStoreQueryRuntime(aggregation, compiledCondition, queryName, metaStreamEvent);
metaPosition = 1;
populateFindStoreQueryRuntime(findStoreQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
return findStoreQueryRuntime;
}
Aggregations