Program: 66341
Project: 66341
Buggy source:
/** 
 * @param dimensionResultIterators
 * @param factTableRowIterator
 * @param aggregations
 * @throws BirtOlapException 
 */
public AggregationExecutor(ICubeDimensionReader cubeDimensionReader,IDataSet4Aggregation dataSet4Aggregation,AggregationDefinition[] aggregations,long memoryCacheSize) throws IOException, DataException {
  Object[] params={dataSet4Aggregation,aggregations};
  logger.entering(AggregationExecutor.class.getName(),"String_Node_Str",params);
  this.dataSet4Aggregation=dataSet4Aggregation;
  this.memoryCacheSize=memoryCacheSize;
  getParameterColIndex(aggregations);
  existReferenceDate=existReferenceDate(aggregations);
  simpleFunc=getFunctionName(aggregations);
  this.aggregationCalculators=new AggregationCalculator[aggregations.length];
  int detailAggregationIndex=-1;
  int detailLevelNum=0;
  if (aggregations.length > 2) {
    for (int i=0; i < aggregations.length; i++) {
      if (aggregations[i].getLevels() != null && aggregations[i].getLevels().length > detailLevelNum) {
        detailLevelNum=aggregations[i].getLevels().length;
        detailAggregationIndex=i;
      }
    }
  }
  this.cubeDimensionReader=cubeDimensionReader;
  timeFunctionCalculator=new TimeFunctionCalculator[aggregations.length];
  for (int i=0; i < this.aggregationCalculators.length; i++) {
    this.timeFunctionCalculator[i]=new TimeFunctionCalculator(aggregations[i],paraColumns,dataSet4Aggregation.getMetaInfo(),this.cubeDimensionReader,this.memoryCacheSize / 5 / this.aggregationCalculators.length);
    if (i == detailAggregationIndex)     this.aggregationCalculators[i]=new AggregationCalculator(aggregations[i],paraColumns,dataSet4Aggregation.getMetaInfo(),cubeDimensionReader,this.memoryCacheSize / 10);
 else     this.aggregationCalculators[i]=new AggregationCalculator(aggregations[i],paraColumns,dataSet4Aggregation.getMetaInfo(),cubeDimensionReader,this.memoryCacheSize / 5 / this.aggregationCalculators.length);
  }
  if (simpleFunc != null) {
    measureIndexes4Merge=dataSet4Aggregation.getMetaInfo().getMeasureIndex(simpleFunc.getMeasureName());
    if (AggregationUtil.needDataField(AggregationManager.getInstance().getAggregation(simpleFunc.getFunctionName()))) {
      this.parameterColIndex4Merge=find(paraColumns,simpleFunc.getParaCol());
    }
 else {
      this.parameterColIndex4Merge=-1;
    }
  }
  sortedFactRows=new DiskSortedStackWrapper[aggregations.length];
  getAggregationLevelIndex();
  logger.exiting(AggregationExecutor.class.getName(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param dimensionResultIterators
 * @param factTableRowIterator
 * @param aggregations
 * @throws BirtOlapException 
 */
public AggregationExecutor(ICubeDimensionReader cubeDimensionReader,IDataSet4Aggregation dataSet4Aggregation,AggregationDefinition[] aggregations,long memoryCacheSize) throws IOException, DataException {
  Object[] params={dataSet4Aggregation,aggregations};
  logger.entering(AggregationExecutor.class.getName(),"String_Node_Str",params);
  this.dataSet4Aggregation=dataSet4Aggregation;
  this.memoryCacheSize=memoryCacheSize;
  getParameterColIndex(aggregations);
  existReferenceDate=existReferenceDate(aggregations);
  simpleFunc=getSimpleFunction(aggregations);
  this.aggregationCalculators=new AggregationCalculator[aggregations.length];
  int detailAggregationIndex=-1;
  int detailLevelNum=0;
  if (aggregations.length > 2) {
    for (int i=0; i < aggregations.length; i++) {
      if (aggregations[i].getLevels() != null && aggregations[i].getLevels().length > detailLevelNum) {
        detailLevelNum=aggregations[i].getLevels().length;
        detailAggregationIndex=i;
      }
    }
  }
  this.cubeDimensionReader=cubeDimensionReader;
  timeFunctionCalculator=new TimeFunctionCalculator[aggregations.length];
  for (int i=0; i < this.aggregationCalculators.length; i++) {
    this.timeFunctionCalculator[i]=new TimeFunctionCalculator(aggregations[i],paraColumns,dataSet4Aggregation.getMetaInfo(),this.cubeDimensionReader,this.memoryCacheSize / 5 / this.aggregationCalculators.length);
    if (i == detailAggregationIndex)     this.aggregationCalculators[i]=new AggregationCalculator(aggregations[i],paraColumns,dataSet4Aggregation.getMetaInfo(),cubeDimensionReader,this.memoryCacheSize / 10);
 else     this.aggregationCalculators[i]=new AggregationCalculator(aggregations[i],paraColumns,dataSet4Aggregation.getMetaInfo(),cubeDimensionReader,this.memoryCacheSize / 5 / this.aggregationCalculators.length);
  }
  if (simpleFunc != null) {
    measureIndexes4Merge=dataSet4Aggregation.getMetaInfo().getMeasureIndex(simpleFunc.getMeasureName());
    if (AggregationUtil.needDataField(AggregationManager.getInstance().getAggregation(simpleFunc.getFunctionName()))) {
      this.parameterColIndex4Merge=find(paraColumns,simpleFunc.getParaCol());
    }
 else {
      this.parameterColIndex4Merge=-1;
    }
  }
  sortedFactRows=new DiskSortedStackWrapper[aggregations.length];
  getAggregationLevelIndex();
  logger.exiting(AggregationExecutor.class.getName(),"String_Node_Str");
}