Program: 28771
Project: 28771
Buggy source:
public StreamEvent find(StateEvent matchingEvent,TimePeriod.Duration perValue,Map<TimePeriod.Duration,IncrementalExecutor> incrementalExecutorMap,List<TimePeriod.Duration> incrementalDurations,Table tableForPerDuration,List<ExpressionExecutor> baseExecutors,ExpressionExecutor timestampExecutor,List<ExpressionExecutor> outputExpressionExecutors,Long[] startTimeEndTime){
  ComplexEventChunk<StreamEvent> complexEventChunkToHoldWithinMatches=new ComplexEventChunk<>(true);
  StreamEvent incomingMatchingStreamEvent=matchingEvent.getStreamEvent(0);
  StateEvent newMatchingStateEvent=new StateEvent(matchingEvent.getStreamEvents().length,0);
  StreamEvent newMatchingStreamEvent=new StreamEvent(metaStreamArraySizes[0],metaStreamArraySizes[1],metaStreamArraySizes[2]);
  if (metaStreamArraySizes[0] > 0) {
    newMatchingStreamEvent.setBeforeWindowData(incomingMatchingStreamEvent.getBeforeWindowData());
  }
  if (metaStreamArraySizes[1] > 0) {
    newMatchingStreamEvent.setOnAfterWindowData(incomingMatchingStreamEvent.getOnAfterWindowData());
  }
  if (metaStreamArraySizes[2] > 2) {
    newMatchingStreamEvent.setOutputData(incomingMatchingStreamEvent.getOutputData());
  }
  newMatchingStreamEvent.setOutputData(startTimeEndTime[0],metaStreamArraySizes[2] - 2);
  newMatchingStreamEvent.setOutputData(startTimeEndTime[1],metaStreamArraySizes[2] - 1);
  newMatchingStateEvent.setEvent(0,newMatchingStreamEvent);
  StreamEvent withinMatchFromPersistedEvents=tableForPerDuration.find(newMatchingStateEvent,withinTableCompiledConditions.get(perValue));
  complexEventChunkToHoldWithinMatches.add(withinMatchFromPersistedEvents);
  BaseIncrementalValueStore newestInMemoryEvent=getNewestInMemoryEvent(incrementalExecutorMap,incrementalDurations,perValue);
  BaseIncrementalValueStore oldestInMemoryEvent=getOldestInMemoryEvent(incrementalExecutorMap,incrementalDurations,perValue);
  if (requiresAggregatingInMemoryData(newestInMemoryEvent,oldestInMemoryEvent,newMatchingStateEvent)) {
    IncrementalDataAggregator incrementalDataAggregator=new IncrementalDataAggregator(incrementalDurations,perValue,baseExecutors,timestampExecutor,tableMetaStreamEvent);
    ComplexEventChunk<StreamEvent> aggregatedInMemoryEventChunk=incrementalDataAggregator.aggregateInMemoryData(incrementalExecutorMap);
    StreamEvent withinMatchFromInMemory=((Operator)inMemoryStoreCompileCondition).find(newMatchingStateEvent,aggregatedInMemoryEventChunk,tableEventCloner);
    complexEventChunkToHoldWithinMatches.add(withinMatchFromInMemory);
  }
  ComplexEventChunk<StreamEvent> aggregateSelectionComplexEventChunk=createAggregateSelectionEventChunk(complexEventChunkToHoldWithinMatches,outputExpressionExecutors);
  return ((Operator)onCompiledCondition).find(matchingEvent,aggregateSelectionComplexEventChunk,aggregateEventCloner);
}

Fixed version (ground truth):
public StreamEvent find(StateEvent matchingEvent,TimePeriod.Duration perValue,Map<TimePeriod.Duration,IncrementalExecutor> incrementalExecutorMap,List<TimePeriod.Duration> incrementalDurations,Table tableForPerDuration,List<ExpressionExecutor> baseExecutors,ExpressionExecutor timestampExecutor,List<ExpressionExecutor> outputExpressionExecutors,Long[] startTimeEndTime){
  ComplexEventChunk<StreamEvent> complexEventChunkToHoldWithinMatches=new ComplexEventChunk<>(true);
  StreamEvent incomingMatchingStreamEvent=matchingEvent.getStreamEvent(0);
  StateEvent newMatchingStateEvent=new StateEvent(matchingEvent.getStreamEvents().length,0);
  int beforeWindowSize=0;
  int onAfterWindowSize=0;
  int outputWindowSize=2;
  if (incomingMatchingStreamEvent.getBeforeWindowData() != null) {
    beforeWindowSize=incomingMatchingStreamEvent.getBeforeWindowData().length;
  }
  if (incomingMatchingStreamEvent.getOnAfterWindowData() != null) {
    onAfterWindowSize=incomingMatchingStreamEvent.getOnAfterWindowData().length;
  }
  if (incomingMatchingStreamEvent.getOutputData() != null) {
    outputWindowSize=incomingMatchingStreamEvent.getOutputData().length + outputWindowSize;
  }
  StreamEvent newMatchingStreamEvent=new StreamEvent(beforeWindowSize,onAfterWindowSize,outputWindowSize);
  if (beforeWindowSize > 0) {
    newMatchingStreamEvent.setBeforeWindowData(incomingMatchingStreamEvent.getBeforeWindowData());
  }
  if (onAfterWindowSize > 0) {
    newMatchingStreamEvent.setOnAfterWindowData(incomingMatchingStreamEvent.getOnAfterWindowData());
  }
  if (outputWindowSize > 2) {
    for (int i=0; i < incomingMatchingStreamEvent.getOutputData().length; i++) {
      newMatchingStreamEvent.setOutputData(incomingMatchingStreamEvent.getOutputData()[i],i);
    }
  }
  newMatchingStreamEvent.setOutputData(startTimeEndTime[0],outputWindowSize - 2);
  newMatchingStreamEvent.setOutputData(startTimeEndTime[1],outputWindowSize - 1);
  newMatchingStateEvent.setEvent(0,newMatchingStreamEvent);
  StreamEvent withinMatchFromPersistedEvents=tableForPerDuration.find(newMatchingStateEvent,withinTableCompiledConditions.get(perValue));
  complexEventChunkToHoldWithinMatches.add(withinMatchFromPersistedEvents);
  BaseIncrementalValueStore newestInMemoryEvent=getNewestInMemoryEvent(incrementalExecutorMap,incrementalDurations,perValue);
  BaseIncrementalValueStore oldestInMemoryEvent=getOldestInMemoryEvent(incrementalExecutorMap,incrementalDurations,perValue);
  if (requiresAggregatingInMemoryData(newestInMemoryEvent,oldestInMemoryEvent,newMatchingStateEvent)) {
    IncrementalDataAggregator incrementalDataAggregator=new IncrementalDataAggregator(incrementalDurations,perValue,baseExecutors,timestampExecutor,tableMetaStreamEvent);
    ComplexEventChunk<StreamEvent> aggregatedInMemoryEventChunk=incrementalDataAggregator.aggregateInMemoryData(incrementalExecutorMap);
    StreamEvent withinMatchFromInMemory=((Operator)inMemoryStoreCompileCondition).find(newMatchingStateEvent,aggregatedInMemoryEventChunk,tableEventCloner);
    complexEventChunkToHoldWithinMatches.add(withinMatchFromInMemory);
  }
  ComplexEventChunk<StreamEvent> aggregateSelectionComplexEventChunk=createAggregateSelectionEventChunk(complexEventChunkToHoldWithinMatches,outputExpressionExecutors);
  return ((Operator)onCompiledCondition).find(matchingEvent,aggregateSelectionComplexEventChunk,aggregateEventCloner);
}