use of io.siddhi.core.query.processor.Processor in project siddhi by wso2.
the class QueryParser method parse.
/**
* Parse a query and return corresponding QueryRuntime.
*
* @param query query to be parsed.
* @param siddhiAppContext associated Siddhi app context.
* @param streamDefinitionMap keyvalue containing user given stream definitions.
* @param tableDefinitionMap keyvalue containing table definitions.
* @param windowDefinitionMap keyvalue containing window definition map.
* @param aggregationDefinitionMap keyvalue containing aggregation definition map.
* @param tableMap keyvalue containing event tables.
* @param aggregationMap keyvalue containing aggrigation runtimes.
* @param windowMap keyvalue containing event window map.
* @param lockSynchronizer Lock synchronizer for sync the lock across queries.
* @param queryIndex query index to identify unknown query by number
* @param partitioned is the query partitioned
* @param partitionId The ID of the partition
* @return queryRuntime
*/
public static QueryRuntimeImpl parse(Query query, SiddhiAppContext siddhiAppContext, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, Map<String, AggregationRuntime> aggregationMap, Map<String, Window> windowMap, LockSynchronizer lockSynchronizer, String queryIndex, boolean partitioned, String partitionId) {
List<VariableExpressionExecutor> executors = new ArrayList<>();
QueryRuntimeImpl queryRuntime;
Element nameElement = null;
LatencyTracker latencyTracker = null;
LockWrapper lockWrapper = null;
try {
nameElement = AnnotationHelper.getAnnotationElement("info", "name", query.getAnnotations());
String queryName;
if (nameElement != null) {
queryName = nameElement.getValue();
} else {
queryName = "query_" + queryIndex;
}
SiddhiQueryContext siddhiQueryContext = new SiddhiQueryContext(siddhiAppContext, queryName, partitionId);
siddhiQueryContext.setPartitioned(partitioned);
latencyTracker = QueryParserHelper.createLatencyTracker(siddhiAppContext, siddhiQueryContext.getName(), SiddhiConstants.METRIC_INFIX_QUERIES, null);
siddhiQueryContext.setLatencyTracker(latencyTracker);
OutputStream.OutputEventType outputEventType = query.getOutputStream().getOutputEventType();
if (query.getOutputRate() != null && query.getOutputRate() instanceof SnapshotOutputRate) {
if (outputEventType != OutputStream.OutputEventType.ALL_EVENTS) {
throw new SiddhiAppCreationException("As query '" + siddhiQueryContext.getName() + "' is performing snapshot rate limiting, it can only insert '" + OutputStream.OutputEventType.ALL_EVENTS + "' but it is inserting '" + outputEventType + "'!", query.getOutputStream().getQueryContextStartIndex(), query.getOutputStream().getQueryContextEndIndex());
}
}
siddhiQueryContext.setOutputEventType(outputEventType);
boolean outputExpectsExpiredEvents = false;
if (outputEventType != OutputStream.OutputEventType.CURRENT_EVENTS) {
outputExpectsExpiredEvents = true;
}
StreamRuntime streamRuntime = InputStreamParser.parse(query.getInputStream(), query, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, windowMap, aggregationMap, executors, outputExpectsExpiredEvents, siddhiQueryContext);
QuerySelector selector;
if (streamRuntime.getQuerySelector() != null) {
selector = streamRuntime.getQuerySelector();
} else {
selector = SelectorParser.parse(query.getSelector(), query.getOutputStream(), streamRuntime.getMetaComplexEvent(), tableMap, executors, SiddhiConstants.UNKNOWN_STATE, streamRuntime.getProcessingMode(), outputExpectsExpiredEvents, siddhiQueryContext);
}
boolean isWindow = query.getInputStream() instanceof JoinInputStream;
if (!isWindow && query.getInputStream() instanceof SingleInputStream) {
for (StreamHandler streamHandler : ((SingleInputStream) query.getInputStream()).getStreamHandlers()) {
if (streamHandler instanceof io.siddhi.query.api.execution.query.input.handler.Window) {
isWindow = true;
break;
}
}
}
Element synchronizedElement = AnnotationHelper.getAnnotationElement("synchronized", null, query.getAnnotations());
if (synchronizedElement != null) {
if (!("false".equalsIgnoreCase(synchronizedElement.getValue()))) {
// Query LockWrapper does not need a unique
lockWrapper = new LockWrapper("");
// id since it will
// not be passed to the LockSynchronizer.
// LockWrapper does not have a default lock
lockWrapper.setLock(new ReentrantLock());
}
} else {
if (isWindow || !(streamRuntime instanceof SingleStreamRuntime)) {
if (streamRuntime instanceof JoinStreamRuntime) {
// If at least one Window is involved in the join, use the LockWrapper of that window
// for the query as well.
// If join is between two EventWindows, sync the locks of the LockWrapper of those windows
// and use either of them for query.
MetaStateEvent metaStateEvent = (MetaStateEvent) streamRuntime.getMetaComplexEvent();
MetaStreamEvent[] metaStreamEvents = metaStateEvent.getMetaStreamEvents();
if (metaStreamEvents[0].getEventType() == EventType.WINDOW && metaStreamEvents[1].getEventType() == EventType.WINDOW) {
LockWrapper leftLockWrapper = windowMap.get(metaStreamEvents[0].getLastInputDefinition().getId()).getLock();
LockWrapper rightLockWrapper = windowMap.get(metaStreamEvents[1].getLastInputDefinition().getId()).getLock();
if (!leftLockWrapper.equals(rightLockWrapper)) {
// Sync the lock across both wrappers
lockSynchronizer.sync(leftLockWrapper, rightLockWrapper);
}
// Can use either leftLockWrapper or rightLockWrapper since both of them will hold the
// same lock internally
// If either of their lock is updated later, the other lock also will be update by the
// LockSynchronizer.
lockWrapper = leftLockWrapper;
} else if (metaStreamEvents[0].getEventType() == EventType.WINDOW) {
// Share the same wrapper as the query lock wrapper
lockWrapper = windowMap.get(metaStreamEvents[0].getLastInputDefinition().getId()).getLock();
} else if (metaStreamEvents[1].getEventType() == EventType.WINDOW) {
// Share the same wrapper as the query lock wrapper
lockWrapper = windowMap.get(metaStreamEvents[1].getLastInputDefinition().getId()).getLock();
} else {
// Join does not contain any Window
// Query LockWrapper does not need a unique
lockWrapper = new LockWrapper("");
// id since
// it will not be passed to the LockSynchronizer.
// LockWrapper does not have a default lock
lockWrapper.setLock(new ReentrantLock());
}
} else {
lockWrapper = new LockWrapper("");
lockWrapper.setLock(new ReentrantLock());
}
}
}
OutputRateLimiter outputRateLimiter = OutputParser.constructOutputRateLimiter(query.getOutputStream().getId(), query.getOutputRate(), query.getSelector().getGroupByList().size() != 0, isWindow, siddhiQueryContext);
if (outputRateLimiter instanceof WrappedSnapshotOutputRateLimiter) {
selector.setBatchingEnabled(false);
}
boolean groupBy = !query.getSelector().getGroupByList().isEmpty();
OutputCallback outputCallback = OutputParser.constructOutputCallback(query.getOutputStream(), streamRuntime.getMetaComplexEvent().getOutputStreamDefinition(), tableMap, windowMap, !(streamRuntime instanceof SingleStreamRuntime) || groupBy, siddhiQueryContext);
QueryParserHelper.reduceMetaComplexEvent(streamRuntime.getMetaComplexEvent());
QueryParserHelper.updateVariablePosition(streamRuntime.getMetaComplexEvent(), executors);
QueryParserHelper.initStreamRuntime(streamRuntime, streamRuntime.getMetaComplexEvent(), lockWrapper, siddhiQueryContext.getName());
// Update cache compile selection variable expression executors
if (streamRuntime instanceof JoinStreamRuntime) {
streamRuntime.getSingleStreamRuntimes().forEach((singleStreamRuntime -> {
Processor processorChain = singleStreamRuntime.getProcessorChain();
if (processorChain instanceof JoinProcessor) {
CompiledSelection compiledSelection = ((JoinProcessor) processorChain).getCompiledSelection();
if (compiledSelection instanceof AbstractQueryableRecordTable.CompiledSelectionWithCache) {
List<VariableExpressionExecutor> variableExpressionExecutors = ((AbstractQueryableRecordTable.CompiledSelectionWithCache) compiledSelection).getVariableExpressionExecutorsForQuerySelector();
QueryParserHelper.updateVariablePosition(streamRuntime.getMetaComplexEvent(), variableExpressionExecutors);
}
}
}));
}
selector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(streamRuntime.getMetaComplexEvent()));
queryRuntime = new QueryRuntimeImpl(query, streamRuntime, selector, outputRateLimiter, outputCallback, streamRuntime.getMetaComplexEvent(), siddhiQueryContext);
if (outputRateLimiter instanceof WrappedSnapshotOutputRateLimiter) {
selector.setBatchingEnabled(false);
((WrappedSnapshotOutputRateLimiter) outputRateLimiter).init(streamRuntime.getMetaComplexEvent().getOutputStreamDefinition().getAttributeList().size(), selector.getAttributeProcessorList(), streamRuntime.getMetaComplexEvent());
}
outputRateLimiter.init(lockWrapper, groupBy, siddhiQueryContext);
} catch (DuplicateDefinitionException e) {
if (nameElement != null) {
throw new DuplicateDefinitionException(e.getMessageWithOutContext() + ", when creating query " + nameElement.getValue(), e, e.getQueryContextStartIndex(), e.getQueryContextEndIndex(), siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString());
} else {
throw new DuplicateDefinitionException(e.getMessage(), e, e.getQueryContextStartIndex(), e.getQueryContextEndIndex(), siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString());
}
} catch (Throwable t) {
ExceptionUtil.populateQueryContext(t, query, siddhiAppContext);
throw t;
}
return queryRuntime;
}
use of io.siddhi.core.query.processor.Processor in project siddhi by wso2.
the class AggregationParser method initAggregateQueryExecutor.
private static Map<TimePeriod.Duration, Processor> initAggregateQueryExecutor(List<TimePeriod.Duration> aggregationDurations, Map<TimePeriod.Duration, List<ExpressionExecutor>> processExpressionExecutorsMap, StreamDefinition incomingOutputStreamDefinition, boolean isDistributed, String shardID, boolean isProcessingOnExternalTime, SiddhiQueryContext siddhiQueryContext, AggregationDefinition aggregationDefinition, ConfigManager configManager, Map<TimePeriod.Duration, Table> aggregationTables, List<Variable> groupByVariableList) {
Map<TimePeriod.Duration, Processor> cudProcessors = new LinkedHashMap<>();
String datasourceName = AnnotationHelper.getAnnotationElement(SiddhiConstants.NAMESPACE_STORE, "datasource", aggregationDefinition.getAnnotations()).getValue();
if (datasourceName == null || datasourceName.isEmpty()) {
throw new SiddhiAppCreationException("Datasource configuration must be provided inorder to use persisted " + "aggregation mode");
}
Database databaseType = getDatabaseType(configManager, datasourceName);
if (log.isDebugEnabled()) {
log.debug("Database type " + databaseType);
}
SiddhiAppContext cudSiddhiAppContext = new SiddhiAppContext();
SiddhiContext context = new SiddhiContext();
context.setConfigManager(configManager);
cudSiddhiAppContext.setSiddhiContext(context);
StringConstant datasource = new StringConstant(datasourceName);
ConstantExpressionExecutor datasourceExecutor = new ConstantExpressionExecutor(datasource.getValue(), Attribute.Type.STRING);
Expression[] streamHandler;
ExpressionExecutor[] cudStreamProcessorInputVariables;
if (isProcessingOnExternalTime) {
streamHandler = new Expression[7];
} else {
streamHandler = new Expression[5];
}
try {
DBAggregationQueryConfigurationEntry dbAggregationQueryConfigurationEntry = DBAggregationQueryUtil.lookupCurrentQueryConfigurationEntry(databaseType);
if (log.isDebugEnabled()) {
log.debug("CUD queries for aggregation " + aggregationDefinition.getId());
}
for (int i = aggregationDurations.size() - 1; i > 0; i--) {
if (aggregationDurations.get(i).ordinal() >= 3) {
if (log.isDebugEnabled()) {
log.debug(" Initializing cudProcessors for duration " + aggregationDurations.get(i));
}
String databaseSelectQuery = generateDatabaseQuery(processExpressionExecutorsMap.get(aggregationDurations.get(i)), dbAggregationQueryConfigurationEntry, incomingOutputStreamDefinition, isDistributed, shardID, isProcessingOnExternalTime, aggregationTables.get(aggregationDurations.get(i)), aggregationTables.get(aggregationDurations.get(i - 1)), groupByVariableList, aggregationDurations.get(i));
StringConstant selectQuery = new StringConstant(databaseSelectQuery);
if (log.isDebugEnabled()) {
log.debug(selectQuery);
}
ConstantExpressionExecutor selectExecutor = new ConstantExpressionExecutor(selectQuery.getValue(), Attribute.Type.STRING);
Map<Attribute, int[]> cudInputStreamAttributesMap = generateCUDInputStreamAttributes(isProcessingOnExternalTime);
if (isProcessingOnExternalTime) {
cudStreamProcessorInputVariables = new ExpressionExecutor[7];
} else {
cudStreamProcessorInputVariables = new ExpressionExecutor[5];
}
cudStreamProcessorInputVariables[0] = datasourceExecutor;
cudStreamProcessorInputVariables[1] = selectExecutor;
streamHandler[0] = datasource;
streamHandler[1] = selectQuery;
MetaStreamEvent metaStreamEvent = generateCUDMetaStreamEvent(isProcessingOnExternalTime);
StreamDefinition outputStream = new StreamDefinition();
VariableExpressionExecutor variableExpressionExecutor;
int j = 0;
for (Map.Entry<Attribute, int[]> entry : cudInputStreamAttributesMap.entrySet()) {
Attribute attribute = entry.getKey();
Variable timestampVariable = new Variable(attribute.getName());
for (int position : entry.getValue()) {
streamHandler[position + 2] = timestampVariable;
variableExpressionExecutor = new VariableExpressionExecutor(attribute, 0, 0);
variableExpressionExecutor.setPosition(new int[] { 2, j });
cudStreamProcessorInputVariables[position + 2] = variableExpressionExecutor;
}
outputStream.attribute(attribute.getName(), attribute.getType());
j++;
}
StreamFunction cudStreamFunction = new StreamFunction(NAMESPACE_RDBMS, FUNCTION_NAME_CUD, streamHandler);
cudProcessors.put(aggregationDurations.get(i), getCudProcessor(cudStreamFunction, siddhiQueryContext, metaStreamEvent, cudStreamProcessorInputVariables, aggregationDurations.get(i)));
}
}
return cudProcessors;
} catch (CannotLoadConfigurationException e) {
throw new SiddhiAppCreationException("Error occurred while initializing the persisted incremental " + "aggregation. Could not load the db quires for database type " + databaseType);
}
}
use of io.siddhi.core.query.processor.Processor in project siddhi by wso2.
the class AggregationParser method buildIncrementalExecutors.
private static Map<TimePeriod.Duration, Executor> buildIncrementalExecutors(MetaStreamEvent processedMetaStreamEvent, Map<TimePeriod.Duration, List<ExpressionExecutor>> processExpressionExecutorsMap, Map<TimePeriod.Duration, GroupByKeyGenerator> groupByKeyGeneratorList, List<TimePeriod.Duration> incrementalDurations, Map<TimePeriod.Duration, Table> aggregationTables, SiddhiQueryContext siddhiQueryContext, String aggregatorName, ExpressionExecutor shouldUpdateTimestamp, String timeZone, boolean isPersistedAggregation, StreamDefinition incomingOutputStreamDefinition, boolean isDistributed, String shardId, boolean isProcessingOnExternalTime, AggregationDefinition aggregationDefinition, ConfigManager configManager, List<Variable> groupByVariableList, boolean isReadOnly) {
Map<TimePeriod.Duration, Executor> incrementalExecutorMap = new HashMap<>();
Map<TimePeriod.Duration, Processor> cudProcessors = new HashMap<>();
// Create incremental executors
Executor child;
Executor root = null;
if (isPersistedAggregation) {
if (!isReadOnly) {
cudProcessors = initAggregateQueryExecutor(incrementalDurations, processExpressionExecutorsMap, incomingOutputStreamDefinition, isDistributed, shardId, isProcessingOnExternalTime, siddhiQueryContext, aggregationDefinition, configManager, aggregationTables, groupByVariableList);
}
CudStreamProcessorQueueManager queueManager = new CudStreamProcessorQueueManager();
// initialize cud stream processor queue
LinkedBlockingQueue<QueuedCudStreamProcessor> cudStreamProcessorQueue = queueManager.initializeAndGetCudStreamProcessorQueue();
siddhiQueryContext.getSiddhiAppContext().getExecutorService().execute(queueManager);
for (int i = incrementalDurations.size() - 1; i >= 0; i--) {
// Base incremental expression executors created using new meta
// Add an object to aggregationTable map inorder fill up the missing durations
aggregationTables.putIfAbsent(incrementalDurations.get(i), null);
boolean isRoot = i == 0;
child = root;
TimePeriod.Duration duration = incrementalDurations.get(i);
Executor incrementalExecutor;
if (duration == TimePeriod.Duration.SECONDS || duration == TimePeriod.Duration.MINUTES || duration == TimePeriod.Duration.HOURS) {
incrementalExecutor = new IncrementalExecutor(aggregatorName, duration, processExpressionExecutorsMap.get(duration), shouldUpdateTimestamp, groupByKeyGeneratorList.get(duration), isRoot, aggregationTables.get(duration), child, siddhiQueryContext, processedMetaStreamEvent, timeZone, duration.equals(TimePeriod.Duration.HOURS));
} else {
incrementalExecutor = new PersistedIncrementalExecutor(aggregatorName, duration, processExpressionExecutorsMap.get(duration), child, siddhiQueryContext, generateCUDMetaStreamEvent(isProcessingOnExternalTime), timeZone, cudProcessors.get(duration), cudStreamProcessorQueue);
}
incrementalExecutorMap.put(duration, incrementalExecutor);
root = incrementalExecutor;
}
} else {
for (int i = incrementalDurations.size() - 1; i >= 0; i--) {
// Base incremental expression executors created using new meta
boolean isRoot = i == 0;
child = root;
TimePeriod.Duration duration = incrementalDurations.get(i);
IncrementalExecutor incrementalExecutor = new IncrementalExecutor(aggregatorName, duration, processExpressionExecutorsMap.get(duration), shouldUpdateTimestamp, groupByKeyGeneratorList.get(duration), isRoot, aggregationTables.get(duration), child, siddhiQueryContext, processedMetaStreamEvent, timeZone, false);
incrementalExecutorMap.put(duration, incrementalExecutor);
root = incrementalExecutor;
}
}
return incrementalExecutorMap;
}
use of io.siddhi.core.query.processor.Processor in project siddhi by wso2.
the class JoinInputStreamParser method insertJoinProcessorsAndGetFindable.
private static FindableProcessor insertJoinProcessorsAndGetFindable(JoinProcessor preJoinProcessor, JoinProcessor postJoinProcessor, SingleStreamRuntime streamRuntime, boolean outputExpectsExpiredEvents, InputStream inputStream, SiddhiQueryContext siddhiQueryContext) {
Processor lastProcessor = streamRuntime.getProcessorChain();
Processor prevLastProcessor = null;
boolean containFindable = false;
if (lastProcessor != null) {
containFindable = lastProcessor instanceof FindableProcessor;
while (lastProcessor.getNextProcessor() != null) {
prevLastProcessor = lastProcessor;
lastProcessor = lastProcessor.getNextProcessor();
if (!containFindable) {
containFindable = lastProcessor instanceof FindableProcessor;
}
}
}
if (!containFindable) {
try {
WindowProcessor windowProcessor = new EmptyWindowProcessor();
ExpressionExecutor[] expressionExecutors = new ExpressionExecutor[1];
expressionExecutors[0] = new ConstantExpressionExecutor(0, Attribute.Type.INT);
ConfigReader configReader = siddhiQueryContext.getSiddhiContext().getConfigManager().generateConfigReader("", "lengthBatch");
windowProcessor.initProcessor(((MetaStreamEvent) streamRuntime.getMetaComplexEvent()), expressionExecutors, configReader, outputExpectsExpiredEvents, true, false, inputStream, siddhiQueryContext);
if (lastProcessor != null) {
prevLastProcessor = lastProcessor;
prevLastProcessor.setNextProcessor(windowProcessor);
lastProcessor = windowProcessor;
} else {
lastProcessor = windowProcessor;
}
} catch (Throwable t) {
throw new SiddhiAppCreationException(t);
}
}
if (lastProcessor instanceof FindableProcessor) {
if (prevLastProcessor != null) {
prevLastProcessor.setNextProcessor(preJoinProcessor);
} else {
streamRuntime.setProcessorChain(preJoinProcessor);
}
preJoinProcessor.setNextProcessor(lastProcessor);
lastProcessor.setNextProcessor(postJoinProcessor);
return (FindableProcessor) lastProcessor;
} else {
throw new OperationNotSupportedException("Stream " + ((MetaStreamEvent) streamRuntime.getMetaComplexEvent()).getLastInputDefinition().getId() + "'s last processor " + lastProcessor.getClass().getCanonicalName() + " is not an instance of " + FindableProcessor.class.getCanonicalName() + " hence join cannot be proceed");
}
}
use of io.siddhi.core.query.processor.Processor in project siddhi by wso2.
the class SingleInputStreamParser method parseInputStream.
/**
* Parse single InputStream and return SingleStreamRuntime
*
* @param inputStream single input stream to be parsed
* @param variableExpressionExecutors List to hold VariableExpressionExecutors to update after query parsing
* @param streamDefinitionMap Stream Definition Map
* @param tableDefinitionMap Table Definition Map
* @param windowDefinitionMap window definition map
* @param aggregationDefinitionMap aggregation definition map
* @param tableMap Table Map
* @param metaComplexEvent MetaComplexEvent
* @param processStreamReceiver ProcessStreamReceiver
* @param supportsBatchProcessing supports batch processing
* @param outputExpectsExpiredEvents is expired events sent as output
* @param findToBeExecuted find will be executed in the steam stores
* @param multiValue event has the possibility to produce multiple values
* @param siddhiQueryContext @return SingleStreamRuntime
*/
public static SingleStreamRuntime parseInputStream(SingleInputStream inputStream, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, MetaComplexEvent metaComplexEvent, ProcessStreamReceiver processStreamReceiver, boolean supportsBatchProcessing, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, boolean multiValue, SiddhiQueryContext siddhiQueryContext) {
Processor processor = null;
EntryValveProcessor entryValveProcessor = null;
ProcessingMode processingMode = ProcessingMode.BATCH;
boolean first = true;
MetaStreamEvent metaStreamEvent;
if (metaComplexEvent instanceof MetaStateEvent) {
metaStreamEvent = new MetaStreamEvent();
((MetaStateEvent) metaComplexEvent).addEvent(metaStreamEvent);
initMetaStreamEvent(inputStream, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, multiValue, metaStreamEvent);
} else {
metaStreamEvent = (MetaStreamEvent) metaComplexEvent;
initMetaStreamEvent(inputStream, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, multiValue, metaStreamEvent);
}
// A window cannot be defined for a window stream
if (!inputStream.getStreamHandlers().isEmpty() && windowDefinitionMap != null && windowDefinitionMap.containsKey(inputStream.getStreamId())) {
for (StreamHandler handler : inputStream.getStreamHandlers()) {
if (handler instanceof Window) {
throw new OperationNotSupportedException("Cannot create " + ((Window) handler).getName() + " " + "window for the window stream " + inputStream.getStreamId());
}
}
}
if (!inputStream.getStreamHandlers().isEmpty()) {
for (StreamHandler handler : inputStream.getStreamHandlers()) {
Processor currentProcessor = generateProcessor(handler, metaComplexEvent, variableExpressionExecutors, tableMap, supportsBatchProcessing, outputExpectsExpiredEvents, findToBeExecuted, siddhiQueryContext);
if (currentProcessor instanceof SchedulingProcessor) {
if (entryValveProcessor == null) {
entryValveProcessor = new EntryValveProcessor(siddhiQueryContext.getSiddhiAppContext());
if (first) {
processor = entryValveProcessor;
first = false;
} else {
processor.setToLast(entryValveProcessor);
}
}
Scheduler scheduler = SchedulerParser.parse(entryValveProcessor, siddhiQueryContext);
((SchedulingProcessor) currentProcessor).setScheduler(scheduler);
}
if (currentProcessor instanceof AbstractStreamProcessor) {
processingMode = ProcessingMode.findUpdatedProcessingMode(processingMode, ((AbstractStreamProcessor) currentProcessor).getProcessingMode());
}
if (first) {
processor = currentProcessor;
first = false;
} else {
processor.setToLast(currentProcessor);
}
}
}
metaStreamEvent.initializeOnAfterWindowData();
return new SingleStreamRuntime(processStreamReceiver, processor, processingMode, metaComplexEvent);
}
Aggregations