Program: 73011
Project: 73011
Buggy source:
private void testFactTableSaveAndLoad3(IDocumentManager documentManager) throws IOException, BirtException, DataException {
  Dimension[] dimensions=new Dimension[3];
  String[] levelNames=new String[3];
  levelNames[0]="String_Node_Str";
  levelNames[1]="String_Node_Str";
  levelNames[2]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L1Col);
  iterator.setLevelMember(1,FactTable2.L2Col);
  iterator.setLevelMember(2,FactTable2.L3Col);
  ILevelDefn[] levelDefs=new ILevelDefn[3];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[0]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[0].length(),FactTable2.L1Col.length);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(FactTable2.L1Col));
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[1]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[1].length(),3);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L3Col);
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[2]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[2].length(),12);
  FactTable2 factTable2=new FactTable2();
  String[] measureColumnName=new String[2];
  measureColumnName[0]="String_Node_Str";
  measureColumnName[1]="String_Node_Str";
  FactTableAccessor factTableConstructor=new FactTableAccessor(documentManager);
  FactTable factTable=factTableConstructor.saveFactTable(NamingUtil.getFactTableName("String_Node_Str"),CubeUtility.getKeyColNames(dimensions),CubeUtility.getKeyColNames(dimensions),factTable2,dimensions,measureColumnName,new StopSign());
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  String[] dimensionNames=new String[3];
  dimensionNames[0]="String_Node_Str";
  dimensionNames[1]="String_Node_Str";
  dimensionNames[2]="String_Node_Str";
  ILevel[] level=dimensions[1].getHierarchy().getLevels();
  ISelection[][] filter=new ISelection[1][1];
  filter[0][0]=SelectionFactory.createRangeSelection(new Object[]{new Integer(1)},new Object[]{new Integer(3)},true,false);
  Level[] findLevel=new Level[1];
  findLevel[0]=(Level)level[0];
  IDiskArray[] positionForFilter=null;
  positionForFilter=new IDiskArray[2];
  IDiskArray positionArray=dimensions[1].find(findLevel,filter);
  positionForFilter[0]=positionArray;
  assertEquals(positionArray.size(),2);
  DimensionResultIterator[] dimesionResultSets=new DimensionResultIterator[2];
  dimesionResultSets[0]=new DimensionResultIterator(dimensions[1],positionArray,new StopSign());
  positionArray=dimensions[2].findAll();
  dimesionResultSets[1]=new DimensionResultIterator(dimensions[2],positionArray,new StopSign());
  String[] dimensionNamesForFilter=new String[2];
  dimensionNamesForFilter[0]="String_Node_Str";
  dimensionNamesForFilter[1]="String_Node_Str";
  positionForFilter[1]=positionArray;
  FactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNamesForFilter,positionForFilter,new StopSign());
  assertTrue(facttableRowIterator != null);
  AggregationDefinition[] aggregations=new AggregationDefinition[2];
  int[] sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  DimLevel[] levelsForFilter=new DimLevel[]{dimLevel21};
  AggregationFunctionDefinition[] funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",IBuildInAggregation.TOTAL_SUM_FUNC);
  aggregations[0]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  sortType=new int[2];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  sortType[1]=IDimensionSortDefn.SORT_ASC;
  levelsForFilter=new DimLevel[]{dimLevel31};
  aggregations[1]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  AggregationExecutor aggregationCalculatorExecutor=new AggregationExecutor(dimesionResultSets,facttableRowIterator,aggregations);
  IAggregationResultSet[] resultSet=aggregationCalculatorExecutor.execute(new StopSign());
  assertEquals(resultSet[0].length(),2);
  assertEquals(resultSet[0].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[0].getLevelIndex(dimLevel21),0);
  assertEquals(resultSet[0].getLevelKeyDataType(dimLevel21,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[0].seek(0);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(6));
  resultSet[0].seek(1);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[1].length(),8);
  assertEquals(resultSet[1].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[1].getLevelIndex(dimLevel31),0);
  assertEquals(resultSet[1].getLevelKeyDataType(dimLevel31,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[1].seek(0);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(0));
  resultSet[1].seek(1);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(1));
  resultSet[1].seek(2);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(3));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(2));
  resultSet[1].seek(3);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(4));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(3));
  resultSet[1].seek(4);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(5));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(4));
  resultSet[1].seek(5);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(6));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(5));
  resultSet[1].seek(6);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(7));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(6));
  resultSet[1].seek(7);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(8));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(7));
}

Fixed version (ground truth):
private void testFactTableSaveAndLoad3(IDocumentManager documentManager) throws IOException, BirtException, DataException {
  Dimension[] dimensions=new Dimension[3];
  String[] levelNames=new String[3];
  levelNames[0]="String_Node_Str";
  levelNames[1]="String_Node_Str";
  levelNames[2]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L1Col);
  iterator.setLevelMember(1,FactTable2.L2Col);
  iterator.setLevelMember(2,FactTable2.L3Col);
  ILevelDefn[] levelDefs=new ILevelDefn[3];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[0]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[0].length(),FactTable2.L1Col.length);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(FactTable2.L1Col));
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[1]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[1].length(),3);
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,FactTable2.L3Col);
  levelDefs=new ILevelDefn[1];
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[2]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false);
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  assertEquals(dimensions[2].length(),12);
  FactTable2 factTable2=new FactTable2();
  String[] measureColumnName=new String[2];
  measureColumnName[0]="String_Node_Str";
  measureColumnName[1]="String_Node_Str";
  FactTableAccessor factTableConstructor=new FactTableAccessor(documentManager);
  FactTable factTable=factTableConstructor.saveFactTable(NamingUtil.getFactTableName("String_Node_Str"),CubeUtility.getKeyColNames(dimensions),CubeUtility.getKeyColNames(dimensions),factTable2,dimensions,measureColumnName,new StopSign());
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  String[] dimensionNames=new String[3];
  dimensionNames[0]="String_Node_Str";
  dimensionNames[1]="String_Node_Str";
  dimensionNames[2]="String_Node_Str";
  ILevel[] level=dimensions[1].getHierarchy().getLevels();
  ISelection[][] filter=new ISelection[1][1];
  filter[0][0]=SelectionFactory.createRangeSelection(new Object[]{new Integer(1)},new Object[]{new Integer(3)},true,false);
  Level[] findLevel=new Level[1];
  findLevel[0]=(Level)level[0];
  IDiskArray[] positionForFilter=null;
  positionForFilter=new IDiskArray[2];
  IDiskArray positionArray=dimensions[1].find(findLevel,filter);
  positionForFilter[0]=positionArray;
  assertEquals(positionArray.size(),2);
  DimensionResultIterator[] dimesionResultSets=new DimensionResultIterator[2];
  dimesionResultSets[0]=new DimensionResultIterator(dimensions[1],positionArray,new StopSign());
  positionArray=dimensions[2].findAll();
  dimesionResultSets[1]=new DimensionResultIterator(dimensions[2],positionArray,new StopSign());
  String[] dimensionNamesForFilter=new String[2];
  dimensionNamesForFilter[0]="String_Node_Str";
  dimensionNamesForFilter[1]="String_Node_Str";
  positionForFilter[1]=positionArray;
  FactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNamesForFilter,positionForFilter,new StopSign());
  assertTrue(facttableRowIterator != null);
  AggregationDefinition[] aggregations=new AggregationDefinition[2];
  int[] sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  DimLevel[] levelsForFilter=new DimLevel[]{dimLevel21};
  AggregationFunctionDefinition[] funcitons=new AggregationFunctionDefinition[1];
  funcitons[0]=new AggregationFunctionDefinition("String_Node_Str",IBuildInAggregation.TOTAL_SUM_FUNC);
  aggregations[0]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  sortType=new int[1];
  sortType[0]=IDimensionSortDefn.SORT_ASC;
  levelsForFilter=new DimLevel[]{dimLevel31};
  aggregations[1]=new AggregationDefinition(levelsForFilter,sortType,funcitons);
  IDataSet4Aggregation dataSet4Aggregation=DataSet4AggregationFactory.createDataSet4Aggregation(facttableRowIterator,dimesionResultSets);
  AggregationExecutor aggregationCalculatorExecutor=new AggregationExecutor(dataSet4Aggregation,aggregations);
  IAggregationResultSet[] resultSet=aggregationCalculatorExecutor.execute(new StopSign());
  assertEquals(resultSet[0].length(),2);
  assertEquals(resultSet[0].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[0].getLevelIndex(dimLevel21),0);
  assertEquals(resultSet[0].getLevelKeyDataType(dimLevel21,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[0].seek(0);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(6));
  resultSet[0].seek(1);
  assertEquals(resultSet[0].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[0].getAggregationValue(0),new Double(22));
  assertEquals(resultSet[1].length(),8);
  assertEquals(resultSet[1].getAggregationDataType(0),DataType.DOUBLE_TYPE);
  assertEquals(resultSet[1].getLevelIndex(dimLevel31),0);
  assertEquals(resultSet[1].getLevelKeyDataType(dimLevel31,"String_Node_Str"),DataType.INTEGER_TYPE);
  resultSet[1].seek(0);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(1));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(0));
  resultSet[1].seek(1);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(2));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(1));
  resultSet[1].seek(2);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(3));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(2));
  resultSet[1].seek(3);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(4));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(3));
  resultSet[1].seek(4);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(5));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(4));
  resultSet[1].seek(5);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(6));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(5));
  resultSet[1].seek(6);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(7));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(6));
  resultSet[1].seek(7);
  assertEquals(resultSet[1].getLevelKeyValue(0)[0],new Integer(8));
  assertEquals(resultSet[1].getAggregationValue(0),new Double(7));
}