nus-yam/ex-repair huggingface dataset:
Program: 51289
Project: 51289
Buggy source:
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  Exp[] args=call.getArgs();
  final MemberCalc memberCalc;
  if (args.length == 1) {
    Dimension timeDimension=compiler.getEvaluator().getCube().getTimeDimension();
    memberCalc=new DimensionCurrentMemberCalc(timeDimension);
  }
 else {
    memberCalc=compiler.compileMember(args[1]);
  }
  final IntegerCalc indexValueCalc=compiler.compileInteger(args[0]);
  return new AbstractListCalc(call,new Calc[]{memberCalc,indexValueCalc}){
    public List evaluateList(    Evaluator evaluator){
      Member member=memberCalc.evaluateMember(evaluator);
      int indexValue=indexValueCalc.evaluateInteger(evaluator);
      return lastPeriods(member,evaluator,indexValue);
    }
  }
;
}

Fixed version (ground truth):
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  Exp[] args=call.getArgs();
  final MemberCalc memberCalc;
  if (args.length == 1) {
    Dimension timeDimension=compiler.getEvaluator().getCube().getTimeDimension();
    if (timeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    memberCalc=new DimensionCurrentMemberCalc(timeDimension);
  }
 else {
    memberCalc=compiler.compileMember(args[1]);
  }
  final IntegerCalc indexValueCalc=compiler.compileInteger(args[0]);
  return new AbstractListCalc(call,new Calc[]{memberCalc,indexValueCalc}){
    public List evaluateList(    Evaluator evaluator){
      Member member=memberCalc.evaluateMember(evaluator);
      int indexValue=indexValueCalc.evaluateInteger(evaluator);
      return lastPeriods(member,evaluator,indexValue);
    }
  }
;
}
Program: 51290
Project: 51290
Buggy source:
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Hierarchy hierarchy=validator.getQuery().getCube().getTimeDimension().getHierarchy();
    return MemberType.forHierarchy(hierarchy);
  }
  return super.getResultType(validator,args);
}

Fixed version (ground truth):
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Dimension defaultTimeDimension=validator.getQuery().getCube().getTimeDimension();
    if (defaultTimeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    Hierarchy hierarchy=defaultTimeDimension.getHierarchy();
    return MemberType.forHierarchy(hierarchy);
  }
  return super.getResultType(validator,args);
}
Program: 51292
Project: 51292
Buggy source:
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Hierarchy hierarchy=validator.getQuery().getCube().getTimeDimension().getHierarchy();
    return MemberType.forHierarchy(hierarchy);
  }
  return super.getResultType(validator,args);
}

Fixed version (ground truth):
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Dimension defaultTimeDimension=validator.getQuery().getCube().getTimeDimension();
    if (defaultTimeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    Hierarchy hierarchy=defaultTimeDimension.getHierarchy();
    return MemberType.forHierarchy(hierarchy);
  }
  return super.getResultType(validator,args);
}
Program: 51293
Project: 51293
Buggy source:
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  Exp[] args=call.getArgs();
  final MemberCalc memberCalc;
switch (args.length) {
case 3:
    memberCalc=compiler.compileMember(args[2]);
  break;
case 1:
final Dimension dimension=args[0].getType().getHierarchy().getDimension();
memberCalc=new DimensionCurrentMemberCalc(dimension);
break;
default :
final Dimension timeDimension=compiler.getEvaluator().getCube().getTimeDimension();
memberCalc=new DimensionCurrentMemberCalc(timeDimension);
break;
}
final IntegerCalc lagValueCalc=(args.length >= 2) ? compiler.compileInteger(args[1]) : ConstantCalc.constantInteger(1);
final LevelCalc ancestorLevelCalc=args.length >= 1 ? compiler.compileLevel(args[0]) : null;
return new AbstractMemberCalc(call,new Calc[]{memberCalc,lagValueCalc,ancestorLevelCalc}){
public Member evaluateMember(Evaluator evaluator){
Member member=memberCalc.evaluateMember(evaluator);
int lagValue=lagValueCalc.evaluateInteger(evaluator);
Level ancestorLevel;
if (ancestorLevelCalc != null) {
ancestorLevel=ancestorLevelCalc.evaluateLevel(evaluator);
}
 else {
Member parent=member.getParentMember();
if (parent == null) {
return member.getHierarchy().getNullMember();
}
ancestorLevel=parent.getLevel();
}
return parallelPeriod(member,ancestorLevel,evaluator,lagValue);
}
}
;
}

Fixed version (ground truth):
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  Exp[] args=call.getArgs();
  final MemberCalc memberCalc;
switch (args.length) {
case 3:
    memberCalc=compiler.compileMember(args[2]);
  break;
case 1:
final Dimension dimension=args[0].getType().getHierarchy().getDimension();
memberCalc=new DimensionCurrentMemberCalc(dimension);
break;
default :
final Dimension timeDimension=compiler.getEvaluator().getCube().getTimeDimension();
if (timeDimension == null) {
throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
}
memberCalc=new DimensionCurrentMemberCalc(timeDimension);
break;
}
final IntegerCalc lagValueCalc=(args.length >= 2) ? compiler.compileInteger(args[1]) : ConstantCalc.constantInteger(1);
final LevelCalc ancestorLevelCalc=args.length >= 1 ? compiler.compileLevel(args[0]) : null;
return new AbstractMemberCalc(call,new Calc[]{memberCalc,lagValueCalc,ancestorLevelCalc}){
public Member evaluateMember(Evaluator evaluator){
Member member=memberCalc.evaluateMember(evaluator);
int lagValue=lagValueCalc.evaluateInteger(evaluator);
Level ancestorLevel;
if (ancestorLevelCalc != null) {
ancestorLevel=ancestorLevelCalc.evaluateLevel(evaluator);
}
 else {
Member parent=member.getParentMember();
if (parent == null) {
return member.getHierarchy().getNullMember();
}
ancestorLevel=parent.getLevel();
}
return parallelPeriod(member,ancestorLevel,evaluator,lagValue);
}
}
;
}
Program: 51294
Project: 51294
Buggy source:
public boolean dependsOn(Dimension dimension){
  if (super.dependsOn(dimension)) {
    return true;
  }
  if (memberCalc != null) {
    return false;
  }
 else   if (levelCalc != null) {
    return levelCalc.getType().usesDimension(dimension,true);
  }
 else {
    return dimension == timeDimension;
  }
}

Fixed version (ground truth):
public boolean dependsOn(Dimension dimension){
  if (super.dependsOn(dimension)) {
    return true;
  }
  if (memberCalc != null) {
    return false;
  }
 else   if (levelCalc != null) {
    return levelCalc.getType().usesDimension(dimension,true);
  }
 else {
    if (timeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    return dimension == timeDimension;
  }
}
Program: 51295
Project: 51295
Buggy source:
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Hierarchy hierarchy=validator.getQuery().getCube().getTimeDimension().getHierarchy();
    return new SetType(MemberType.forHierarchy(hierarchy));
  }
  final Type type=args[0].getType();
  if (type.getDimension() == null || type.getDimension().getDimensionType() != mondrian.olap.DimensionType.TimeDimension) {
    throw MondrianResource.instance().TimeArgNeeded.ex(getName());
  }
  return super.getResultType(validator,args);
}

Fixed version (ground truth):
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Dimension defaultTimeDimension=validator.getQuery().getCube().getTimeDimension();
    if (defaultTimeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    Hierarchy hierarchy=defaultTimeDimension.getHierarchy();
    return new SetType(MemberType.forHierarchy(hierarchy));
  }
  final Type type=args[0].getType();
  if (type.getDimension() == null || type.getDimension().getDimensionType() != mondrian.olap.DimensionType.TimeDimension) {
    throw MondrianResource.instance().TimeArgNeeded.ex(getName());
  }
  return super.getResultType(validator,args);
}
Program: 51296
Project: 51296
Buggy source:
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  final LevelCalc levelCalc=call.getArgCount() > 0 ? compiler.compileLevel(call.getArg(0)) : null;
  final MemberCalc memberCalc=call.getArgCount() > 1 ? compiler.compileMember(call.getArg(1)) : null;
  final Dimension timeDimension=compiler.getEvaluator().getCube().getTimeDimension();
  return new AbstractListCalc(call,new Calc[]{levelCalc,memberCalc}){
    public List evaluateList(    Evaluator evaluator){
      final Member member;
      final Level level;
      if (levelCalc == null) {
        member=evaluator.getContext(timeDimension);
        level=member.getLevel().getParentLevel();
      }
 else {
        level=levelCalc.evaluateLevel(evaluator);
        if (memberCalc == null) {
          member=evaluator.getContext(level.getHierarchy().getDimension());
        }
 else {
          member=memberCalc.evaluateMember(evaluator);
        }
      }
      return periodsToDate(evaluator,level,member);
    }
    public boolean dependsOn(    Dimension dimension){
      if (super.dependsOn(dimension)) {
        return true;
      }
      if (memberCalc != null) {
        return false;
      }
 else       if (levelCalc != null) {
        return levelCalc.getType().usesDimension(dimension,true);
      }
 else {
        return dimension == timeDimension;
      }
    }
  }
;
}

Fixed version (ground truth):
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  final LevelCalc levelCalc=call.getArgCount() > 0 ? compiler.compileLevel(call.getArg(0)) : null;
  final MemberCalc memberCalc=call.getArgCount() > 1 ? compiler.compileMember(call.getArg(1)) : null;
  final Dimension timeDimension=compiler.getEvaluator().getCube().getTimeDimension();
  return new AbstractListCalc(call,new Calc[]{levelCalc,memberCalc}){
    public List evaluateList(    Evaluator evaluator){
      final Member member;
      final Level level;
      if (levelCalc == null) {
        if (timeDimension == null) {
          throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
        }
        member=evaluator.getContext(timeDimension);
        level=member.getLevel().getParentLevel();
      }
 else {
        level=levelCalc.evaluateLevel(evaluator);
        if (memberCalc == null) {
          member=evaluator.getContext(level.getHierarchy().getDimension());
        }
 else {
          member=memberCalc.evaluateMember(evaluator);
        }
      }
      return periodsToDate(evaluator,level,member);
    }
    public boolean dependsOn(    Dimension dimension){
      if (super.dependsOn(dimension)) {
        return true;
      }
      if (memberCalc != null) {
        return false;
      }
 else       if (levelCalc != null) {
        return levelCalc.getType().usesDimension(dimension,true);
      }
 else {
        if (timeDimension == null) {
          throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
        }
        return dimension == timeDimension;
      }
    }
  }
;
}
Program: 51297
Project: 51297
Buggy source:
public List evaluateList(Evaluator evaluator){
  final Member member;
  final Level level;
  if (levelCalc == null) {
    member=evaluator.getContext(timeDimension);
    level=member.getLevel().getParentLevel();
  }
 else {
    level=levelCalc.evaluateLevel(evaluator);
    if (memberCalc == null) {
      member=evaluator.getContext(level.getHierarchy().getDimension());
    }
 else {
      member=memberCalc.evaluateMember(evaluator);
    }
  }
  return periodsToDate(evaluator,level,member);
}

Fixed version (ground truth):
public List evaluateList(Evaluator evaluator){
  final Member member;
  final Level level;
  if (levelCalc == null) {
    if (timeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    member=evaluator.getContext(timeDimension);
    level=member.getLevel().getParentLevel();
  }
 else {
    level=levelCalc.evaluateLevel(evaluator);
    if (memberCalc == null) {
      member=evaluator.getContext(level.getHierarchy().getDimension());
    }
 else {
      member=memberCalc.evaluateMember(evaluator);
    }
  }
  return periodsToDate(evaluator,level,member);
}
Program: 51298
Project: 51298
Buggy source:
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Hierarchy hierarchy=validator.getQuery().getCube().getTimeDimension().getHierarchy();
    return new SetType(MemberType.forHierarchy(hierarchy));
  }
  final Type type=args[0].getType();
  if (type.getHierarchy().getDimension().getDimensionType() != DimensionType.TimeDimension) {
    throw MondrianResource.instance().TimeArgNeeded.ex(getName());
  }
  return super.getResultType(validator,args);
}

Fixed version (ground truth):
public Type getResultType(Validator validator,Exp[] args){
  if (args.length == 0) {
    Dimension defaultTimeDimension=validator.getQuery().getCube().getTimeDimension();
    if (defaultTimeDimension == null) {
      throw MondrianResource.instance().NoTimeDimensionInCube.ex(getName());
    }
    Hierarchy hierarchy=defaultTimeDimension.getHierarchy();
    return new SetType(MemberType.forHierarchy(hierarchy));
  }
  final Type type=args[0].getType();
  if (type.getHierarchy().getDimension().getDimensionType() != DimensionType.TimeDimension) {
    throw MondrianResource.instance().TimeArgNeeded.ex(getName());
  }
  return super.getResultType(validator,args);
}
Program: 51299
Project: 51299
Buggy source:
@FunctionName("String_Node_Str") @Signature("String_Node_Str") @Description("String_Node_Str") public static String typeName(Object varName){
  if (varName == null) {
    return "String_Node_Str";
  }
 else {
    return varName.getClass().getSimpleName();
  }
}

Fixed version (ground truth):
@FunctionName("String_Node_Str") @Signature("String_Node_Str") @Description("String_Node_Str") public static String typeName(Object varName){
  if (varName == null) {
    return "String_Node_Str";
  }
 else {
    String name=varName.getClass().getName();
    if (name.lastIndexOf("String_Node_Str") >= 0) {
      name=name.substring(name.lastIndexOf("String_Node_Str") + 1);
    }
    return name;
  }
}
Program: 51300
Project: 51300
Buggy source:
public void testFormatDateTime(){
  try {
    Date date=DateFormat.getDateTimeInstance().parse("String_Node_Str");
    assertEquals("String_Node_Str",Vba.formatDateTime(date));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,0));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,1));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,2));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,3));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,4));
  }
 catch (  ParseException e) {
    e.printStackTrace();
    fail();
  }
}

Fixed version (ground truth):
public void testFormatDateTime(){
  try {
    Date date=DateFormat.getDateTimeInstance().parse("String_Node_Str");
    assertEquals("String_Node_Str",Vba.formatDateTime(date));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,0));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,1));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,2));
    String datestr=Vba.formatDateTime(date,3);
    assertNotNull(datestr);
    assertTrue(datestr.startsWith("String_Node_Str"));
    assertEquals("String_Node_Str",Vba.formatDateTime(date,4));
  }
 catch (  ParseException e) {
    e.printStackTrace();
    fail();
  }
}
Program: 51301
Project: 51301
Buggy source:
/** 
 * Create an sql query that, when executed, will return the drill through data for this cell. If the parameter extendedContext is true, then the query will include all the levels (i.e. columns) of non-constraining members (i.e. members which are at the "All" level). If the parameter extendedContext is false, the query will exclude the levels (coulmns) of non-constraining members.
 */
public String getDrillThroughSQL(boolean extendedContext){
  RolapAggregationManager aggMan=AggregationManager.instance();
  final Member[] currentMembers=getMembers();
  CellRequest cellRequest=RolapAggregationManager.makeDrillThroughRequest(currentMembers,extendedContext);
  return (cellRequest == null) ? null : aggMan.getDrillThroughSql(cellRequest,false);
}

Fixed version (ground truth):
/** 
 * Create an sql query that, when executed, will return the drill through data for this cell. If the parameter extendedContext is true, then the query will include all the levels (i.e. columns) of non-constraining members (i.e. members which are at the "All" level). If the parameter extendedContext is false, the query will exclude the levels (coulmns) of non-constraining members.
 */
public String getDrillThroughSQL(boolean extendedContext){
  RolapAggregationManager aggMan=AggregationManager.instance();
  final Member[] currentMembers=getMembersForDrillThrough();
  CellRequest cellRequest=RolapAggregationManager.makeDrillThroughRequest(currentMembers,extendedContext);
  return (cellRequest == null) ? null : aggMan.getDrillThroughSql(cellRequest,false);
}
Program: 51302
Project: 51302
Buggy source:
/** 
 * Returns whether it is possible to drill through this cell. Drill-through is possible if the measure is a stored measure and not possible for calculated measures.
 * @return true if can drill through
 */
public boolean canDrillThrough(){
  final Member[] currentMembers=getMembers();
  return (currentMembers[0] instanceof RolapStoredMeasure);
}

Fixed version (ground truth):
/** 
 * Returns whether it is possible to drill through this cell. Drill-through is possible if the measure is a stored measure and not possible for calculated measures.
 * @return true if can drill through
 */
public boolean canDrillThrough(){
  final Member[] currentMembers=getMembersForDrillThrough();
  return (currentMembers[0] instanceof RolapStoredMeasure);
}
Program: 51303
Project: 51303
Buggy source:
public int getDrillThroughCount(){
  RolapAggregationManager aggMan=AggregationManager.instance();
  final Member[] currentMembers=getMembers();
  CellRequest cellRequest=RolapAggregationManager.makeDrillThroughRequest(currentMembers,false);
  if (cellRequest == null) {
    return -1;
  }
  RolapConnection connection=(RolapConnection)result.getQuery().getConnection();
  final String sql=aggMan.getDrillThroughSql(cellRequest,true);
  final SqlStatement stmt=RolapUtil.executeQuery(connection.getDataSource(),sql,"String_Node_Str","String_Node_Str");
  try {
    ResultSet rs=stmt.getResultSet();
    rs.next();
    ++stmt.rowCount;
    return rs.getInt(1);
  }
 catch (  SQLException e) {
    throw stmt.handle(e);
  }
 finally {
    stmt.close();
  }
}

Fixed version (ground truth):
public int getDrillThroughCount(){
  RolapAggregationManager aggMan=AggregationManager.instance();
  final Member[] currentMembers=getMembersForDrillThrough();
  CellRequest cellRequest=RolapAggregationManager.makeDrillThroughRequest(currentMembers,false);
  if (cellRequest == null) {
    return -1;
  }
  RolapConnection connection=(RolapConnection)result.getQuery().getConnection();
  final String sql=aggMan.getDrillThroughSql(cellRequest,true);
  final SqlStatement stmt=RolapUtil.executeQuery(connection.getDataSource(),sql,"String_Node_Str","String_Node_Str");
  try {
    ResultSet rs=stmt.getResultSet();
    rs.next();
    ++stmt.rowCount;
    return rs.getInt(1);
  }
 catch (  SQLException e) {
    throw stmt.handle(e);
  }
 finally {
    stmt.close();
  }
}
Program: 51304
Project: 51304
Buggy source:
protected ContextCalc(MemberCalc[] memberCalcs,Calc calc){
  super(new DummyExp(calc.getType()));
  this.memberCalcs=memberCalcs;
  this.calc=calc;
  this.calcs=new Calc[memberCalcs.length + 1];
  System.arraycopy(memberCalcs,0,this.calcs,0,memberCalcs.length);
  this.calcs[this.calcs.length - 1]=calc;
  this.members=new Member[memberCalcs.length];
}

Fixed version (ground truth):
protected ContextCalc(MemberCalc[] memberCalcs,CalcImpl calc){
  super(new DummyExp(calc.getType()));
  this.memberCalcs=memberCalcs;
  this.calc=calc;
  this.calcs=new Calc[memberCalcs.length + 1];
  System.arraycopy(memberCalcs,0,this.calcs,0,memberCalcs.length);
  this.calcs[this.calcs.length - 1]=calc;
  this.members=new Member[memberCalcs.length];
}
Program: 51305
Project: 51305
Buggy source:
public Object evaluate(Evaluator evaluator){
  for (int i=0; i < memberCalcs.length; i++) {
    members[i]=memberCalcs[i].evaluateMember(evaluator);
  }
  final Evaluator subEval=evaluator.push(members);
  return calc.evaluate(subEval);
}

Fixed version (ground truth):
public Object evaluate(Evaluator evaluator){
  for (int i=0; i < memberCalcs.length; i++) {
    members[i]=memberCalcs[i].evaluateMember(evaluator);
  }
  final Evaluator subEval=evaluator.push(members);
  return calc.evaluateDual(evaluator,subEval);
}
Program: 51307
Project: 51307
Buggy source:
public void resolve(Validator validator){
  exp=validator.validate(exp,false);
  final Type type=exp.getType();
  if (!TypeUtil.isSet(type)) {
    throw MondrianResource.instance().MdxAxisIsNotSet.ex(axisOrdinal.name());
  }
}

Fixed version (ground truth):
public void resolve(Validator validator){
  exp=validator.validate(exp,false);
  final Type type=exp.getType();
  if (!TypeUtil.isSet(type)) {
    if (type instanceof MemberType || type instanceof TupleType) {
      exp=new UnresolvedFunCall("String_Node_Str",Syntax.Braces,new Exp[]{exp});
      exp=validator.validate(exp,false);
    }
 else {
      throw MondrianResource.instance().MdxAxisIsNotSet.ex(axisOrdinal.name());
    }
  }
}
Program: 51308
Project: 51308
Buggy source:
public void metadata(SaxWriter writer){
  if (empty) {
    return;
  }
  writer.startElement("String_Node_Str",new String[]{"String_Node_Str",XmlaConstants.NS_XSD,"String_Node_Str",NS_XMLA_ROWSET,"String_Node_Str",NS_XMLA_ROWSET,"String_Node_Str",XmlaConstants.NS_XSI,"String_Node_Str",NS_XML_SQL,"String_Node_Str","String_Node_Str"});
{
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.startElement("String_Node_Str");
    writer.startElement("String_Node_Str");
    writer.element("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
    writer.endElement();
    writer.endElement();
    writer.endElement();
  }
{
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str",XSD_STRING});
    writer.element("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.endElement();
    writer.endElement();
  }
{
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.startElement("String_Node_Str");
    for (    ColumnHandler columnHandler : columnHandlers) {
      columnHandler.metadata(writer);
    }
    writer.endElement();
    writer.endElement();
  }
  writer.endElement();
}

Fixed version (ground truth):
public void metadata(SaxWriter writer){
  writer.startElement("String_Node_Str",new String[]{"String_Node_Str",XmlaConstants.NS_XSD,"String_Node_Str",NS_XMLA_ROWSET,"String_Node_Str",NS_XMLA_ROWSET,"String_Node_Str",XmlaConstants.NS_XSI,"String_Node_Str",NS_XML_SQL,"String_Node_Str","String_Node_Str"});
{
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.startElement("String_Node_Str");
    writer.startElement("String_Node_Str");
    writer.element("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"});
    writer.endElement();
    writer.endElement();
    writer.endElement();
  }
{
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str",XSD_STRING});
    writer.element("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.endElement();
    writer.endElement();
  }
{
    writer.startElement("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"});
    writer.startElement("String_Node_Str");
    for (    ColumnHandler columnHandler : columnHandlers) {
      columnHandler.metadata(writer);
    }
    writer.endElement();
    writer.endElement();
  }
  writer.endElement();
}
Program: 51312
Project: 51312
Buggy source:
/** 
 * Processes a request.
 * @param request  XML request, for example, "<SOAP-ENV:Envelope ...>".
 * @param response Destination for response
 */
public void process(XmlaRequest request,XmlaResponse response) throws XmlaException {
  int method=request.getMethod();
  long start=System.currentTimeMillis();
switch (method) {
case METHOD_DISCOVER:
    discover(request,response);
  break;
case METHOD_EXECUTE:
execute(request,response);
break;
default :
throw new XmlaException(CLIENT_FAULT_FC,HSB_BAD_METHOD_CODE,HSB_BAD_METHOD_FAULT_FS,new IllegalArgumentException("String_Node_Str" + method));
}
if (LOGGER.isDebugEnabled()) {
long end=System.currentTimeMillis();
LOGGER.debug("String_Node_Str" + (end - start));
LOGGER.debug("String_Node_Str" + Util.printMemory());
}
}

Fixed version (ground truth):
/** 
 * Processes a request.
 * @param request  XML request, for example, "<SOAP-ENV:Envelope ...>".
 * @param response Destination for response
 * @throws XmlaException on error
 */
public void process(XmlaRequest request,XmlaResponse response) throws XmlaException {
  int method=request.getMethod();
  long start=System.currentTimeMillis();
switch (method) {
case METHOD_DISCOVER:
    discover(request,response);
  break;
case METHOD_EXECUTE:
execute(request,response);
break;
default :
throw new XmlaException(CLIENT_FAULT_FC,HSB_BAD_METHOD_CODE,HSB_BAD_METHOD_FAULT_FS,new IllegalArgumentException("String_Node_Str" + method));
}
if (LOGGER.isDebugEnabled()) {
long end=System.currentTimeMillis();
LOGGER.debug("String_Node_Str" + (end - start));
LOGGER.debug("String_Node_Str" + Util.printMemory());
}
}
Program: 51313
Project: 51313
Buggy source:
private void cellData(SaxWriter writer) throws SAXException {
  cellOrdinal=0;
  if (axisCount == 0) {
    emitCell(writer,result.getCell(pos));
  }
 else {
    recurse(writer,axisCount - 1,0);
  }
}

Fixed version (ground truth):
private void cellData(SaxWriter writer) throws SAXException {
  cellOrdinal=0;
  iterate(writer);
}
Program: 51315
Project: 51315
Buggy source:
private void setValueAndType(long lval){
  if (!isValidXsdInt(lval)) {
    this.valueType=XSD_LONG;
    this.value=new Long(lval);
  }
 else {
    this.valueType=XSD_INT;
    this.value=new Integer((int)lval);
  }
  this.isDecimal=false;
}

Fixed version (ground truth):
private void setValueAndType(long lval){
  if (!isValidXsdInt(lval)) {
    this.valueType=XSD_LONG;
    this.value=lval;
  }
 else {
    this.valueType=XSD_INT;
    this.value=(int)lval;
  }
  this.isDecimal=false;
}
Program: 51316
Project: 51316
Buggy source:
private void recurse(SaxWriter writer,int axis,final int headerOrdinal) throws SAXException {
  final List<Position> positions=result.getAxes()[axis].getPositions();
  int i=0;
  for (  Position position : positions) {
    pos[axis]=i;
    if (axis == 0) {
      final Cell cell=result.getCell(pos);
      emitCell(writer,cell);
    }
 else {
      int ho=headerOrdinal;
      for (      Member member : position) {
        members[ho++]=member;
      }
      recurse(writer,axis - 1,ho);
    }
    i++;
  }
}

Fixed version (ground truth):
private void recurse(SaxWriter writer,int[] pos,int axisOrdinal,Evaluator evaluator,int[] cellOrdinal){
  if (axisOrdinal < 0) {
    emitCell(writer,pos,evaluator,cellOrdinal[0]++);
  }
 else {
    Axis axis=result.getAxes()[axisOrdinal];
    List<Position> positions=axis.getPositions();
    int i=0;
    for (    Position position : positions) {
      pos[axisOrdinal]=i;
      evaluator.setContext(position);
      recurse(writer,pos,axisOrdinal - 1,evaluator,cellOrdinal);
      i++;
    }
  }
}
Program: 51317
Project: 51317
Buggy source:
public FunDef resolve(Exp[] args,Validator validator,int[] conversionCount){
  if (args.length < 1) {
    return null;
  }
  Type type=args[0].getType();
  if (!(type instanceof StringType)) {
    return null;
  }
  for (int i=1; i < args.length; i++) {
    Exp exp=args[i];
    if (!(exp instanceof DimensionExpr)) {
      return null;
    }
  }
  int[] argTypes=new int[args.length];
  argTypes[0]=Category.String;
  for (int i=1; i < argTypes.length; i++) {
    argTypes[i]=Category.Hierarchy;
  }
  return new StrToTupleFunDef(argTypes);
}

Fixed version (ground truth):
public FunDef resolve(Exp[] args,Validator validator,int[] conversionCount){
  if (args.length < 1) {
    return null;
  }
  Type type=args[0].getType();
  if (!(type instanceof StringType)) {
    return null;
  }
  for (int i=1; i < args.length; i++) {
    Exp exp=args[i];
    if (!(exp instanceof DimensionExpr || exp instanceof HierarchyExpr)) {
      return null;
    }
  }
  int[] argTypes=new int[args.length];
  argTypes[0]=Category.String;
  for (int i=1; i < argTypes.length; i++) {
    argTypes[i]=Category.Hierarchy;
  }
  return new StrToTupleFunDef(argTypes);
}
Program: 51318
Project: 51318
Buggy source:
public Exp createCall(Validator validator,Exp[] args){
  final int argCount=args.length;
  if (argCount <= 1) {
    throw MondrianResource.instance().MdxFuncArgumentsNum.ex(getName());
  }
  for (int i=1; i < argCount; i++) {
    final Exp arg=args[i];
    if (arg instanceof DimensionExpr) {
      DimensionExpr dimensionExpr=(DimensionExpr)arg;
      Dimension dimension=dimensionExpr.getDimension();
      args[i]=new HierarchyExpr(dimension.getHierarchy());
    }
 else     if (arg instanceof Hierarchy) {
    }
 else {
      throw MondrianResource.instance().MdxFuncNotHier.ex(i + 1,getName());
    }
  }
  return super.createCall(validator,args);
}

Fixed version (ground truth):
public Exp createCall(Validator validator,Exp[] args){
  final int argCount=args.length;
  if (argCount <= 1) {
    throw MondrianResource.instance().MdxFuncArgumentsNum.ex(getName());
  }
  for (int i=1; i < argCount; i++) {
    final Exp arg=args[i];
    if (arg instanceof DimensionExpr) {
      DimensionExpr dimensionExpr=(DimensionExpr)arg;
      Dimension dimension=dimensionExpr.getDimension();
      args[i]=new HierarchyExpr(dimension.getHierarchy());
    }
 else     if (arg instanceof HierarchyExpr) {
    }
 else {
      throw MondrianResource.instance().MdxFuncNotHier.ex(i + 1,getName());
    }
  }
  return super.createCall(validator,args);
}
Program: 51319
Project: 51319
Buggy source:
/** 
 * Sets the cardinality for a given column in cache.
 * @param columnHash
 * @param cardinality
 */
void putCachedRelationExprCardinality(MondrianDef.Relation relation,MondrianDef.Expression columnExpr,Integer cardinality){
synchronized (relationExprCardinalityMap) {
    Map<MondrianDef.Expression,Integer> exprCardinalityMap=relationExprCardinalityMap.get(relation);
    if (exprCardinalityMap == null) {
      exprCardinalityMap=new HashMap<MondrianDef.Expression,Integer>();
      relationExprCardinalityMap.put(relation,exprCardinalityMap);
    }
    ;
    exprCardinalityMap.put(columnExpr,cardinality);
  }
}

Fixed version (ground truth):
/** 
 * Sets the cardinality for a given column in cache.
 * @param relation the relation associated with the column expression 
 * @param columnExpr the column expression to cache the cardinality for
 * @param cardinality the cardinality for the column expression
 */
void putCachedRelationExprCardinality(MondrianDef.Relation relation,MondrianDef.Expression columnExpr,Integer cardinality){
synchronized (relationExprCardinalityMap) {
    Map<MondrianDef.Expression,Integer> exprCardinalityMap=relationExprCardinalityMap.get(relation);
    if (exprCardinalityMap == null) {
      exprCardinalityMap=new HashMap<MondrianDef.Expression,Integer>();
      relationExprCardinalityMap.put(relation,exprCardinalityMap);
    }
    ;
    exprCardinalityMap.put(columnExpr,cardinality);
  }
}
Program: 51322
Project: 51322
Buggy source:
public Object getCompound(RolapEvaluator evaluator,List<List<Member>> aggregationLists){
  String sql=RolapAggregationManager.generateMultiSql(evaluator,(List)aggregationLists);
  final SqlStatement stmt=RolapUtil.executeQuery(cube.getStar().getDataSource(),sql,"String_Node_Str","String_Node_Str");
  final ResultSet resultSet=stmt.getResultSet();
  try {
    final int columnCount=resultSet.getMetaData().getColumnCount();
    if (!resultSet.next()) {
      throw Util.newInternal("String_Node_Str");
    }
    ++stmt.rowCount;
    final Object o=resultSet.getObject(columnCount);
    if (resultSet.next()) {
      ++stmt.rowCount;
      throw Util.newInternal("String_Node_Str");
    }
    return o;
  }
 catch (  SQLException e) {
    throw stmt.handle(e);
  }
 finally {
    stmt.close();
  }
}

Fixed version (ground truth):
public Object getCompound(RolapEvaluator evaluator,List<List<Member>> aggregationLists){
  String sql=RolapAggregationManager.generateMultiSql(evaluator,(List)aggregationLists);
  if (sql == null) {
    return Util.nullValue;
  }
  final RolapCube cube=evaluator.getMeasureCube();
  final SqlStatement stmt=RolapUtil.executeQuery(cube.getStar().getDataSource(),sql,"String_Node_Str","String_Node_Str");
  final ResultSet resultSet=stmt.getResultSet();
  try {
    final int columnCount=resultSet.getMetaData().getColumnCount();
    if (!resultSet.next()) {
      throw Util.newInternal("String_Node_Str");
    }
    ++stmt.rowCount;
    final Object o=resultSet.getObject(columnCount);
    if (resultSet.next()) {
      ++stmt.rowCount;
      throw Util.newInternal("String_Node_Str");
    }
    return o;
  }
 catch (  SQLException e) {
    throw stmt.handle(e);
  }
 finally {
    stmt.close();
  }
}
Program: 51324
Project: 51324
Buggy source:
public static Object min(Evaluator evaluator,List members,Calc calc){
  SetWrapper sw=evaluateSet(evaluator,members,calc);
  if (sw.errorCount > 0) {
    return new Double(Double.NaN);
  }
 else   if (sw.v.size() == 0) {
    return Util.nullValue;
  }
 else {
    double min=Double.MAX_VALUE;
    for (int i=0; i < sw.v.size(); i++) {
      double iValue=((Double)sw.v.get(i)).doubleValue();
      if (iValue < min) {
        min=iValue;
      }
    }
    return new Double(min);
  }
}

Fixed version (ground truth):
public static Object min(Evaluator evaluator,List members,Calc calc){
  SetWrapper sw=evaluateSet(evaluator,members,calc);
  if (sw.errorCount > 0) {
    return Double.NaN;
  }
 else {
    final int size=sw.v.size();
    if (size == 0) {
      return Util.nullValue;
    }
 else {
      Double min=(Double)sw.v.get(0);
      for (int i=1; i < size; i++) {
        Double iValue=(Double)sw.v.get(i);
        if (iValue < min) {
          min=iValue;
        }
      }
      return min;
    }
  }
}
Program: 51325
Project: 51325
Buggy source:
public static Object max(Evaluator evaluator,List members,Calc exp){
  SetWrapper sw=evaluateSet(evaluator,members,exp);
  if (sw.errorCount > 0) {
    return new Double(Double.NaN);
  }
 else   if (sw.v.size() == 0) {
    return Util.nullValue;
  }
 else {
    double max=Double.MIN_VALUE;
    for (int i=0; i < sw.v.size(); i++) {
      double iValue=((Double)sw.v.get(i)).doubleValue();
      if (iValue > max) {
        max=iValue;
      }
    }
    return new Double(max);
  }
}

Fixed version (ground truth):
public static Object max(Evaluator evaluator,List members,Calc exp){
  SetWrapper sw=evaluateSet(evaluator,members,exp);
  if (sw.errorCount > 0) {
    return Double.NaN;
  }
 else {
    final int size=sw.v.size();
    if (size == 0) {
      return Util.nullValue;
    }
 else {
      Double max=(Double)sw.v.get(0);
      for (int i=1; i < size; i++) {
        Double iValue=(Double)sw.v.get(i);
        if (iValue > max) {
          max=iValue;
        }
      }
      return max;
    }
  }
}
Program: 51326
Project: 51326
Buggy source:
/** 
 * Creates a CellKey populated with the given coordinates.
 * @param pos Coordinate array
 * @return CellKey
 */
public static CellKey newCellKey(int[] pos){
switch (pos.length) {
case 0:
    return new Zero();
case 1:
  return new One(pos[0]);
case 2:
return new Two(pos[0],pos[1]);
case 3:
return new Three(pos[0],pos[1],pos[2]);
default :
return new Many(pos.clone());
}
}

Fixed version (ground truth):
/** 
 * Creates a CellKey populated with the given coordinates.
 * @param pos Coordinate array
 * @return CellKey
 */
public static CellKey newCellKey(int[] pos){
switch (pos.length) {
case 0:
    return Zero.INSTANCE;
case 1:
  return new One(pos[0]);
case 2:
return new Two(pos[0],pos[1]);
case 3:
return new Three(pos[0],pos[1],pos[2]);
default :
return new Many(pos.clone());
}
}
Program: 51327
Project: 51327
Buggy source:
private static RolapProperty[] createProperties(MondrianDef.Level xmlLevel){
  List<RolapProperty> list=new ArrayList<RolapProperty>();
  final MondrianDef.Expression nameExp=xmlLevel.getNameExp();
  if (nameExp != null) {
    list.add(new RolapProperty(Property.NAME.name,Property.Datatype.TYPE_STRING,nameExp,null,null));
  }
  for (int i=0; i < xmlLevel.properties.length; i++) {
    MondrianDef.Property property=xmlLevel.properties[i];
    list.add(new RolapProperty(property.name,convertPropertyTypeNameToCode(property.type),xmlLevel.getPropertyExp(i),property.formatter,property.caption));
  }
  return list.toArray(new RolapProperty[list.size()]);
}

Fixed version (ground truth):
private static RolapProperty[] createProperties(MondrianDef.Level xmlLevel){
  List<RolapProperty> list=new ArrayList<RolapProperty>();
  final MondrianDef.Expression nameExp=xmlLevel.getNameExp();
  if (nameExp != null) {
    list.add(new RolapProperty(Property.NAME.name,Property.Datatype.TYPE_STRING,nameExp,null,null,true));
  }
  for (int i=0; i < xmlLevel.properties.length; i++) {
    MondrianDef.Property property=xmlLevel.properties[i];
    list.add(new RolapProperty(property.name,convertPropertyTypeNameToCode(property.type),xmlLevel.getPropertyExp(i),property.formatter,property.caption,false));
  }
  return list.toArray(new RolapProperty[list.size()]);
}
Program: 51328
Project: 51328
Buggy source:
/** 
 * Creates a RolapProperty.
 */
RolapProperty(String name,Datatype type,MondrianDef.Expression exp,String formatterDef,String caption){
  super(name,type,-1,false,false,false,null);
  this.exp=exp;
  this.caption=caption;
  this.formatter=makePropertyFormatter(formatterDef);
}

Fixed version (ground truth):
/** 
 * Creates a RolapProperty.
 * @param name Name of property
 * @param type Datatype
 * @param exp Expression for property's value; often a literal
 * @param formatterDef Name of formatter class (must implement{@link PropertyFormatter}), or null
 * @param caption Caption
 * @param internal Whether property is internal
 */
RolapProperty(String name,Datatype type,MondrianDef.Expression exp,String formatterDef,String caption,boolean internal){
  super(name,type,-1,internal,false,false,null);
  this.exp=exp;
  this.caption=caption;
  this.formatter=makePropertyFormatter(formatterDef);
}
Program: 51329
Project: 51329
Buggy source:
/** 
 * Returns style in which the result of evaluating this expression is returned. <p>One application of this method is for the compiler to figure out whether the compiled expression is returning a mutable list. If a mutable list is required, the compiler can create a mutable copy.
 * @see ExpCompiler#compileList(mondrian.olap.Exp,boolean)
 */
ExpCompiler.ResultStyle getResultStyle();

Fixed version (ground truth):
/** 
 * Returns style in which the result of evaluating this expression is returned. <p>One application of this method is for the compiler to figure out whether the compiled expression is returning a mutable list. If a mutable list is required, the compiler can create a mutable copy.
 * @see ExpCompiler#compileList(mondrian.olap.Exp,boolean)
 */
ResultStyle getResultStyle();
Program: 51330
Project: 51330
Buggy source:
/** 
 * Compiles an expression to a given result type.
 * @param exp Expression
 * @param preferredResultTypes List of result types, in descending orderof preference. Never null.
 * @return Compiled expression, or null if none can satisfy
 */
Calc compile(Exp exp,ResultStyle[] preferredResultTypes);

Fixed version (ground truth):
/** 
 * Compiles an expression.
 * @param exp Expression
 * @return Compiled expression
 */
Calc compile(Exp exp);
Program: 51331
Project: 51331
Buggy source:
/** 
 * Returns a list of the   {@link mondrian.calc.ExpCompiler.ResultStyle}s acceptable to the caller.
 */
ResultStyle[] getAcceptableResultStyles();

Fixed version (ground truth):
/** 
 * Returns a list of the   {@link ResultStyle}s acceptable to the caller.
 */
List<ResultStyle> getAcceptableResultStyles();
Program: 51332
Project: 51332
Buggy source:
/** 
 * @param evaluator the <code>Evaluator</code> to use with the compiler
 * @param validator the <code>Validator</code> to use with the compiler
 * @param resultStyles the initial <code>ResultStyle</code> arrayfor the compiler
 * @return the new <code>ExpCompiler</code> compiler
 * @throws CreationException if the compiler can not be created
 */
public static ExpCompiler getExpCompiler(final Evaluator evaluator,final Validator validator,final ResultStyle[] resultStyles) throws CreationException {
  return factory.getObject(CLASS_ARRAY,new Object[]{evaluator,validator,resultStyles});
}

Fixed version (ground truth):
/** 
 * @param evaluator the <code>Evaluator</code> to use with the compiler
 * @param validator the <code>Validator</code> to use with the compiler
 * @param resultStyles the initial <code>ResultStyle</code> arrayfor the compiler
 * @return the new <code>ExpCompiler</code> compiler
 * @throws CreationException if the compiler can not be created
 */
public static ExpCompiler getExpCompiler(final Evaluator evaluator,final Validator validator,final List<ResultStyle> resultStyles) throws CreationException {
  return factory.getObject(CLASS_ARRAY,new Object[]{evaluator,validator,resultStyles});
}
Program: 51333
Project: 51333
Buggy source:
/** 
 * The <code>ExpCompiler.Factory</code>'s implementation of the <code>ObjectFactory</code>'s abstract method which returns the default <code>ExpCompiler</code> instance.
 * @param parameterTypes array of classes: Evaluator, Validator andResultStyle
 * @param parameterValues  the Evaluator, Validator and ResultStylevalues
 * @return <code>ExpCompiler</code> instance
 * @throws CreationException if the <code>ExpCompiler</code> can not becreated.
 */
protected ExpCompiler getDefault(final Class[] parameterTypes,final Object[] parameterValues) throws CreationException {
  Evaluator evaluator=(Evaluator)parameterValues[0];
  Validator validator=(Validator)parameterValues[1];
  ResultStyle[] resultStyles=(ResultStyle[])parameterValues[2];
  return new mondrian.calc.impl.BetterExpCompiler(evaluator,validator,resultStyles);
}

Fixed version (ground truth):
/** 
 * The <code>ExpCompiler.Factory</code>'s implementation of the <code>ObjectFactory</code>'s abstract method which returns the default <code>ExpCompiler</code> instance.
 * @param parameterTypes array of classes: Evaluator, Validator andResultStyle
 * @param parameterValues  the Evaluator, Validator and ResultStylevalues
 * @return <code>ExpCompiler</code> instance
 * @throws CreationException if the <code>ExpCompiler</code> can not becreated.
 */
protected ExpCompiler getDefault(final Class[] parameterTypes,final Object[] parameterValues) throws CreationException {
  Evaluator evaluator=(Evaluator)parameterValues[0];
  Validator validator=(Validator)parameterValues[1];
  List<ResultStyle> resultStyles=(List<ResultStyle>)parameterValues[2];
  return new BetterExpCompiler(evaluator,validator,resultStyles);
}
Program: 51334
Project: 51334
Buggy source:
/** 
 * Evaluates an expression to yield a list of members or tuples. <p>The list is immutable if   {@link #getResultStyle()} yields{@link mondrian.calc.ExpCompiler.ResultStyle#MUTABLE_LIST}. Otherwise, the caller must not modify the list.
 * @param evaluator Evaluation context
 * @return A list of members or tuples, never null.
 */
List evaluateList(Evaluator evaluator);

Fixed version (ground truth):
/** 
 * Evaluates an expression to yield a list of members or tuples. <p>The list is immutable if   {@link #getResultStyle()} yields{@link ResultStyle#MUTABLE_LIST}. Otherwise, the caller must not modify the list.
 * @param evaluator Evaluation context
 * @return A list of members or tuples, never null.
 */
List evaluateList(Evaluator evaluator);
Program: 51335
Project: 51335
Buggy source:
public ExpCompiler.ResultStyle getResultStyle(){
  return ExpCompiler.ResultStyle.VALUE;
}

Fixed version (ground truth):
public ResultStyle getResultStyle(){
  return ResultStyle.VALUE;
}
Program: 51336
Project: 51336
Buggy source:
List<CompositeBatch> groupBatches(List<Batch> batchList){
  Map<BatchKey,CompositeBatch> batchGroups=new HashMap<BatchKey,CompositeBatch>();
  for (int i=0; i < batchList.size(); i++) {
    for (int j=0; j < batchList.size() && i < batchList.size(); ) {
      if (i == j) {
        j++;
        continue;
      }
      FastBatchingCellReader.Batch iBatch=batchList.get(i);
      FastBatchingCellReader.Batch jBatch=batchList.get(j);
      if (iBatch.canBatch(jBatch)) {
        batchList.remove(j);
        addToCompositeBatch(batchGroups,iBatch,jBatch);
      }
 else       if (jBatch.canBatch(iBatch)) {
        batchList.set(i,jBatch);
        batchList.remove(j);
        addToCompositeBatch(batchGroups,jBatch,iBatch);
      }
 else {
        j++;
      }
    }
  }
  wrapNonBatchedBatchesWithCompositeBatches(batchList,batchGroups);
  ArrayList<CompositeBatch> list=new ArrayList<CompositeBatch>(batchGroups.values());
  Collections.sort(list,CompositeBatchComparator.instance);
  return list;
}

Fixed version (ground truth):
List<CompositeBatch> groupBatches(List<Batch> batchList){
  Map<BatchKey,CompositeBatch> batchGroups=new HashMap<BatchKey,CompositeBatch>();
  for (int i=0; i < batchList.size(); i++) {
    for (int j=i + 1; j < batchList.size() && i < batchList.size(); ) {
      FastBatchingCellReader.Batch iBatch=batchList.get(i);
      FastBatchingCellReader.Batch jBatch=batchList.get(j);
      if (iBatch.canBatch(jBatch)) {
        batchList.remove(j);
        addToCompositeBatch(batchGroups,iBatch,jBatch);
      }
 else       if (jBatch.canBatch(iBatch)) {
        batchList.set(i,jBatch);
        batchList.remove(j);
        addToCompositeBatch(batchGroups,jBatch,iBatch);
        j=i + 1;
      }
 else {
        j++;
      }
    }
  }
  wrapNonBatchedBatchesWithCompositeBatches(batchList,batchGroups);
  ArrayList<CompositeBatch> list=new ArrayList<CompositeBatch>(batchGroups.values());
  Collections.sort(list,CompositeBatchComparator.instance);
  return list;
}