Program: 28781
Project: 28781
Buggy source:
public static AggregationRuntime parse(AggregationDefinition aggregationDefinition,SiddhiAppContext siddhiAppContext,Map<String,AbstractDefinition> streamDefinitionMap,Map<String,AbstractDefinition> tableDefinitionMap,Map<String,AbstractDefinition> windowDefinitionMap,Map<String,AbstractDefinition> aggregationDefinitionMap,Map<String,Table> tableMap,Map<String,Window> windowMap,Map<String,AggregationRuntime> aggregationMap,SiddhiAppRuntimeBuilder siddhiAppRuntimeBuilder){
  if (aggregationDefinition == null) {
    throw new SiddhiAppCreationException("String_Node_Str" + "String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str");
  }
  if (aggregationDefinition.getTimePeriod() == null) {
    throw new SiddhiAppCreationException("String_Node_Str" + aggregationDefinition.getId() + "String_Node_Str"+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",aggregationDefinition.getQueryContextStartIndex(),aggregationDefinition.getQueryContextEndIndex());
  }
  if (aggregationDefinition.getSelector() == null) {
    throw new SiddhiAppCreationException("String_Node_Str" + aggregationDefinition.getId() + "String_Node_Str"+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",aggregationDefinition.getQueryContextStartIndex(),aggregationDefinition.getQueryContextEndIndex());
  }
  try {
    List<VariableExpressionExecutor> incomingVariableExpressionExecutors=new ArrayList<>();
    siddhiAppContext.getSiddhiContext().getSiddhiExtensions().put("String_Node_Str",IncrementalWithinTimeFunctionExecutor.class);
    siddhiAppContext.getSiddhiContext().getSiddhiExtensions().put("String_Node_Str",IncrementalUnixTimeFunctionExecutor.class);
    siddhiAppContext.getSiddhiContext().getSiddhiExtensions().put("String_Node_Str",IncrementalTimeGetTimeZone.class);
    String aggregatorName=aggregationDefinition.getId();
    LatencyTracker latencyTracker=QueryParserHelper.getLatencyTracker(siddhiAppContext,aggregatorName,SiddhiConstants.METRIC_INFIX_AGGRIGATIONS);
    StreamRuntime streamRuntime=InputStreamParser.parse(aggregationDefinition.getBasicSingleInputStream(),siddhiAppContext,streamDefinitionMap,tableDefinitionMap,windowDefinitionMap,aggregationDefinitionMap,tableMap,windowMap,aggregationMap,incomingVariableExpressionExecutors,latencyTracker,false,aggregatorName);
    MetaStreamEvent incomingMetaStreamEvent=(MetaStreamEvent)streamRuntime.getMetaComplexEvent();
    incomingMetaStreamEvent.initializeAfterWindowData();
    List<ExpressionExecutor> incomingExpressionExecutors=new ArrayList<>();
    List<IncrementalAttributeAggregator> incrementalAttributeAggregators=new ArrayList<>();
    List<Variable> groupByVariableList=aggregationDefinition.getSelector().getGroupByList();
    boolean isProcessingOnExternalTime=aggregationDefinition.getAggregateAttribute() != null;
    List<Expression> outputExpressions=new ArrayList<>();
    List<ExpressionExecutor> outputExpressionExecutors=new ArrayList<>();
    populateIncomingAggregatorsAndExecutors(aggregationDefinition,siddhiAppContext,tableMap,incomingVariableExpressionExecutors,aggregatorName,incomingMetaStreamEvent,incomingExpressionExecutors,incrementalAttributeAggregators,groupByVariableList,outputExpressions);
    int baseAggregatorBeginIndex=incomingMetaStreamEvent.getOutputData().size();
    List<Expression> finalBaseAggregators=getFinalBaseAggregators(siddhiAppContext,tableMap,incomingVariableExpressionExecutors,aggregatorName,incomingMetaStreamEvent,incomingExpressionExecutors,incrementalAttributeAggregators);
    StreamDefinition incomingOutputStreamDefinition=StreamDefinition.id("String_Node_Str");
    incomingOutputStreamDefinition.setQueryContextStartIndex(aggregationDefinition.getQueryContextStartIndex());
    incomingOutputStreamDefinition.setQueryContextEndIndex(aggregationDefinition.getQueryContextEndIndex());
    MetaStreamEvent processedMetaStreamEvent=new MetaStreamEvent();
    for (    Attribute attribute : incomingMetaStreamEvent.getOutputData()) {
      incomingOutputStreamDefinition.attribute(attribute.getName(),attribute.getType());
      processedMetaStreamEvent.addOutputData(attribute);
    }
    incomingMetaStreamEvent.setOutputDefinition(incomingOutputStreamDefinition);
    processedMetaStreamEvent.addInputDefinition(incomingOutputStreamDefinition);
    processedMetaStreamEvent.setOutputDefinition(incomingOutputStreamDefinition);
    List<VariableExpressionExecutor> processVariableExpressionExecutors=new ArrayList<>();
    boolean groupBy=aggregationDefinition.getSelector().getGroupByList().size() != 0;
    List<ExpressionExecutor> processExpressionExecutors=constructProcessExpressionExecutors(siddhiAppContext,tableMap,aggregatorName,baseAggregatorBeginIndex,finalBaseAggregators,incomingOutputStreamDefinition,processedMetaStreamEvent,processVariableExpressionExecutors,groupBy);
    outputExpressionExecutors.addAll(outputExpressions.stream().map(expression -> ExpressionParser.parseExpression(expression,processedMetaStreamEvent,0,tableMap,processVariableExpressionExecutors,siddhiAppContext,groupBy,0,aggregatorName)).collect(Collectors.toList()));
    GroupByKeyGenerator groupByKeyGenerator=null;
    if (groupBy) {
      groupByKeyGenerator=new GroupByKeyGenerator(groupByVariableList,processedMetaStreamEvent,tableMap,processVariableExpressionExecutors,siddhiAppContext,aggregatorName);
    }
    int bufferSize=0;
    Element element=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_BUFFER_SIZE,null,aggregationDefinition.getAnnotations());
    if (element != null) {
      bufferSize=Integer.parseInt(element.getValue());
    }
    EntryValveExecutor entryValveExecutor=new EntryValveExecutor(siddhiAppContext);
    LockWrapper lockWrapper=new LockWrapper(aggregatorName);
    lockWrapper.setLock(new ReentrantLock());
    Scheduler scheduler=SchedulerParser.parse(siddhiAppContext.getScheduledExecutorService(),entryValveExecutor,siddhiAppContext);
    scheduler.init(lockWrapper,aggregatorName);
    scheduler.setStreamEventPool(new StreamEventPool(processedMetaStreamEvent,10));
    QueryParserHelper.reduceMetaComplexEvent(incomingMetaStreamEvent);
    QueryParserHelper.reduceMetaComplexEvent(processedMetaStreamEvent);
    QueryParserHelper.updateVariablePosition(incomingMetaStreamEvent,incomingVariableExpressionExecutors);
    QueryParserHelper.updateVariablePosition(processedMetaStreamEvent,processVariableExpressionExecutors);
    List<TimePeriod.Duration> incrementalDurations=getSortedPeriods(aggregationDefinition.getTimePeriod());
    Map<TimePeriod.Duration,Table> aggregationTables=initDefaultTables(aggregatorName,incrementalDurations,processedMetaStreamEvent.getOutputStreamDefinition(),siddhiAppRuntimeBuilder,aggregationDefinition.getAnnotations(),groupByVariableList);
    Map<TimePeriod.Duration,IncrementalExecutor> incrementalExecutorMap=buildIncrementalExecutors(isProcessingOnExternalTime,processedMetaStreamEvent,processExpressionExecutors,groupByKeyGenerator,bufferSize,incrementalDurations,aggregationTables);
    IncrementalExecutor rootIncrementalExecutor=incrementalExecutorMap.get(incrementalDurations.get(0));
    rootIncrementalExecutor.setScheduler(scheduler);
    entryValveExecutor.setNextExecutor(rootIncrementalExecutor);
    QueryParserHelper.initStreamRuntime(streamRuntime,incomingMetaStreamEvent,lockWrapper,aggregatorName);
    streamRuntime.setCommonProcessor(new IncrementalAggregationProcessor(rootIncrementalExecutor,incomingExpressionExecutors,processedMetaStreamEvent));
    List<ExpressionExecutor> baseExecutors=cloneExpressionExecutors(processExpressionExecutors);
    ExpressionExecutor timestampExecutor=baseExecutors.remove(0);
    return new AggregationRuntime(aggregationDefinition,incrementalExecutorMap,aggregationTables,((SingleStreamRuntime)streamRuntime),entryValveExecutor,incrementalDurations,siddhiAppContext,baseExecutors,timestampExecutor,processedMetaStreamEvent,outputExpressionExecutors);
  }
 catch (  Throwable t) {
    ExceptionUtil.populateQueryContext(t,aggregationDefinition,siddhiAppContext);
    throw t;
  }
}

Fixed version (ground truth):
public static AggregationRuntime parse(AggregationDefinition aggregationDefinition,SiddhiAppContext siddhiAppContext,Map<String,AbstractDefinition> streamDefinitionMap,Map<String,AbstractDefinition> tableDefinitionMap,Map<String,AbstractDefinition> windowDefinitionMap,Map<String,AbstractDefinition> aggregationDefinitionMap,Map<String,Table> tableMap,Map<String,Window> windowMap,Map<String,AggregationRuntime> aggregationMap,SiddhiAppRuntimeBuilder siddhiAppRuntimeBuilder){
  if (aggregationDefinition == null) {
    throw new SiddhiAppCreationException("String_Node_Str" + "String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str");
  }
  if (aggregationDefinition.getTimePeriod() == null) {
    throw new SiddhiAppCreationException("String_Node_Str" + aggregationDefinition.getId() + "String_Node_Str"+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",aggregationDefinition.getQueryContextStartIndex(),aggregationDefinition.getQueryContextEndIndex());
  }
  if (aggregationDefinition.getSelector() == null) {
    throw new SiddhiAppCreationException("String_Node_Str" + aggregationDefinition.getId() + "String_Node_Str"+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",aggregationDefinition.getQueryContextStartIndex(),aggregationDefinition.getQueryContextEndIndex());
  }
  try {
    List<VariableExpressionExecutor> incomingVariableExpressionExecutors=new ArrayList<>();
    String aggregatorName=aggregationDefinition.getId();
    LatencyTracker latencyTracker=QueryParserHelper.getLatencyTracker(siddhiAppContext,aggregatorName,SiddhiConstants.METRIC_INFIX_AGGRIGATIONS);
    StreamRuntime streamRuntime=InputStreamParser.parse(aggregationDefinition.getBasicSingleInputStream(),siddhiAppContext,streamDefinitionMap,tableDefinitionMap,windowDefinitionMap,aggregationDefinitionMap,tableMap,windowMap,aggregationMap,incomingVariableExpressionExecutors,latencyTracker,false,aggregatorName);
    MetaStreamEvent incomingMetaStreamEvent=(MetaStreamEvent)streamRuntime.getMetaComplexEvent();
    incomingMetaStreamEvent.initializeAfterWindowData();
    List<ExpressionExecutor> incomingExpressionExecutors=new ArrayList<>();
    List<IncrementalAttributeAggregator> incrementalAttributeAggregators=new ArrayList<>();
    List<Variable> groupByVariableList=aggregationDefinition.getSelector().getGroupByList();
    boolean isProcessingOnExternalTime=aggregationDefinition.getAggregateAttribute() != null;
    List<Expression> outputExpressions=new ArrayList<>();
    List<ExpressionExecutor> outputExpressionExecutors=new ArrayList<>();
    populateIncomingAggregatorsAndExecutors(aggregationDefinition,siddhiAppContext,tableMap,incomingVariableExpressionExecutors,aggregatorName,incomingMetaStreamEvent,incomingExpressionExecutors,incrementalAttributeAggregators,groupByVariableList,outputExpressions);
    int baseAggregatorBeginIndex=incomingMetaStreamEvent.getOutputData().size();
    List<Expression> finalBaseAggregators=getFinalBaseAggregators(siddhiAppContext,tableMap,incomingVariableExpressionExecutors,aggregatorName,incomingMetaStreamEvent,incomingExpressionExecutors,incrementalAttributeAggregators);
    StreamDefinition incomingOutputStreamDefinition=StreamDefinition.id("String_Node_Str");
    incomingOutputStreamDefinition.setQueryContextStartIndex(aggregationDefinition.getQueryContextStartIndex());
    incomingOutputStreamDefinition.setQueryContextEndIndex(aggregationDefinition.getQueryContextEndIndex());
    MetaStreamEvent processedMetaStreamEvent=new MetaStreamEvent();
    for (    Attribute attribute : incomingMetaStreamEvent.getOutputData()) {
      incomingOutputStreamDefinition.attribute(attribute.getName(),attribute.getType());
      processedMetaStreamEvent.addOutputData(attribute);
    }
    incomingMetaStreamEvent.setOutputDefinition(incomingOutputStreamDefinition);
    processedMetaStreamEvent.addInputDefinition(incomingOutputStreamDefinition);
    processedMetaStreamEvent.setOutputDefinition(incomingOutputStreamDefinition);
    List<VariableExpressionExecutor> processVariableExpressionExecutors=new ArrayList<>();
    boolean groupBy=aggregationDefinition.getSelector().getGroupByList().size() != 0;
    List<ExpressionExecutor> processExpressionExecutors=constructProcessExpressionExecutors(siddhiAppContext,tableMap,aggregatorName,baseAggregatorBeginIndex,finalBaseAggregators,incomingOutputStreamDefinition,processedMetaStreamEvent,processVariableExpressionExecutors,groupBy);
    outputExpressionExecutors.addAll(outputExpressions.stream().map(expression -> ExpressionParser.parseExpression(expression,processedMetaStreamEvent,0,tableMap,processVariableExpressionExecutors,siddhiAppContext,groupBy,0,aggregatorName)).collect(Collectors.toList()));
    GroupByKeyGenerator groupByKeyGenerator=null;
    if (groupBy) {
      groupByKeyGenerator=new GroupByKeyGenerator(groupByVariableList,processedMetaStreamEvent,tableMap,processVariableExpressionExecutors,siddhiAppContext,aggregatorName);
    }
    int bufferSize=0;
    Element element=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_BUFFER_SIZE,null,aggregationDefinition.getAnnotations());
    if (element != null) {
      bufferSize=Integer.parseInt(element.getValue());
    }
    EntryValveExecutor entryValveExecutor=new EntryValveExecutor(siddhiAppContext);
    LockWrapper lockWrapper=new LockWrapper(aggregatorName);
    lockWrapper.setLock(new ReentrantLock());
    Scheduler scheduler=SchedulerParser.parse(siddhiAppContext.getScheduledExecutorService(),entryValveExecutor,siddhiAppContext);
    scheduler.init(lockWrapper,aggregatorName);
    scheduler.setStreamEventPool(new StreamEventPool(processedMetaStreamEvent,10));
    QueryParserHelper.reduceMetaComplexEvent(incomingMetaStreamEvent);
    QueryParserHelper.reduceMetaComplexEvent(processedMetaStreamEvent);
    QueryParserHelper.updateVariablePosition(incomingMetaStreamEvent,incomingVariableExpressionExecutors);
    QueryParserHelper.updateVariablePosition(processedMetaStreamEvent,processVariableExpressionExecutors);
    List<TimePeriod.Duration> incrementalDurations=getSortedPeriods(aggregationDefinition.getTimePeriod());
    Map<TimePeriod.Duration,Table> aggregationTables=initDefaultTables(aggregatorName,incrementalDurations,processedMetaStreamEvent.getOutputStreamDefinition(),siddhiAppRuntimeBuilder,aggregationDefinition.getAnnotations(),groupByVariableList);
    Map<TimePeriod.Duration,IncrementalExecutor> incrementalExecutorMap=buildIncrementalExecutors(isProcessingOnExternalTime,processedMetaStreamEvent,processExpressionExecutors,groupByKeyGenerator,bufferSize,incrementalDurations,aggregationTables);
    IncrementalExecutor rootIncrementalExecutor=incrementalExecutorMap.get(incrementalDurations.get(0));
    rootIncrementalExecutor.setScheduler(scheduler);
    entryValveExecutor.setNextExecutor(rootIncrementalExecutor);
    QueryParserHelper.initStreamRuntime(streamRuntime,incomingMetaStreamEvent,lockWrapper,aggregatorName);
    streamRuntime.setCommonProcessor(new IncrementalAggregationProcessor(rootIncrementalExecutor,incomingExpressionExecutors,processedMetaStreamEvent));
    List<ExpressionExecutor> baseExecutors=cloneExpressionExecutors(processExpressionExecutors);
    ExpressionExecutor timestampExecutor=baseExecutors.remove(0);
    return new AggregationRuntime(aggregationDefinition,incrementalExecutorMap,aggregationTables,((SingleStreamRuntime)streamRuntime),entryValveExecutor,incrementalDurations,siddhiAppContext,baseExecutors,timestampExecutor,processedMetaStreamEvent,outputExpressionExecutors);
  }
 catch (  Throwable t) {
    ExceptionUtil.populateQueryContext(t,aggregationDefinition,siddhiAppContext);
    throw t;
  }
}