nus-yam/ex-repair huggingface dataset:
Program: 51337
Project: 51337
Buggy source:
private void makeDescription(StringBuilder buf,boolean values){
  final String sep=Util.nl + "String_Node_Str";
  buf.append(printSegmentHeaderInfo(sep));
  RolapStar.Column[] columns=aggregation.getColumns();
  for (int i=0; i < columns.length; i++) {
    buf.append(sep);
    buf.append(columns[i].getExpression().getGenericExpression());
    final Aggregation.Axis axis=axes[i];
    axis.getPredicate().describe(buf);
    if (values) {
      Object[] keys=axis.getKeys();
      buf.append("String_Node_Str");
      for (int j=0; j < keys.length; j++) {
        if (j > 0) {
          buf.append("String_Node_Str");
        }
        Object key=keys[j];
        buf.append(key);
      }
      buf.append("String_Node_Str");
    }
  }
  if (!excludedRegions.isEmpty()) {
    buf.append(sep);
    buf.append("String_Node_Str");
    int k=0;
    for (    Region excludedRegion : excludedRegions) {
      if (k++ > 0) {
        buf.append("String_Node_Str");
      }
      excludedRegion.describe(buf);
    }
    buf.append('}');
  }
  buf.append('}');
}

Fixed version (ground truth):
private void makeDescription(StringBuilder buf,boolean values){
  final String sep=Util.nl + "String_Node_Str";
  buf.append(printSegmentHeaderInfo(sep));
  RolapStar.Column[] columns=aggregation.getColumns();
  for (int i=0; i < columns.length; i++) {
    buf.append(sep);
    buf.append(columns[i].getExpression().getGenericExpression());
    final Aggregation.Axis axis=axes[i];
    axis.getPredicate().describe(buf);
    if (values && isReady()) {
      Object[] keys=axis.getKeys();
      buf.append("String_Node_Str");
      for (int j=0; j < keys.length; j++) {
        if (j > 0) {
          buf.append("String_Node_Str");
        }
        Object key=keys[j];
        buf.append(key);
      }
      buf.append("String_Node_Str");
    }
  }
  if (!excludedRegions.isEmpty()) {
    buf.append(sep);
    buf.append("String_Node_Str");
    int k=0;
    for (    Region excludedRegion : excludedRegions) {
      if (k++ > 0) {
        buf.append("String_Node_Str");
      }
      excludedRegion.describe(buf);
    }
    buf.append('}');
  }
  buf.append('}');
}
Program: 51338
Project: 51338
Buggy source:
/** 
 * Blocks until this segment has finished loading; if this segment has already loaded, returns immediately.
 */
public synchronized void waitUntilLoaded(){
  if (!isReady()) {
    try {
      LOGGER.debug("String_Node_Str" + printSegmentHeaderInfo("String_Node_Str"));
      wait();
    }
 catch (    InterruptedException e) {
    }
switch (state) {
case Ready:
      return;
case Failed:
    throw Util.newError("String_Node_Str" + toString());
default :
  throw Util.badValue(state);
}
}
}

Fixed version (ground truth):
/** 
 * Blocks until this segment has finished loading; if this segment has already loaded, returns immediately.
 */
public synchronized void waitUntilLoaded(){
  if (isLoading()) {
    try {
      LOGGER.debug("String_Node_Str" + printSegmentHeaderInfo("String_Node_Str"));
      wait();
    }
 catch (    InterruptedException e) {
    }
switch (state) {
case Ready:
      return;
case Failed:
    throw Util.newError("String_Node_Str" + toString());
default :
  throw Util.badValue(state);
}
}
}
Program: 51340
Project: 51340
Buggy source:
public void load(List<GroupingSet> sets,RolapAggregationManager.PinSet pinnedSegments){
  groupingSets.addAll(sets);
}

Fixed version (ground truth):
public void load(List<GroupingSet> sets,RolapAggregationManager.PinSet pinnedSegments){
  groupingSets.addAll(sets);
  for (  GroupingSet groupingSet : sets) {
    groupingSet.setSegmentsFailed();
  }
}
Program: 51341
Project: 51341
Buggy source:
SegmentLoader getSegmentLoader(){
  return new SegmentLoader(){
    public void load(    List<GroupingSet> sets,    RolapAggregationManager.PinSet pinnedSegments){
      groupingSets.addAll(sets);
    }
  }
;
}

Fixed version (ground truth):
SegmentLoader getSegmentLoader(){
  return new SegmentLoader(){
    public void load(    List<GroupingSet> sets,    RolapAggregationManager.PinSet pinnedSegments){
      groupingSets.addAll(sets);
      for (      GroupingSet groupingSet : sets) {
        groupingSet.setSegmentsFailed();
      }
    }
  }
;
}
Program: 51343
Project: 51343
Buggy source:
/** 
 * Returns the list of measures based upon a distinct aggregation containing SQL measure expressions(as opposed to column expressions). This method was initially intended for only those measures that are defined using subqueries(for DBs that support them). However, since Mondrian does not parse the SQL string, the method will count both queries as well as non query SQL expressions, e.g. "col1" + "col2".
 */
List<RolapStar.Measure> getDistinctSqlMeasures(List<RolapStar.Measure> measuresList){
  List<RolapStar.Measure> distinctSqlMeasureList=new ArrayList<RolapStar.Measure>();
  for (  RolapStar.Measure measure : measuresList) {
    if (measure.getAggregator().isDistinct() && measure.getExpression() instanceof MondrianDef.MeasureExpression) {
      distinctSqlMeasureList.add(measure);
    }
  }
  return distinctSqlMeasureList;
}

Fixed version (ground truth):
/** 
 * Returns the list of measures based upon a distinct aggregation containing SQL measure expressions(as opposed to column expressions). This method was initially intended for only those measures that are defined using subqueries(for DBs that support them). However, since Mondrian does not parse the SQL string, the method will count both queries as well as some non query SQL expressions.
 */
List<RolapStar.Measure> getDistinctSqlMeasures(List<RolapStar.Measure> measuresList){
  List<RolapStar.Measure> distinctSqlMeasureList=new ArrayList<RolapStar.Measure>();
  for (  RolapStar.Measure measure : measuresList) {
    if (measure.getAggregator().isDistinct() && measure.getExpression() instanceof MondrianDef.MeasureExpression) {
      MondrianDef.MeasureExpression measureExpr=(MondrianDef.MeasureExpression)measure.getExpression();
      MondrianDef.SQL measureSql=measureExpr.expressions[0];
      if (measureSql.cdata.toUpperCase().contains("String_Node_Str")) {
        distinctSqlMeasureList.add(measure);
      }
    }
  }
  return distinctSqlMeasureList;
}
Program: 51345
Project: 51345
Buggy source:
private Measure(String name,RolapAggregator aggregator,Table table,MondrianDef.Expression expression,SqlQuery.Datatype datatype){
  super(name,table,expression,datatype);
  this.aggregator=aggregator;
}

Fixed version (ground truth):
private Measure(String name,String cubeName,RolapAggregator aggregator,Table table,MondrianDef.Expression expression,SqlQuery.Datatype datatype){
  super(name,table,expression,datatype);
  this.cubeName=cubeName;
  this.aggregator=aggregator;
}
Program: 51346
Project: 51346
Buggy source:
/** 
 * Get the <String, Table> map associated with a cube.
 * @param cube
 * @return the <String, RolapStar.Table> map
 */
Map<String,RolapStar.Table> getRelationNamesToStarTableMap(RolapCube cube){
  Map<String,RolapStar.Table> relationNamesToStarTableMap=this.cubeToRelationNamesToStarTableMapMap.get(cube);
  if (relationNamesToStarTableMap == null) {
    relationNamesToStarTableMap=new HashMap<String,RolapStar.Table>();
    this.cubeToRelationNamesToStarTableMapMap.put(cube,relationNamesToStarTableMap);
  }
  return relationNamesToStarTableMap;
}

Fixed version (ground truth):
/** 
 * Gets the (String, Table) map associated with a cube.
 * @param cube Cube
 * @return the (String, RolapStar.Table) map
 */
Map<String,RolapStar.Table> getRelationNamesToStarTableMap(RolapCube cube){
  Map<String,RolapStar.Table> relationNamesToStarTableMap=this.cubeToRelationNamesToStarTableMapMap.get(cube);
  if (relationNamesToStarTableMap == null) {
    relationNamesToStarTableMap=new HashMap<String,RolapStar.Table>();
    this.cubeToRelationNamesToStarTableMapMap.put(cube,relationNamesToStarTableMap);
  }
  return relationNamesToStarTableMap;
}
Program: 51347
Project: 51347
Buggy source:
/** 
 * Look up a   {@link Measure} by its name.Returns null if not found.
 */
public Measure lookupMeasureByName(String name){
  for (Iterator<Column> it=getColumns().iterator(); it.hasNext(); ) {
    Column column=it.next();
    if (column instanceof Measure) {
      Measure measure=(Measure)column;
      if (measure.getName().equals(name)) {
        return measure;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Look up a   {@link Measure} by its name.Returns null if not found.
 */
public Measure lookupMeasureByName(String cubeName,String name){
  for (  Column column : getColumns()) {
    if (column instanceof Measure) {
      Measure measure=(Measure)column;
      if (measure.getName().equals(name) && measure.getCubeName().equals(cubeName)) {
        return measure;
      }
    }
  }
  return null;
}
Program: 51348
Project: 51348
Buggy source:
public Column lookupColumn(String columnName){
  for (Iterator<Column> it=getColumns().iterator(); it.hasNext(); ) {
    Column column=it.next();
    if (column.getExpression() instanceof MondrianDef.Column) {
      MondrianDef.Column columnExpr=(MondrianDef.Column)column.getExpression();
      if (columnExpr.name.equals(columnName)) {
        return column;
      }
    }
 else     if (column.getName().equals(columnName)) {
      return column;
    }
  }
  return null;
}

Fixed version (ground truth):
public Column lookupColumn(String columnName){
  for (  Column column : getColumns()) {
    if (column.getExpression() instanceof MondrianDef.Column) {
      MondrianDef.Column columnExpr=(MondrianDef.Column)column.getExpression();
      if (columnExpr.name.equals(columnName)) {
        return column;
      }
    }
 else     if (column.getName().equals(columnName)) {
      return column;
    }
  }
  return null;
}
Program: 51349
Project: 51349
Buggy source:
/** 
 * Returns an array of all columns in this star with a given name.
 */
public Column[] lookupColumns(String columnName){
  List<Column> l=new ArrayList<Column>();
  for (Iterator<Column> it=getColumns().iterator(); it.hasNext(); ) {
    Column column=it.next();
    if (column.getExpression() instanceof MondrianDef.Column) {
      MondrianDef.Column columnExpr=(MondrianDef.Column)column.getExpression();
      if (columnExpr.name.equals(columnName)) {
        l.add(column);
      }
    }
  }
  return (Column[])l.toArray(new Column[0]);
}

Fixed version (ground truth):
/** 
 * Returns an array of all columns in this star with a given name.
 */
public Column[] lookupColumns(String columnName){
  List<Column> l=new ArrayList<Column>();
  for (  Column column : getColumns()) {
    if (column.getExpression() instanceof MondrianDef.Column) {
      MondrianDef.Column columnExpr=(MondrianDef.Column)column.getExpression();
      if (columnExpr.name.equals(columnName)) {
        l.add(column);
      }
    }
  }
  return l.toArray(new Column[l.size()]);
}
Program: 51350
Project: 51350
Buggy source:
synchronized void makeMeasure(RolapBaseCubeMeasure measure){
  RolapStar.Measure starMeasure=new RolapStar.Measure(measure.getName(),measure.getAggregator(),this,measure.getMondrianDefExpression(),measure.getDatatype());
  measure.setStarMeasure(starMeasure);
  if (containsColumn(starMeasure)) {
    star.decrementColumnCount();
  }
 else {
    addColumn(starMeasure);
  }
}

Fixed version (ground truth):
synchronized void makeMeasure(RolapBaseCubeMeasure measure){
}
Program: 51351
Project: 51351
Buggy source:
/** 
 * Given a MondrianDef.Expression return a column with that expression or null.
 */
public Column lookupColumnByExpression(MondrianDef.Expression xmlExpr){
  for (Iterator<Column> it=getColumns().iterator(); it.hasNext(); ) {
    Column column=it.next();
    if (column instanceof RolapStar.Measure) {
      continue;
    }
    if (column.getExpression().equals(xmlExpr)) {
      return column;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Given a MondrianDef.Expression return a column with that expression or null.
 */
public Column lookupColumnByExpression(MondrianDef.Expression xmlExpr){
  for (  Column column : getColumns()) {
    if (column instanceof Measure) {
      continue;
    }
    if (column.getExpression().equals(xmlExpr)) {
      return column;
    }
  }
  return null;
}
Program: 51352
Project: 51352
Buggy source:
/** 
 * This is only called by RolapCube. If the RolapLevel has a non-null name expression then two columns will be made, otherwise only one. Updates the RolapLevel to RolapStar.Column mapping associated with this cube.
 * @param cube
 * @param level
 * @param parentColumn
 */
synchronized Column makeColumns(RolapCube cube,RolapLevel level,Column parentColumn,String usagePrefix){
  Column nameColumn=null;
  if (level.getNameExp() != null) {
    nameColumn=makeColumnForLevelExpr(cube,level,level.getName(),level.getNameExp(),SqlQuery.Datatype.String,null,null,null);
  }
  String name=(level.getNameExp() == null) ? level.getName() : level.getName() + "String_Node_Str";
  Column column=makeColumnForLevelExpr(cube,level,name,level.getKeyExp(),level.getDatatype(),nameColumn,parentColumn,usagePrefix);
  if (column != null) {
    Map<RolapLevel,Column> map=star.getLevelToColumnMap(cube);
    map.put(level,column);
  }
  return column;
}

Fixed version (ground truth):
/** 
 * This is only called by RolapCube. If the RolapLevel has a non-null name expression then two columns will be made, otherwise only one. Updates the RolapLevel to RolapStar.Column mapping associated with this cube.
 * @param cube Cube
 * @param level Level
 * @param parentColumn Parent column
 */
synchronized Column makeColumns(RolapCube cube,RolapLevel level,Column parentColumn,String usagePrefix){
  Column nameColumn=null;
  if (level.getNameExp() != null) {
    nameColumn=makeColumnForLevelExpr(cube,level,level.getName(),level.getNameExp(),SqlQuery.Datatype.String,null,null,null);
  }
  String name=(level.getNameExp() == null) ? level.getName() : level.getName() + "String_Node_Str";
  Column column=makeColumnForLevelExpr(cube,level,name,level.getKeyExp(),level.getDatatype(),nameColumn,parentColumn,usagePrefix);
  if (column != null) {
    Map<RolapLevel,Column> map=star.getLevelToColumnMap(cube);
    map.put(level,column);
  }
  return column;
}
Program: 51353
Project: 51353
Buggy source:
ExplicitRecognizer(final ExplicitRules.TableDef tableDef,final RolapStar star,final JdbcSchema.Table dbFactTable,final JdbcSchema.Table aggTable,final MessageRecorder msgRecorder){
  super(star,dbFactTable,aggTable,msgRecorder);
  this.tableDef=tableDef;
}

Fixed version (ground truth):
ExplicitRecognizer(final ExplicitRules.TableDef tableDef,final RolapStar star,RolapCube cube,final JdbcSchema.Table dbFactTable,final JdbcSchema.Table aggTable,final MessageRecorder msgRecorder){
  super(star,dbFactTable,aggTable,msgRecorder);
  this.tableDef=tableDef;
  this.cube=cube;
}
Program: 51355
Project: 51355
Buggy source:
/** 
 * Checks that ALL of the columns in the dbTable have a mapping in in the tableDef. <p>It is an error if there is a column that does not have a mapping.
 */
public boolean columnsOK(final RolapStar star,final JdbcSchema.Table dbFactTable,final JdbcSchema.Table dbTable,final MessageRecorder msgRecorder){
  Recognizer cb=new ExplicitRecognizer(this,star,dbFactTable,dbTable,msgRecorder);
  return cb.check();
}

Fixed version (ground truth):
/** 
 * Checks that ALL of the columns in the dbTable have a mapping in the tableDef. <p>It is an error if there is a column that does not have a mapping.
 */
public boolean columnsOK(final RolapStar star,final JdbcSchema.Table dbFactTable,final JdbcSchema.Table dbTable,final MessageRecorder msgRecorder){
  Recognizer cb=new ExplicitRecognizer(this,star,getCube(),dbFactTable,dbTable,msgRecorder);
  return cb.check();
}
Program: 51357
Project: 51357
Buggy source:
/** 
 * Check that multi-level member list generates compact form of SQL where clause: (1) User IN list if possible (2) Group members sharing the same parent (3) Only need to compare up to the first unique parent level. Note: matching SQL pattern only works if the SQL is run in the same thread, which is the case with Derby. For LucidDB dialect, the  generated SQL is verified manually.
 */
public void testMultiLevelMemberConstraint(){
  String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  String necjSql="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  SqlPattern[] patterns=new SqlPattern[]{new SqlPattern(SqlPattern.DERBY_DIALECT,necjSql,necjSql)};
  assertQuerySql(query,patterns);
}

Fixed version (ground truth):
/** 
 * Check that multi-level member list generates compact form of SQL where clause: (1) User IN list if possible (2) Group members sharing the same parent (3) Only need to compare up to the first unique parent level.
 */
public void testMultiLevelMemberConstraint(){
  String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  String necjSqlDerby="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  SqlPattern[] patterns=new SqlPattern[]{new SqlPattern(SqlPattern.DERBY_DIALECT,necjSqlDerby,necjSqlDerby)};
  assertQuerySql(query,patterns);
}
Program: 51358
Project: 51358
Buggy source:
/** 
 * Check that multi-level member list generates compact form of SQL where clause: (1) User IN list if possible(not possible if there are null values) (2) Group members sharing the same parent (3) Only need to compare up to the first unique parent level.
 */
public void testMultiLevelMemberConstraintWithNull(){
  String dimension="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String cube="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  String necjSql="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  TestContext testContext=TestContext.create(dimension,cube,null,null,null);
  SqlPattern[] patterns=new SqlPattern[]{new SqlPattern(SqlPattern.getDialect(testContext.getDialect()),necjSql,necjSql)};
  assertQuerySql(testContext,query,patterns);
}

Fixed version (ground truth):
/** 
 * Check that multi-level member list generates compact form of SQL where clause: (1) User IN list if possible(not possible if there are null values because  NULLs do not match) (2) Group members sharing the same parent (3) Only need to compare up to the first unique parent level.
 */
public void testMultiLevelMemberConstraintWithNull(){
  String dimension="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String cube="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  String necjSqlDerby="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  TestContext testContext=TestContext.create(dimension,cube,null,null,null);
  SqlPattern[] patterns=new SqlPattern[]{new SqlPattern(SqlPattern.DERBY_DIALECT,necjSqlDerby,necjSqlDerby)};
  assertQuerySql(testContext,query,patterns);
}
Program: 51359
Project: 51359
Buggy source:
private void checkDimensions(MemberType[] memberTypes){
  for (int i=0; i < memberTypes.length; i++) {
    MemberType memberType=memberTypes[i];
    for (int j=0; j < i; j++) {
      MemberType member1=memberTypes[j];
      final Dimension dimension=memberType.getDimension();
      final Dimension dimension1=member1.getDimension();
      if (dimension == dimension1) {
        throw MondrianResource.instance().DupDimensionsInTuple.ex(dimension.getUniqueName());
      }
    }
  }
}

Fixed version (ground truth):
private void checkDimensions(MemberType[] memberTypes){
  for (int i=0; i < memberTypes.length; i++) {
    MemberType memberType=memberTypes[i];
    for (int j=0; j < i; j++) {
      MemberType member1=memberTypes[j];
      final Dimension dimension=memberType.getDimension();
      final Dimension dimension1=member1.getDimension();
      if (dimension != null && dimension == dimension1) {
        throw MondrianResource.instance().DupDimensionsInTuple.ex(dimension.getUniqueName());
      }
    }
  }
}
Program: 51360
Project: 51360
Buggy source:
public Type getValueType(){
  for (  Type elementType : elementTypes) {
    if (elementType instanceof MemberType) {
      MemberType memberType=(MemberType)elementType;
      if (memberType.getDimension().isMeasures()) {
        return memberType.getValueType();
      }
    }
  }
  return new ScalarType();
}

Fixed version (ground truth):
public Type getValueType(){
  for (  Type elementType : elementTypes) {
    if (elementType instanceof MemberType) {
      MemberType memberType=(MemberType)elementType;
      Dimension dimension=memberType.getDimension();
      if (dimension != null && dimension.isMeasures()) {
        return memberType.getValueType();
      }
    }
  }
  return new ScalarType();
}
Program: 51361
Project: 51361
Buggy source:
public void testItemNull(){
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testItemNull(){
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str" + "String_Node_Str","String_Node_Str");
}
Program: 51362
Project: 51362
Buggy source:
/** 
 * Loads keys into the axis.
 * @param valueSet Set of distinct key values, sorted
 * @param hasNull Whether the axis contains the null value, in additionto the values in <code>valueSet</code>
 * @return Number of keys on axis
 */
int loadKeys(SortedSet<Comparable<?>> valueSet,boolean hasNull){
  this.hasNull=hasNull;
  int size=valueSet.size();
  this.keys=valueSet.toArray(new Comparable<?>[size]);
  for (int i=0; i < size; i++) {
    mapKeyToOffset.put(keys[i],i);
  }
  if (hasNull) {
    mapKeyToOffset.put(RolapUtil.sqlNullValue,size);
    ++size;
  }
  return size;
}

Fixed version (ground truth):
/** 
 * Loads keys into the axis.
 * @param valueSet Set of distinct key values, sorted
 * @param hasNull Whether the axis contains the null value, in additionto the values in <code>valueSet</code>
 * @return Number of keys on axis
 */
int loadKeys(SortedSet<Comparable<?>> valueSet,boolean hasNull){
  this.hasNull=hasNull;
  int size=valueSet.size();
  if (hasNull) {
    size++;
  }
  keys=new Comparable<?>[size];
  valueSet.toArray(keys);
  if (hasNull) {
    keys[size - 1]=RolapUtil.sqlNullValue;
  }
  for (int i=0; i < size; i++) {
    mapKeyToOffset.put(keys[i],i);
  }
  return size;
}
Program: 51363
Project: 51363
Buggy source:
private Vector getFactTableFKs(String sname,String factTable){
  Vector f=new Vector();
  if (sname == null || sname.equals("String_Node_Str")) {
    boolean duplicate=(tablesCount.containsKey(factTable)) && (((Integer)tablesCount.get(factTable)).intValue() > 1);
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t instanceof FactTable && t.name.equals(factTable)) {
        if (duplicate) {
          Iterator fki=((FactTable)t).fks.keySet().iterator();
          while (fki.hasNext()) {
            String fk=(String)fki.next();
            if (t.schemaName == null) {
              f.add(t.name + "String_Node_Str" + fk);
            }
 else {
              f.add(t.schemaName + "String_Node_Str" + t.name+ "String_Node_Str"+ fk);
            }
          }
        }
 else {
          f.addAll(((FactTable)t).fks.keySet());
        }
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable t=(DbTable)ti.next();
          if (t instanceof FactTable && t.name.equals(factTable)) {
            f.addAll(((FactTable)t).fks.keySet());
            break;
          }
        }
        break;
      }
    }
  }
  return f;
}

Fixed version (ground truth):
private Vector<String> getFactTableFKs(String sname,String factTable){
  Vector<String> f=new Vector<String>();
  if (sname == null || sname.equals("String_Node_Str")) {
    boolean duplicate=(tablesCount.containsKey(factTable)) && ((tablesCount.get(factTable)).intValue() > 1);
    for (    DbTable t : tables) {
      if (t instanceof FactTable && t.name.equals(factTable)) {
        if (duplicate) {
          for (          String fk : ((FactTable)t).fks.keySet()) {
            if (t.schemaName == null) {
              f.add(t.name + "String_Node_Str" + fk);
            }
 else {
              f.add(t.schemaName + "String_Node_Str" + t.name+ "String_Node_Str"+ fk);
            }
          }
        }
 else {
          f.addAll(((FactTable)t).fks.keySet());
        }
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t instanceof FactTable && t.name.equals(factTable)) {
            f.addAll(((FactTable)t).fks.keySet());
            break;
          }
        }
        break;
      }
    }
  }
  return f;
}
Program: 51364
Project: 51364
Buggy source:
private boolean tableExists(String sname,String tableName){
  if (sname == null || sname.equals("String_Node_Str")) {
    return tablesCount.containsKey(tableName);
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable d=(DbTable)ti.next();
          if (d.name.equals(tableName)) {
            return true;
          }
        }
        break;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean tableExists(String sname,String tableName){
  if (sname == null || sname.equals("String_Node_Str")) {
    return tablesCount.containsKey(tableName);
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable d : s.tables) {
          if (d.name.equals(tableName)) {
            return true;
          }
        }
        break;
      }
    }
  }
  return false;
}
Program: 51365
Project: 51365
Buggy source:
private Vector getFactTables(String sname){
  Vector f=new Vector();
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t instanceof FactTable) {
        if (t.schemaName == null) {
          f.add(t.name);
        }
 else {
          f.add(t.schemaName + "String_Node_Str" + t.name);
        }
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          Object t=ti.next();
          if (t instanceof FactTable) {
            f.add(((FactTable)t).name);
          }
        }
        break;
      }
    }
  }
  return f;
}

Fixed version (ground truth):
private Vector<String> getFactTables(String sname){
  Vector<String> f=new Vector<String>();
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator<DbTable> ti=tables.iterator();
    for (    DbTable t : tables) {
      if (t instanceof FactTable) {
        if (t.schemaName == null) {
          f.add(t.name);
        }
 else {
          f.add(t.schemaName + "String_Node_Str" + t.name);
        }
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t instanceof FactTable) {
            f.add(((FactTable)t).name);
          }
        }
        break;
      }
    }
  }
  return f;
}
Program: 51366
Project: 51366
Buggy source:
private Vector getDimensionTables(String sname,String factTable){
  Vector f=new Vector();
  if (sname == null || sname.equals("String_Node_Str")) {
    boolean duplicate=(tablesCount.containsKey(factTable)) && (((Integer)tablesCount.get(factTable)).intValue() > 1);
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t instanceof FactTable && t.name.equals(factTable)) {
        if (duplicate) {
          Iterator fki=((FactTable)t).fks.values().iterator();
          while (fki.hasNext()) {
            String fkt=(String)fki.next();
            if (t.schemaName == null) {
              f.add(t.name + "String_Node_Str" + fkt);
            }
 else {
              f.add(t.schemaName + "String_Node_Str" + t.name+ "String_Node_Str"+ fkt);
            }
          }
        }
 else {
          f.addAll(((FactTable)t).fks.values());
          break;
        }
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable t=(DbTable)ti.next();
          if (t instanceof FactTable && t.name.equals(factTable)) {
            f.addAll(((FactTable)t).fks.values());
            break;
          }
        }
        break;
      }
    }
  }
  return f;
}

Fixed version (ground truth):
private Vector<String> getDimensionTables(String sname,String factTable){
  Vector<String> f=new Vector<String>();
  if (sname == null || sname.equals("String_Node_Str")) {
    boolean duplicate=(tablesCount.containsKey(factTable)) && ((tablesCount.get(factTable)).intValue() > 1);
    for (    DbTable t : tables) {
      if (t instanceof FactTable && t.name.equals(factTable)) {
        if (duplicate) {
          Iterator<String> fki=((FactTable)t).fks.values().iterator();
          for (          String fkt : ((FactTable)t).fks.values()) {
            if (t.schemaName == null) {
              f.add(t.name + "String_Node_Str" + fkt);
            }
 else {
              f.add(t.schemaName + "String_Node_Str" + t.name+ "String_Node_Str"+ fkt);
            }
          }
        }
 else {
          f.addAll(((FactTable)t).fks.values());
          break;
        }
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t instanceof FactTable && t.name.equals(factTable)) {
            f.addAll(((FactTable)t).fks.values());
            break;
          }
        }
        break;
      }
    }
  }
  return f;
}
Program: 51367
Project: 51367
Buggy source:
private Vector getAllTables(String sname){
  Vector v=new Vector();
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator i=tables.iterator();
    while (i.hasNext()) {
      DbTable d=(DbTable)i.next();
      if (d.schemaName == null) {
        v.add(d.name);
      }
 else {
        v.add(d.schemaName + "String_Node_Str" + d.name);
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable d=(DbTable)ti.next();
          v.add(d.name);
        }
        break;
      }
    }
  }
  return v;
}

Fixed version (ground truth):
private Vector<String> getAllTables(String sname){
  Vector<String> v=new Vector<String>();
  if (sname == null || sname.equals("String_Node_Str")) {
    for (    DbTable d : tables) {
      if (d.schemaName == null) {
        v.add(d.name);
      }
 else {
        v.add(d.schemaName + "String_Node_Str" + d.name);
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable d : s.tables) {
          v.add(d.name);
        }
        break;
      }
    }
  }
  return v;
}
Program: 51368
Project: 51368
Buggy source:
private String getTablePK(String sname,String tableName){
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t.name.equals(tableName)) {
        return t.pk;
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable t=(DbTable)ti.next();
          if (t.name.equals(tableName)) {
            return t.pk;
          }
        }
        break;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private String getTablePK(String sname,String tableName){
  if (sname == null || sname.equals("String_Node_Str")) {
    for (    DbTable t : tables) {
      if (t.name.equals(tableName)) {
        return t.pk;
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t.name.equals(tableName)) {
            return t.pk;
          }
        }
        break;
      }
    }
  }
  return null;
}
Program: 51369
Project: 51369
Buggy source:
private Vector getAllColumns(String sname,String tableName){
  Vector f=new Vector();
  if (sname == null || sname.equals("String_Node_Str")) {
    boolean duplicate=(tablesCount.containsKey(tableName)) && (((Integer)tablesCount.get(tableName)).intValue() > 1);
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t.name.equals(tableName)) {
        if (duplicate) {
          Iterator ci=t.colsDataType.keySet().iterator();
          while (ci.hasNext()) {
            String c=(String)ci.next();
            if (t.schemaName == null) {
              f.add(t.name + "String_Node_Str" + c);
            }
 else {
              f.add(t.schemaName + "String_Node_Str" + t.name+ "String_Node_Str"+ c);
            }
          }
        }
 else {
          f.addAll(t.colsDataType.keySet());
          break;
        }
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable t=(DbTable)ti.next();
          if (t.name.equals(tableName)) {
            f.addAll(t.colsDataType.keySet());
            break;
          }
        }
        break;
      }
    }
  }
  return f;
}

Fixed version (ground truth):
private Vector<String> getAllColumns(String sname,String tableName){
  Vector<String> f=new Vector<String>();
  if (sname == null || sname.equals("String_Node_Str")) {
    boolean duplicate=(tablesCount.containsKey(tableName)) && ((tablesCount.get(tableName)).intValue() > 1);
    for (    DbTable t : tables) {
      if (t.name.equals(tableName)) {
        if (duplicate) {
          for (          String c : t.colsDataType.keySet()) {
            if (t.schemaName == null) {
              f.add(t.name + "String_Node_Str" + c);
            }
 else {
              f.add(t.schemaName + "String_Node_Str" + t.name+ "String_Node_Str"+ c);
            }
          }
        }
 else {
          f.addAll(t.colsDataType.keySet());
          break;
        }
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t.name.equals(tableName)) {
            f.addAll(t.colsDataType.keySet());
            break;
          }
        }
        break;
      }
    }
  }
  return f;
}
Program: 51370
Project: 51370
Buggy source:
private Vector getAllSchemas(){
  if (allSchemas == null) {
    allSchemas=new Vector();
    if (schemas.size() > 0) {
      Iterator i=schemas.iterator();
      while (i.hasNext()) {
        allSchemas.add(((DbSchema)i.next()).name);
      }
    }
  }
  return allSchemas;
}

Fixed version (ground truth):
private Vector<String> getAllSchemas(){
  if (allSchemas == null) {
    allSchemas=new Vector<String>();
    if (schemas.size() > 0) {
      for (      DbSchema s : schemas) {
        allSchemas.add((s).name);
      }
    }
  }
  return allSchemas;
}
Program: 51371
Project: 51371
Buggy source:
private boolean colExists(String sname,String tableName,String colName){
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t.name.equals(tableName)) {
        return t.colsDataType.containsKey(colName);
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable t=(DbTable)ti.next();
          if (t.name.equals(tableName)) {
            return t.colsDataType.containsKey(colName);
          }
        }
        break;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean colExists(String sname,String tableName,String colName){
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator<DbTable> ti=tables.iterator();
    for (    DbTable t : tables) {
      if (t.name.equals(tableName)) {
        return t.colsDataType.containsKey(colName);
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t.name.equals(tableName)) {
            return t.colsDataType.containsKey(colName);
          }
        }
        break;
      }
    }
  }
  return false;
}
Program: 51372
Project: 51372
Buggy source:
private int getColumnDataType(String sname,String tableName,String colName){
  if (sname == null || sname.equals("String_Node_Str")) {
    Iterator ti=tables.iterator();
    while (ti.hasNext()) {
      DbTable t=(DbTable)ti.next();
      if (t.name.equals(tableName)) {
        int dataType=Integer.parseInt((String)t.colsDataType.get(colName));
        return dataType;
      }
    }
  }
 else {
    Iterator i=schemas.iterator();
    while (i.hasNext()) {
      DbSchema s=(DbSchema)i.next();
      if (s.name.equals(sname)) {
        Iterator ti=s.tables.iterator();
        while (ti.hasNext()) {
          DbTable t=(DbTable)ti.next();
          if (t.name.equals(tableName)) {
            int dataType=Integer.parseInt((String)t.colsDataType.get(colName));
            return dataType;
          }
        }
        break;
      }
    }
  }
  return -1;
}

Fixed version (ground truth):
private int getColumnDataType(String sname,String tableName,String colName){
  if (sname == null || sname.equals("String_Node_Str")) {
    for (    DbTable t : tables) {
      if (t.name.equals(tableName)) {
        return Integer.parseInt(t.colsDataType.get(colName));
      }
    }
  }
 else {
    for (    DbSchema s : schemas) {
      if (s.name.equals(sname)) {
        for (        DbTable t : s.tables) {
          if (t.name.equals(tableName)) {
            return Integer.parseInt(t.colsDataType.get(colName));
          }
        }
        break;
      }
    }
  }
  return -1;
}
Program: 51374
Project: 51374
Buggy source:
/** 
 * Clear the in memory aggregate cache associated with this Cube, but only if Disabling Caching has been enabled.
 */
public void clearCachedAggregations(boolean forced){
  if (isVirtual()) {
    schema.flushRolapStarCaches(forced);
  }
 else {
    star.clearCachedAggregations(forced);
  }
}

Fixed version (ground truth):
/** 
 * Clear the in memory aggregate cache associated with this Cube.
 */
public void clearCachedAggregations(boolean forced){
  if (isVirtual()) {
    schema.flushRolapStarCaches(forced);
  }
 else {
    star.clearCachedAggregations(forced);
  }
}
Program: 51376
Project: 51376
Buggy source:
/** 
 * Other batch can be batched to this if columns list is super set of other batch's constraint columns and if both the batch does not have distinct count measure in it and if both have same Fact Table and if matching columns of this and other batch has the same value and if non matching columns of this batch have �All values�
 */
boolean canBatch(Batch other){
  return hasOverlappingBitKeys(other) && !hasDistinctCountMeasure() && !other.hasDistinctCountMeasure()&& haveSameStarAndAggregation(other)&& haveSameValuesForOverlappingColumnsOrHasAllChildrenForOthers(other);
}

Fixed version (ground truth):
/** 
 * Other batch can be batched to this if columns list is super set of other batch's constraint columns and if both the batch does not have distinct count measure in it and if both have same Fact Table and if matching columns of this and other batch has the same value and if non matching columns of this batch have ALL VALUES
 */
boolean canBatch(Batch other){
  return hasOverlappingBitKeys(other) && !hasDistinctCountMeasure() && !other.hasDistinctCountMeasure()&& haveSameStarAndAggregation(other)&& haveSameValuesForOverlappingColumnsOrHasAllChildrenForOthers(other);
}
Program: 51377
Project: 51377
Buggy source:
/** 
 * Returns members of a level which are not empty (according to the criteria expressed by the evaluator). Calculated members are included.
 */
protected static Member[] getNonEmptyLevelMembers(Evaluator evaluator,Level level){
  SchemaReader sr=evaluator.getSchemaReader();
  if (evaluator.isNonEmpty()) {
    final Member[] members=sr.getLevelMembers(level,evaluator);
    return Util.addLevelCalculatedMembers(sr,level,members);
  }
  return sr.getLevelMembers(level,true);
}

Fixed version (ground truth):
/** 
 * Returns members of a level which are not empty (according to the criteria expressed by the evaluator).
 * @param evaluator Evaluator, determines non-empty criteria
 * @param level Level
 * @param includeCalcMembers Whether to include calculated members
 */
protected static Member[] getNonEmptyLevelMembers(Evaluator evaluator,Level level,boolean includeCalcMembers){
  SchemaReader sr=evaluator.getSchemaReader();
  if (evaluator.isNonEmpty()) {
    final Member[] members=sr.getLevelMembers(level,evaluator);
    if (includeCalcMembers) {
      return Util.addLevelCalculatedMembers(sr,level,members);
    }
    return members;
  }
  return sr.getLevelMembers(level,includeCalcMembers);
}
Program: 51378
Project: 51378
Buggy source:
static List<Member> hierarchyMembers(Hierarchy hierarchy,Evaluator evaluator,final boolean includeCalcMembers){
  final List<Member> memberList;
  if (evaluator.isNonEmpty()) {
    memberList=new ArrayList<Member>();
    for (    Level level : hierarchy.getLevels()) {
      Member[] members=getNonEmptyLevelMembers(evaluator,level);
      memberList.addAll(Arrays.asList(members));
    }
  }
 else {
    memberList=FunUtil.addMembers(evaluator.getSchemaReader(),new ArrayList<Member>(),hierarchy);
    if (!includeCalcMembers && memberList != null) {
      FunUtil.removeCalculatedMembers(memberList);
    }
  }
  FunUtil.hierarchize(memberList,false);
  return memberList;
}

Fixed version (ground truth):
static List<Member> hierarchyMembers(Hierarchy hierarchy,Evaluator evaluator,final boolean includeCalcMembers){
  final List<Member> memberList;
  if (evaluator.isNonEmpty()) {
    memberList=new ArrayList<Member>();
    for (    Level level : hierarchy.getLevels()) {
      Member[] members=getNonEmptyLevelMembers(evaluator,level,includeCalcMembers);
      memberList.addAll(Arrays.asList(members));
    }
  }
 else {
    memberList=FunUtil.addMembers(evaluator.getSchemaReader(),new ArrayList<Member>(),hierarchy);
    if (!includeCalcMembers && memberList != null) {
      FunUtil.removeCalculatedMembers(memberList);
    }
  }
  FunUtil.hierarchize(memberList,false);
  return memberList;
}
Program: 51379
Project: 51379
Buggy source:
static List<Member> levelMembers(Level level,Evaluator evaluator,final boolean includeCalcMembers){
  Member[] members=getNonEmptyLevelMembers(evaluator,level);
  List<Member> memberList=new ArrayList<Member>(Arrays.asList(members));
  if (!includeCalcMembers) {
    FunUtil.removeCalculatedMembers(memberList);
  }
  FunUtil.hierarchize(memberList,false);
  return memberList;
}

Fixed version (ground truth):
static List<Member> levelMembers(Level level,Evaluator evaluator,final boolean includeCalcMembers){
  Member[] members=getNonEmptyLevelMembers(evaluator,level,includeCalcMembers);
  List<Member> memberList=new ArrayList<Member>(Arrays.asList(members));
  if (!includeCalcMembers) {
    FunUtil.removeCalculatedMembers(memberList);
  }
  FunUtil.hierarchize(memberList,false);
  return memberList;
}
Program: 51380
Project: 51380
Buggy source:
/** 
 * Cleans up after all rows have been processed, and returns the list of members.
 * @return list of members
 */
public List<RolapMember> internalClose(){
  for (int i=0; i < members.length; i++) {
    RolapMember member=members[i];
    final List<RolapMember> children=siblings[i + 1];
    if (member != null && children != null) {
      MemberChildrenConstraint mcc=constraint.getMemberChildrenConstraint(member);
      if (mcc != null) {
        cache.putChildren(member,mcc,children);
      }
    }
  }
  return list;
}

Fixed version (ground truth):
/** 
 * Cleans up after all rows have been processed, and returns the list of members.
 * @return list of members
 */
public List<RolapMember> internalClose(){
  for (int i=0; i < members.length; i++) {
    RolapMember member=members[i];
    final List<RolapMember> children=siblings[i + 1];
    if (member != null && children != null) {
      if (member.getDepth() < level.getDepth()) {
        continue;
      }
      MemberChildrenConstraint mcc=constraint.getMemberChildrenConstraint(member);
      if (mcc != null) {
        cache.putChildren(member,mcc,children);
      }
    }
  }
  return list;
}