use of io.siddhi.core.aggregation.persistedaggregation.QueuedCudStreamProcessor 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;
}
Aggregations