nus-yam/ex-repair huggingface dataset:
Program: 51040
Project: 51040
Buggy source:
/** 
 * Creates a SegmentHeader object describing the supplied Segment object.
 * @param segment A segment object for which we want to generatea SegmentHeader.
 * @return A SegmentHeader describing the supplied Segment object.
 */
public static SegmentHeader forSegment(Segment segment){
  final ConstrainedColumn[] cc=new ConstrainedColumn[segment.axes.length];
  for (int i=0; i < segment.axes.length; i++) {
    Aggregation.Axis axis=segment.axes[i];
    final List<Object> values=new ArrayList<Object>();
    axis.getPredicate().values(values);
    cc[i]=new SegmentHeader.ConstrainedColumn(axis.getPredicate().getConstrainedColumn().getTable().getTableName(),axis.getPredicate().getConstrainedColumn().getName(),values.toArray());
  }
  return new SegmentHeader(segment.measure.getStar().getSchema().getName(),segment.measure.getCubeName(),segment.measure.getName(),cc);
}

Fixed version (ground truth):
/** 
 * Creates a SegmentHeader object describing the supplied Segment object.
 * @param segment A segment object for which we want to generatea SegmentHeader.
 * @return A SegmentHeader describing the supplied Segment object.
 */
public static SegmentHeader forSegment(Segment segment){
  final ConstrainedColumn[] cc=new ConstrainedColumn[segment.axes.length];
  for (int i=0; i < segment.axes.length; i++) {
    Aggregation.Axis axis=segment.axes[i];
    final List<Object> values=new ArrayList<Object>();
    axis.getPredicate().values(values);
    cc[i]=new SegmentHeader.ConstrainedColumn(axis.getPredicate().getConstrainedColumn().getExpression().getGenericExpression(),values.toArray());
  }
  return new SegmentHeader(segment.measure.getStar().getSchema().getName(),segment.measure.getCubeName(),segment.measure.getName(),cc,segment.aggregation.getStar().getFactTable().getAlias(),segment.aggregation.getConstrainedColumnsBitKey());
}
Program: 51041
Project: 51041
Buggy source:
/** 
 * Constructor for ConstrainedColumn.
 * @param tableName Name of the source table into which theconstrained column is, as defined in the Mondrian schema.
 * @param columnName Name of the column to constrain, as definedin the Mondrian schema.
 * @param valueList List of values to constrain thecolumn to. Use objects like Integer, Boolean, String or Double.
 */
public ConstrainedColumn(String tableName,String columnName,Object[] valueList){
  this.tableName=tableName;
  this.columnName=columnName;
  this.values=new Object[valueList.length];
  System.arraycopy(valueList,0,this.values,0,valueList.length);
}

Fixed version (ground truth):
/** 
 * Constructor for ConstrainedColumn.
 * @param columnExpression Name of the source table into which theconstrained column is, as defined in the Mondrian schema.
 * @param valueList List of values to constrain thecolumn to. Use objects like Integer, Boolean, String or Double.
 */
public ConstrainedColumn(String columnExpression,Object[] valueList){
  this.columnExpression=columnExpression;
  this.values=new Object[valueList.length];
  System.arraycopy(valueList,0,this.values,0,valueList.length);
}
Program: 51042
Project: 51042
Buggy source:
/** 
 * Creates a list of given arity and initial capacity. <p>If arity == 1, creates a   {@link UnaryTupleList}; otherwise creates a   {@link ArrayTupleList}.
 * @see TupleList#cloneList(int)
 * @param arity Arity
 * @param initialCapacity Initial capacity
 * @return Tuple list
 */
public static TupleList createList(int arity,int initialCapacity){
  return arity == 1 ? new UnaryTupleList(new ArrayList<Member>(initialCapacity)) : new ArrayTupleList(arity,initialCapacity);
}

Fixed version (ground truth):
/** 
 * Creates a list of given arity and initial capacity. <p>If arity == 1, creates a   {@link UnaryTupleList}; if arity == 0, creates a   {@link DelegatingTupleList}; otherwise creates a   {@link ArrayTupleList}.
 * @see TupleList#cloneList(int)
 * @param arity Arity
 * @param initialCapacity Initial capacity
 * @return Tuple list
 */
public static TupleList createList(int arity,int initialCapacity){
switch (arity) {
case 0:
    return new DelegatingTupleList(0,new ArrayList<List<Member>>(initialCapacity));
case 1:
  return new UnaryTupleList(new ArrayList<Member>(initialCapacity));
default :
return new ArrayTupleList(arity,initialCapacity);
}
}
Program: 51043
Project: 51043
Buggy source:
public TupleCursor tupleCursor(){
  return new AbstractTupleCursor(getArity()){
    final TupleCursor i1=it1.tupleCursor();
    TupleCursor i2=TupleCollections.emptyList(1).tupleCursor();
    final Member[] members=new Member[arity];
    public boolean forward(){
      if (i2.forward()) {
        return true;
      }
      while (i1.forward()) {
        i2=it2.tupleCursor();
        if (i2.forward()) {
          return true;
        }
      }
      return false;
    }
    public List<Member> current(){
      i1.currentToArray(members,0);
      i2.currentToArray(members,i1.getArity());
      return Util.flatList(members);
    }
  }
;
}

Fixed version (ground truth):
public TupleCursor tupleCursor(){
  return new AbstractTupleCursor(getArity()){
    final TupleCursor i1=it1.tupleCursor();
    final int arity1=i1.getArity();
    TupleCursor i2=TupleCollections.emptyList(1).tupleCursor();
    final Member[] members=new Member[arity];
    public boolean forward(){
      if (i2.forward()) {
        return true;
      }
      while (i1.forward()) {
        i2=it2.tupleCursor();
        if (i2.forward()) {
          return true;
        }
      }
      return false;
    }
    public List<Member> current(){
      i1.currentToArray(members,0);
      i2.currentToArray(members,arity1);
      return Util.flatList(members);
    }
    @Override public Member member(    int column){
      if (column < arity1) {
        return i1.member(column);
      }
 else {
        return i2.member(column - arity1);
      }
    }
    @Override public void setContext(    Evaluator evaluator){
      i1.setContext(evaluator);
      i2.setContext(evaluator);
    }
    @Override public void currentToArray(    Member[] members,    int offset){
      i1.currentToArray(members,offset);
      i2.currentToArray(members,offset + arity1);
    }
  }
;
}
Program: 51044
Project: 51044
Buggy source:
public List<Member> current(){
  i1.currentToArray(members,0);
  i2.currentToArray(members,i1.getArity());
  return Util.flatList(members);
}

Fixed version (ground truth):
public List<Member> current(){
  i1.currentToArray(members,0);
  i2.currentToArray(members,arity1);
  return Util.flatList(members);
}
Program: 51045
Project: 51045
Buggy source:
protected TupleIterable makeIterable(final TupleIterable it1,final TupleIterable it2){
  return new AbstractTupleIterable(it1.getArity() + it2.getArity()){
    public TupleCursor tupleCursor(){
      return new AbstractTupleCursor(getArity()){
        final TupleCursor i1=it1.tupleCursor();
        TupleCursor i2=TupleCollections.emptyList(1).tupleCursor();
        final Member[] members=new Member[arity];
        public boolean forward(){
          if (i2.forward()) {
            return true;
          }
          while (i1.forward()) {
            i2=it2.tupleCursor();
            if (i2.forward()) {
              return true;
            }
          }
          return false;
        }
        public List<Member> current(){
          i1.currentToArray(members,0);
          i2.currentToArray(members,i1.getArity());
          return Util.flatList(members);
        }
      }
;
    }
  }
;
}

Fixed version (ground truth):
protected TupleIterable makeIterable(final TupleIterable it1,final TupleIterable it2){
  return new AbstractTupleIterable(it1.getArity() + it2.getArity()){
    public TupleCursor tupleCursor(){
      return new AbstractTupleCursor(getArity()){
        final TupleCursor i1=it1.tupleCursor();
        final int arity1=i1.getArity();
        TupleCursor i2=TupleCollections.emptyList(1).tupleCursor();
        final Member[] members=new Member[arity];
        public boolean forward(){
          if (i2.forward()) {
            return true;
          }
          while (i1.forward()) {
            i2=it2.tupleCursor();
            if (i2.forward()) {
              return true;
            }
          }
          return false;
        }
        public List<Member> current(){
          i1.currentToArray(members,0);
          i2.currentToArray(members,arity1);
          return Util.flatList(members);
        }
        @Override public Member member(        int column){
          if (column < arity1) {
            return i1.member(column);
          }
 else {
            return i2.member(column - arity1);
          }
        }
        @Override public void setContext(        Evaluator evaluator){
          i1.setContext(evaluator);
          i2.setContext(evaluator);
        }
        @Override public void currentToArray(        Member[] members,        int offset){
          i1.currentToArray(members,offset);
          i2.currentToArray(members,offset + arity1);
        }
      }
;
    }
  }
;
}
Program: 51046
Project: 51046
Buggy source:
/** 
 * Partially sorts a list of Tuples by the value of an applied expression. <p>Avoids sorting the whole list, finds only the <i>n</i> top (or bottom) valued Tuples, and returns them as a new List. Helper function for MDX functions TopCount and BottomCount. <p>NOTE: Does not preserve the contents of the validator. The returned list is immutable.
 * @param evaluator Evaluator
 * @param list a list of tuples
 * @param exp a Calc applied to each tple to find its sort-key
 * @param limit maximum count of tuples to return.
 * @param desc true to sort descending (and find TopCount),false to sort ascending (and find BottomCount).
 * @return the top or bottom tuples, as a new list.
 */
public static List<List<Member>> partiallySortTuples(Evaluator evaluator,TupleList list,Calc exp,int limit,boolean desc,int arity){
  Comparator<List<Member>> comp=new BreakTupleComparator(evaluator,exp,arity).wrap();
  if (desc) {
    comp=Collections.reverseOrder(comp);
  }
  return stablePartialSort(list,comp,limit);
}

Fixed version (ground truth):
/** 
 * Partially sorts a list of Tuples by the value of an applied expression. <p>Avoids sorting the whole list, finds only the <i>n</i> top (or bottom) valued Tuples, and returns them as a new List. Helper function for MDX functions TopCount and BottomCount. <p>NOTE: Does not preserve the contents of the validator. The returned list is immutable.
 * @param evaluator Evaluator
 * @param list a list of tuples
 * @param exp a Calc applied to each tple to find its sort-key
 * @param limit maximum count of tuples to return.
 * @param desc true to sort descending (and find TopCount),false to sort ascending (and find BottomCount).
 * @return the top or bottom tuples, as a new list.
 */
public static List<List<Member>> partiallySortTuples(Evaluator evaluator,TupleList list,Calc exp,int limit,boolean desc){
  Comparator<List<Member>> comp=new BreakTupleComparator(evaluator,exp,list.getArity()).wrap();
  if (desc) {
    comp=Collections.reverseOrder(comp);
  }
  return stablePartialSort(list,comp,limit);
}
Program: 51047
Project: 51047
Buggy source:
/** 
 * Partially sorts a list of Members by the value of an applied expression. <p>Avoids sorting the whole list, finds only the <i>n</i>top (or bottom) valued Members, and returns them as a new List. Helper function for MDX functions TopCount and BottomCount.
 * @param list a list of members
 * @param exp a Calc applied to each member to find its sort-key
 * @param evaluator
 * @param limit maximum count of members to return.
 * @param desc true to sort descending (and find TopCount), false to sortascending (and find BottomCount).
 * @return the top or bottom members, as a new list.<p>NOTE: Does not preserve the contents of the validator.
 */
public static List<Member> partiallySortMembers(Evaluator evaluator,List<Member> list,Calc exp,int limit,boolean desc){
  MemberComparator comp=new BreakMemberComparator(evaluator,exp,desc);
  Map<Member,Object> valueMap=evaluateMembers(evaluator,exp,list,null,false);
  comp.preloadValues(valueMap);
  return stablePartialSort(list,comp.wrap(),limit);
}

Fixed version (ground truth):
/** 
 * Partially sorts a list of Members by the value of an applied expression. <p>Avoids sorting the whole list, finds only the <i>n</i>top (or bottom) valued Members, and returns them as a new List. Helper function for MDX functions TopCount and BottomCount.
 * @param list a list of members
 * @param exp a Calc applied to each member to find its sort-key
 * @param evaluator Evaluator
 * @param limit maximum count of members to return.
 * @param desc true to sort descending (and find TopCount), false to sortascending (and find BottomCount).
 * @return the top or bottom members, as a new list.<p>NOTE: Does not preserve the contents of the validator.
 */
public static List<Member> partiallySortMembers(Evaluator evaluator,List<Member> list,Calc exp,int limit,boolean desc){
  MemberComparator comp=new BreakMemberComparator(evaluator,exp,desc);
  Map<Member,Object> valueMap=evaluateMembers(evaluator,exp,list,null,false);
  comp.preloadValues(valueMap);
  return stablePartialSort(list,comp.wrap(),limit);
}
Program: 51048
Project: 51048
Buggy source:
public TupleCursor tupleCursor(){
  return new AbstractTupleCursor(arity){
    Iterator<IterCalc> calcIterator=Arrays.asList(iterCalcs).iterator();
    TupleCursor currentCursor=TupleCollections.emptyList(1).tupleCursor();
    public boolean forward(){
      while (true) {
        if (currentCursor.forward()) {
          return true;
        }
        if (!calcIterator.hasNext()) {
          return false;
        }
        currentCursor=calcIterator.next().evaluateIterable(evaluator).tupleCursor();
      }
    }
    public List<Member> current(){
      return currentCursor.current();
    }
  }
;
}

Fixed version (ground truth):
public TupleCursor tupleCursor(){
  return new AbstractTupleCursor(arity){
    Iterator<IterCalc> calcIterator=Arrays.asList(iterCalcs).iterator();
    TupleCursor currentCursor=TupleCollections.emptyList(1).tupleCursor();
    public boolean forward(){
      while (true) {
        if (currentCursor.forward()) {
          return true;
        }
        if (!calcIterator.hasNext()) {
          return false;
        }
        currentCursor=calcIterator.next().evaluateIterable(evaluator).tupleCursor();
      }
    }
    public List<Member> current(){
      return currentCursor.current();
    }
    @Override public void setContext(    Evaluator evaluator){
      currentCursor.setContext(evaluator);
    }
    @Override public void currentToArray(    Member[] members,    int offset){
      currentCursor.currentToArray(members,offset);
    }
    @Override public Member member(    int column){
      return currentCursor.member(column);
    }
  }
;
}
Program: 51049
Project: 51049
Buggy source:
public TupleIterable evaluateIterable(final Evaluator evaluator){
  return new AbstractTupleIterable(getType().getArity()){
    public TupleCursor tupleCursor(){
      return new AbstractTupleCursor(arity){
        Iterator<IterCalc> calcIterator=Arrays.asList(iterCalcs).iterator();
        TupleCursor currentCursor=TupleCollections.emptyList(1).tupleCursor();
        public boolean forward(){
          while (true) {
            if (currentCursor.forward()) {
              return true;
            }
            if (!calcIterator.hasNext()) {
              return false;
            }
            currentCursor=calcIterator.next().evaluateIterable(evaluator).tupleCursor();
          }
        }
        public List<Member> current(){
          return currentCursor.current();
        }
      }
;
    }
  }
;
}

Fixed version (ground truth):
public TupleIterable evaluateIterable(final Evaluator evaluator){
  return new AbstractTupleIterable(getType().getArity()){
    public TupleCursor tupleCursor(){
      return new AbstractTupleCursor(arity){
        Iterator<IterCalc> calcIterator=Arrays.asList(iterCalcs).iterator();
        TupleCursor currentCursor=TupleCollections.emptyList(1).tupleCursor();
        public boolean forward(){
          while (true) {
            if (currentCursor.forward()) {
              return true;
            }
            if (!calcIterator.hasNext()) {
              return false;
            }
            currentCursor=calcIterator.next().evaluateIterable(evaluator).tupleCursor();
          }
        }
        public List<Member> current(){
          return currentCursor.current();
        }
        @Override public void setContext(        Evaluator evaluator){
          currentCursor.setContext(evaluator);
        }
        @Override public void currentToArray(        Member[] members,        int offset){
          currentCursor.currentToArray(members,offset);
        }
        @Override public Member member(        int column){
          return currentCursor.member(column);
        }
      }
;
    }
  }
;
}
Program: 51050
Project: 51050
Buggy source:
public Calc compileCall(final ResolvedFunCall call,ExpCompiler compiler){
  final ListCalc listCalc=compiler.compileList(call.getArg(0),true);
  final IntegerCalc integerCalc=compiler.compileInteger(call.getArg(1));
  final Calc orderCalc=call.getArgCount() > 2 ? compiler.compileScalar(call.getArg(2),true) : null;
  final int arity=call.getType().getArity();
  return new AbstractListCalc(call,new Calc[]{listCalc,integerCalc,orderCalc}){
    public TupleList evaluateList(    Evaluator evaluator){
      SchemaReader schemaReader=evaluator.getSchemaReader();
      NativeEvaluator nativeEvaluator=schemaReader.getNativeSetEvaluator(call.getFunDef(),call.getArgs(),evaluator,this);
      if (nativeEvaluator != null) {
        return (TupleList)nativeEvaluator.execute(ResultStyle.LIST);
      }
      int n=integerCalc.evaluateInteger(evaluator);
      if (n == 0 || n == mondrian.olap.fun.FunUtil.IntegerNull) {
        return TupleCollections.emptyList(arity);
      }
      TupleList list=listCalc.evaluateList(evaluator);
      if (list.isEmpty()) {
        return list;
      }
      if (orderCalc == null) {
        if (list instanceof AbstractList && list.size() < n) {
          return list;
        }
 else {
          return list.subList(0,n);
        }
      }
      return partiallySortList(evaluator,list,hasHighCardDimension(list),n,arity);
    }
    private TupleList partiallySortList(    Evaluator evaluator,    TupleList list,    boolean highCard,    int n,    int arity){
      if (highCard) {
        final int chunkSize=6400;
        TupleList allChunkResults=TupleCollections.createList(arity);
        for (int i=0, next; i < list.size(); i=next) {
          next=Math.min(i + chunkSize,list.size());
          final TupleList chunk=list.subList(i,next);
          TupleList chunkResult=partiallySortList(evaluator,chunk,false,n,arity);
          allChunkResults.addAll(chunkResult);
        }
        return partiallySortList(evaluator,allChunkResults,false,n,arity);
      }
      return new DelegatingTupleList(list.getArity(),partiallySortTuples(evaluator.push(),list,orderCalc,n,top,arity));
    }
    public boolean dependsOn(    Hierarchy hierarchy){
      return anyDependsButFirst(getCalcs(),hierarchy);
    }
    private boolean hasHighCardDimension(    TupleList l){
      final List<Member> trial=l.get(0);
      for (      Member m : trial) {
        if (m.getHierarchy().getDimension().isHighCardinality()) {
          return true;
        }
      }
      return false;
    }
  }
;
}

Fixed version (ground truth):
public Calc compileCall(final ResolvedFunCall call,ExpCompiler compiler){
}
Program: 51051
Project: 51051
Buggy source:
/** 
 * Returns whether there is a cached segment body available for a given segment header. <p>If no cache is configured or there is an error while querying the cache, false is returned none the less. To throw an exception, enable  {@link MondrianProperties#SegmentCacheFailOnError} To adjusttimeout values, set  {@link MondrianProperties#SegmentCacheLookupTimeout}
 * @param header A header to search for in the segment cache.
 * @return True or false, whether there is a segment bodyavailable in a segment cache.
 */
public final static Boolean contains(SegmentHeader header){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      return closureSC.contains(header).get(MondrianProperties.instance().SegmentCacheLookupTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheLookupTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheLookupTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error(MondrianResource.instance().SegmentCacheFailedToLookupSegment.baseMessage,t);
      throw MondrianResource.instance().SegmentCacheFailedToLookupSegment.ex(t);
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns whether there is a cached segment body available for a given segment header. <p>If no cache is configured or there is an error while querying the cache, false is returned none the less. To adjust timeout values, set  {@link MondrianProperties#SegmentCacheLookupTimeout}
 * @param header A header to search for in the segment cache.
 * @return True or false, whether there is a segment bodyavailable in a segment cache.
 */
public final static Boolean contains(SegmentHeader header){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      return closureSC.contains(header).get(MondrianProperties.instance().SegmentCacheLookupTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheLookupTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheLookupTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error(MondrianResource.instance().SegmentCacheFailedToLookupSegment.baseMessage,t);
      throw MondrianResource.instance().SegmentCacheFailedToLookupSegment.ex(t);
    }
  }
  return false;
}
Program: 51052
Project: 51052
Buggy source:
/** 
 * Returns a segment body corresponding to a header. <p>If no cache is configured or there is an error while querying the cache, null is returned none the less. To throw an exception, enable  {@link MondrianProperties#SegmentCacheFailOnError} To adjusttimeout values, set  {@link MondrianProperties#SegmentCacheReadTimeout}
 * @param header Header to search.
 * @return Either a segment body object or null if therewas no cache configured or no segment could be found for the passed header.
 */
public final static SegmentBody get(SegmentHeader header){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      return closureSC.get(header).get(MondrianProperties.instance().SegmentCacheReadTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheReadTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheReadTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error(MondrianResource.instance().SegmentCacheFailedToLoadSegment.baseMessage,t);
      throw MondrianResource.instance().SegmentCacheFailedToLoadSegment.ex(t);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns a segment body corresponding to a header. <p>If no cache is configured or there is an error while querying the cache, null is returned none the less. To adjust timeout values, set   {@link MondrianProperties#SegmentCacheReadTimeout}
 * @param header Header to search.
 * @return Either a segment body object or null if therewas no cache configured or no segment could be found for the passed header.
 */
public final static SegmentBody get(SegmentHeader header){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      return closureSC.get(header).get(MondrianProperties.instance().SegmentCacheReadTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheReadTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheReadTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error(MondrianResource.instance().SegmentCacheFailedToLoadSegment.baseMessage,t);
      throw MondrianResource.instance().SegmentCacheFailedToLoadSegment.ex(t);
    }
  }
  return null;
}
Program: 51053
Project: 51053
Buggy source:
/** 
 * Returns a list of segments present in the cache. <p>If no cache is configured or there is an error while querying the cache, an empty list is returned none the less. To throw an exception, enable  {@link MondrianProperties#SegmentCacheFailOnError} To adjusttimeout values, set  {@link MondrianProperties#SegmentCacheScanTimeout}
 * @return Either a list of header objects or an empty list if therewas no cache configured or no segment could be found
 */
public final static List<SegmentHeader> getSegmentHeaders(){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      return closureSC.getSegmentHeaders().get(MondrianProperties.instance().SegmentCacheScanTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheScanTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheScanTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error("String_Node_Str",t);
      throw MondrianResource.instance().SegmentCacheFailedToScanSegments.ex(t);
    }
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
/** 
 * Returns a list of segments present in the cache. <p>If no cache is configured or there is an error while querying the cache, an empty list is returned none the less. To adjust timeout values, set  {@link MondrianProperties#SegmentCacheScanTimeout}
 * @return Either a list of header objects or an empty list if therewas no cache configured or no segment could be found
 */
public final static List<SegmentHeader> getSegmentHeaders(){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      return closureSC.getSegmentHeaders().get(MondrianProperties.instance().SegmentCacheScanTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheScanTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheScanTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error("String_Node_Str",t);
      throw MondrianResource.instance().SegmentCacheFailedToScanSegments.ex(t);
    }
  }
  return Collections.emptyList();
}
Program: 51054
Project: 51054
Buggy source:
/** 
 * Places a segment in the cache. Returns true or false if the operation succeeds. <p>To throw an exception, enable  {@link MondrianProperties#SegmentCacheFailOnError} To adjusttimeout values, set  {@link MondrianProperties#SegmentCacheWriteTimeout}
 * @param header A header to search for in the segment cache.
 */
public final static void put(SegmentHeader header,SegmentBody body){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      final boolean result=closureSC.put(header,body).get(MondrianProperties.instance().SegmentCacheWriteTimeout.get(),TimeUnit.MILLISECONDS);
      if (!result) {
        LOGGER.error(MondrianResource.instance().SegmentCacheFailedToSaveSegment.baseMessage);
        throw MondrianResource.instance().SegmentCacheFailedToSaveSegment.ex();
      }
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheReadTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheReadTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error(MondrianResource.instance().SegmentCacheFailedToSaveSegment.baseMessage,t);
      throw MondrianResource.instance().SegmentCacheFailedToSaveSegment.ex(t);
    }
  }
}

Fixed version (ground truth):
/** 
 * Places a segment in the cache. Returns true or false if the operation succeeds. <p>To adjust timeout values, set  {@link MondrianProperties#SegmentCacheWriteTimeout}
 * @param header A header to search for in the segment cache.
 */
public final static void put(SegmentHeader header,SegmentBody body){
  final SegmentCache closureSC=segmentCache;
  if (closureSC != null) {
    try {
      final boolean result=closureSC.put(header,body).get(MondrianProperties.instance().SegmentCacheWriteTimeout.get(),TimeUnit.MILLISECONDS);
      if (!result) {
        LOGGER.error(MondrianResource.instance().SegmentCacheFailedToSaveSegment.baseMessage);
        throw MondrianResource.instance().SegmentCacheFailedToSaveSegment.ex();
      }
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheReadTimeout.baseMessage,e);
      throw MondrianResource.instance().SegmentCacheReadTimeout.ex(e);
    }
catch (    Throwable t) {
      LOGGER.error(MondrianResource.instance().SegmentCacheFailedToSaveSegment.baseMessage,t);
      throw MondrianResource.instance().SegmentCacheFailedToSaveSegment.ex(t);
    }
  }
}
Program: 51055
Project: 51055
Buggy source:
public byte[] call() throws Exception {
  return get(url,request);
}

Fixed version (ground truth):
public byte[] call() throws Exception {
  return get(infos,request);
}
Program: 51056
Project: 51056
Buggy source:
public Future<byte[]> submit(final URL url,final String request){
  return singleThreadExecutor.submit(new Callable<byte[]>(){
    public byte[] call() throws Exception {
      return get(url,request);
    }
  }
);
}

Fixed version (ground truth):
public Future<byte[]> submit(final XmlaOlap4jServerInfos infos,final String request){
  return singleThreadExecutor.submit(new Callable<byte[]>(){
    public byte[] call() throws Exception {
      return get(infos,request);
    }
  }
);
}
Program: 51057
Project: 51057
Buggy source:
public byte[] get(URL url,String request) throws IOException {
  try {
    return XmlaSupport.processSoapXmla(request,urlString,catalogNameUrls,null,null,servletCache);
  }
 catch (  ServletException e) {
    throw new RuntimeException("String_Node_Str" + url + "String_Node_Str",e);
  }
catch (  SAXException e) {
    throw new RuntimeException("String_Node_Str" + url + "String_Node_Str",e);
  }
}

Fixed version (ground truth):
public byte[] get(XmlaOlap4jServerInfos infos,String request){
  try {
    return XmlaSupport.processSoapXmla(request,urlString,catalogNameUrls,null,null,servletCache);
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + infos.getUrl() + "String_Node_Str",e);
  }
}
Program: 51058
Project: 51058
Buggy source:
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  LOGGER.debug("String_Node_Str");
  Exp funArg=call.getArg(0);
  if (MondrianProperties.instance().UseAggregates.get() || MondrianProperties.instance().ReadAggregates.get()) {
    return funArg.accept(compiler);
  }
  final Calc[] calcs=new Calc[]{compiler.compileList(funArg,true)};
  final int arity=calcs[0].getType().getArity();
  if (arity < 1) {
    throw new IllegalArgumentException("String_Node_Str" + arity);
  }
 else   if (arity == 1 || substitutionMap.isEmpty()) {
    IterCalc calc=(IterCalc)funArg.accept(compiler);
    final boolean highCardinality=arity == 1 && isHighCardinality(funArg,compiler.getEvaluator());
    if (calc instanceof ListCalc) {
      return new NonNativeListCalc((ListCalc)calc,highCardinality);
    }
 else {
      return new NonNativeIterCalc(calc,highCardinality);
    }
  }
 else {
    if (isFirstCompileCall) {
      isFirstCompileCall=false;
      originalExp=funArg.clone();
      Query query=compiler.getEvaluator().getQuery();
      call.accept(new AddFormulasVisitor(query,substitutionMap,dimensions));
      call.accept(new TransformToFormulasVisitor(query));
      query.resolve();
    }
    return new NativeListCalc(call,calcs,compiler,substitutionMap,originalExp);
  }
}

Fixed version (ground truth):
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
}
Program: 51059
Project: 51059
Buggy source:
protected NonNativeCalc(Calc parent,final boolean nativeEnabled){
  this.parent=parent;
  this.nativeEnabled=nativeEnabled;
}

Fixed version (ground truth):
protected NonNativeCalc(Calc parent,final boolean nativeEnabled){
}
Program: 51060
Project: 51060
Buggy source:
public static String toString(List<Position> pl){
  StringBuilder buf=new StringBuilder();
  for (  Position p : pl) {
    buf.append('{');
    boolean firstTime=true;
    for (    Member m : p) {
      if (!firstTime) {
        buf.append("String_Node_Str");
      }
      buf.append(m.getUniqueName());
      firstTime=false;
    }
    buf.append('}');
    buf.append('\n');
  }
  return buf.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return getList().toString();
}
Program: 51061
Project: 51061
Buggy source:
protected TupleList executeList(final SqlTupleReader tr){
  tr.setMaxRows(maxRows);
  for (  CrossJoinArg arg : args) {
    addLevel(tr,arg);
  }
  Object key=tr.getCacheKey();
  TupleList result=cache.get(key);
  boolean hasEnumTargets=(tr.getEnumTargetCount() > 0);
  if (result != null && !hasEnumTargets) {
    if (listener != null) {
      TupleEvent e=new TupleEvent(this,tr);
      listener.foundInCache(e);
    }
    return new DelegatingTupleList(args.length,Util.<List<Member>>cast(result));
  }
  if (result == null && listener != null) {
    TupleEvent e=new TupleEvent(this,tr);
    listener.executingSql(e);
  }
  TupleList partialResult=result;
  List<List<RolapMember>> newPartialResult=null;
  if (hasEnumTargets && partialResult == null) {
    newPartialResult=new ArrayList<List<RolapMember>>();
  }
  DataSource dataSource=schemaReader.getDataSource();
  if (args.length == 1) {
    result=tr.readMembers(dataSource,partialResult,newPartialResult);
  }
 else {
    result=tr.readTuples(dataSource,partialResult,newPartialResult);
  }
  if (hasEnumTargets) {
    if (newPartialResult != null) {
      cache.put(key,new DelegatingTupleList(args.length,Util.<List<Member>>cast(newPartialResult)));
    }
  }
 else {
    cache.put(key,result);
  }
  return result;
}

Fixed version (ground truth):
protected TupleList executeList(final SqlTupleReader tr){
  tr.setMaxRows(maxRows);
  for (  CrossJoinArg arg : args) {
    addLevel(tr,arg);
  }
  List<Object> key=new ArrayList<Object>();
  key.add(tr.getCacheKey());
  key.addAll(Arrays.asList(args));
  TupleList result=cache.get(key);
  boolean hasEnumTargets=(tr.getEnumTargetCount() > 0);
  if (result != null && !hasEnumTargets) {
    if (listener != null) {
      TupleEvent e=new TupleEvent(this,tr);
      listener.foundInCache(e);
    }
    return new DelegatingTupleList(args.length,Util.<List<Member>>cast(result));
  }
  if (result == null && listener != null) {
    TupleEvent e=new TupleEvent(this,tr);
    listener.executingSql(e);
  }
  TupleList partialResult=result;
  List<List<RolapMember>> newPartialResult=null;
  if (hasEnumTargets && partialResult == null) {
    newPartialResult=new ArrayList<List<RolapMember>>();
  }
  DataSource dataSource=schemaReader.getDataSource();
  if (args.length == 1) {
    result=tr.readMembers(dataSource,partialResult,newPartialResult);
  }
 else {
    result=tr.readTuples(dataSource,partialResult,newPartialResult);
  }
  if (hasEnumTargets) {
    if (newPartialResult != null) {
      cache.put(key,new DelegatingTupleList(args.length,Util.<List<Member>>cast(newPartialResult)));
    }
  }
 else {
    cache.put(key,result);
  }
  return result;
}
Program: 51062
Project: 51062
Buggy source:
/** 
 * Returns whether certain member types(e.g. calculated members) should disable native SQL evaluation for expressions containing them. <p> If true, expressions containing calculated members will be evaluated by the interpreter, instead of using SQL. If false, calc members will be ignored and the computation will be done in SQL, returning more members than requested.  This is ok, if the superflous members are filtered out in java code afterwards. </p>
 */
protected abstract boolean restrictMemberTypes();

Fixed version (ground truth):
/** 
 * Returns whether certain member types (e.g. calculated members) should disable native SQL evaluation for expressions containing them. <p>If true, expressions containing calculated members will be evaluated by the interpreter, instead of using SQL. <p>If false, calc members will be ignored and the computation will be done in SQL, returning more members than requested.  This is ok, if the superflous members are filtered out in java code afterwards.
 * @return whether certain member types should disable native SQL evaluation
 */
protected abstract boolean restrictMemberTypes();
Program: 51063
Project: 51063
Buggy source:
/** 
 * Returns a list of segments present in the cache. <p>If no cache is configured or there is an error while querying the cache, an empty list is returned none the less. To throw an exception, enable  {@link MondrianProperties#SegmentCacheFailOnError} To adjusttimeout values, set  {@link MondrianProperties#SegmentCacheScanTimeout}
 * @param header Header to search.
 * @return Either a segment body object or null if therewas no cache configured or no segment could be found for the passed header.
 */
public final static List<SegmentHeader> getSegmentHeaders(){
  if (segmentCache != null) {
    try {
      return segmentCache.getSegmentHeaders().get(MondrianProperties.instance().SegmentCacheScanTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheScanTimeout.baseMessage,e);
      if (MondrianProperties.instance().SegmentCacheFailOnError.get()) {
        throw MondrianResource.instance().SegmentCacheScanTimeout.ex(e);
      }
    }
catch (    Throwable t) {
      LOGGER.error("String_Node_Str",t);
      if (MondrianProperties.instance().SegmentCacheFailOnError.get()) {
        throw MondrianResource.instance().SegmentCacheFailedToScanSegments.ex(t);
      }
    }
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
/** 
 * Returns a list of segments present in the cache. <p>If no cache is configured or there is an error while querying the cache, an empty list is returned none the less. To throw an exception, enable  {@link MondrianProperties#SegmentCacheFailOnError} To adjusttimeout values, set  {@link MondrianProperties#SegmentCacheScanTimeout}
 * @return Either a list of header objects or an empty list if therewas no cache configured or no segment could be found
 */
public final static List<SegmentHeader> getSegmentHeaders(){
  if (segmentCache != null) {
    try {
      return segmentCache.getSegmentHeaders().get(MondrianProperties.instance().SegmentCacheScanTimeout.get(),TimeUnit.MILLISECONDS);
    }
 catch (    TimeoutException e) {
      LOGGER.error(MondrianResource.instance().SegmentCacheScanTimeout.baseMessage,e);
      if (MondrianProperties.instance().SegmentCacheFailOnError.get()) {
        throw MondrianResource.instance().SegmentCacheScanTimeout.ex(e);
      }
    }
catch (    Throwable t) {
      LOGGER.error("String_Node_Str",t);
      if (MondrianProperties.instance().SegmentCacheFailOnError.get()) {
        throw MondrianResource.instance().SegmentCacheFailedToScanSegments.ex(t);
      }
    }
  }
  return Collections.emptyList();
}
Program: 51064
Project: 51064
Buggy source:
/** 
 * Returns the SQL type of the data contained in this dataset.
 * @return A value of {@link SqlStatement.Type}
 */
SqlStatement.Type getType();

Fixed version (ground truth):
/** 
 * Returns the SQL type of the data contained in this dataset.
 * @return A value of SqlStatement.Type
 */
SqlStatement.Type getType();
Program: 51066
Project: 51066
Buggy source:
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  final Exp[] args=call.getArgs();
  Calc[] calcs=new Calc[args.length];
  UserDefinedFunction.Argument[] expCalcs=new UserDefinedFunction.Argument[args.length];
  for (int i=0; i < args.length; i++) {
    Exp arg=args[i];
    final Calc calc=compiler.compileAs(arg,castType(arg.getType(),parameterCategories[i]),ResultStyle.ANY_LIST);
    final Calc scalarCalc=compiler.compileScalar(arg,true);
    expCalcs[i]=new CalcExp(calc,scalarCalc);
  }
  UserDefinedFunction udf2=Util.createUdf(udf.getClass(),udf.getName());
  return new CalcImpl(call,calcs,udf2,expCalcs);
}

Fixed version (ground truth):
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
  final Exp[] args=call.getArgs();
  Calc[] calcs=new Calc[args.length];
  UserDefinedFunction.Argument[] expCalcs=new UserDefinedFunction.Argument[args.length];
  for (int i=0; i < args.length; i++) {
    Exp arg=args[i];
    final Calc calc=compiler.compileAs(arg,castType(arg.getType(),parameterCategories[i]),ResultStyle.ANY_LIST);
    final Calc scalarCalc=compiler.compileScalar(arg,true);
    expCalcs[i]=new CalcExp(calc,scalarCalc);
  }
  UserDefinedFunction udf2=Util.createUdf(udf.getClass(),udf.getName());
  if (call.getType() instanceof SetType) {
    return new ListCalcImpl(call,calcs,udf2,expCalcs);
  }
 else {
    return new ScalarCalcImpl(call,calcs,udf2,expCalcs);
  }
}
Program: 51069
Project: 51069
Buggy source:
public DateTimeCalc compileDateTime(Exp exp){
  return (DateTimeCalc)compile(exp);
}

Fixed version (ground truth):
public DateTimeCalc compileDateTime(Exp exp){
  return (DateTimeCalc)compileScalar(exp,false);
}
Program: 51070
Project: 51070
Buggy source:
public StringCalc compileString(Exp exp){
  return (StringCalc)compile(exp);
}

Fixed version (ground truth):
public StringCalc compileString(Exp exp){
  return (StringCalc)compileScalar(exp,false);
}
Program: 51072
Project: 51072
Buggy source:
@FunctionName("String_Node_Str") @Signature("String_Node_Str") @Description("String_Node_Str") public static String mid(String value,int beginIndex,int length){
  if (beginIndex < 0) {
    throw new InvalidArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (length < 0) {
    throw new InvalidArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (beginIndex >= value.length()) {
    return "String_Node_Str";
  }
  if (beginIndex != 0) {
    --beginIndex;
  }
  int endIndex=beginIndex + length;
  return endIndex >= value.length() ? value.substring(beginIndex) : value.substring(beginIndex,endIndex);
}

Fixed version (ground truth):
@FunctionName("String_Node_Str") @Signature("String_Node_Str") @Description("String_Node_Str") public static String mid(String value,int beginIndex,int length){
  if (beginIndex <= 0) {
    throw new InvalidArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (length < 0) {
    throw new InvalidArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (beginIndex > value.length()) {
    return "String_Node_Str";
  }
  --beginIndex;
  int endIndex=beginIndex + length;
  return endIndex >= value.length() ? value.substring(beginIndex) : value.substring(beginIndex,endIndex);
}
Program: 51074
Project: 51074
Buggy source:
private Level getTimeLevel(LevelType levelType){
  for (  Dimension dimension : dimensions) {
    if (dimension.getDimensionType() == DimensionType.TimeDimension) {
      Hierarchy[] hierarchies=dimension.getHierarchies();
      for (      Hierarchy hierarchy : hierarchies) {
        Level[] levels=hierarchy.getLevels();
        for (        Level level : levels) {
          if (level.getLevelType() == levelType) {
            return level;
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the first level of a given type in this cube.
 * @param levelType Level type
 * @return First level of given type, or null
 */
private Level getTimeLevel(LevelType levelType){
  for (  Dimension dimension : dimensions) {
    if (dimension.getDimensionType() == DimensionType.TimeDimension) {
      Hierarchy[] hierarchies=dimension.getHierarchies();
      for (      Hierarchy hierarchy : hierarchies) {
        Level[] levels=hierarchy.getLevels();
        for (        Level level : levels) {
          if (level.getLevelType() == levelType) {
            return level;
          }
        }
      }
    }
  }
  return null;
}
Program: 51075
Project: 51075
Buggy source:
public Dimension lookupDimension(Id.Segment s){
  for (  Dimension dimension : dimensions) {
    if (Util.equalName(dimension.getName(),s.name)) {
      return dimension;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Looks up a dimension in this cube based on a component of its name.
 * @param s Name segment
 * @return Dimension, or null if not found
 */
public Dimension lookupDimension(Id.Segment s){
  for (  Dimension dimension : dimensions) {
    if (Util.equalName(dimension.getName(),s.name)) {
      return dimension;
    }
  }
  return null;
}
Program: 51076
Project: 51076
Buggy source:
protected CubeBase(String name,Dimension[] dimensions){
  this.name=name;
  this.dimensions=dimensions;
}

Fixed version (ground truth):
/** 
 * Creates a CubeBase.
 * @param name Name
 * @param dimensions List of dimensions
 */
protected CubeBase(String name,Dimension[] dimensions){
  this.name=name;
  this.dimensions=dimensions;
  this.uniqueName=Util.quoteMdxIdentifier(name);
}
Program: 51077
Project: 51077
Buggy source:
public String getUniqueName(){
  return Util.quoteMdxIdentifier(name);
}

Fixed version (ground truth):
public String getUniqueName(){
  return uniqueName;
}
Program: 51079
Project: 51079
Buggy source:
Axis evalExecute(List<List<Member>> nonAllMembers,int cnt,RolapEvaluator evaluator,QueryAxis axis,Calc calc){
  Axis axisResult=null;
  if (cnt < 0) {
    evaluator.setCellReader(aggregatingReader);
    axisResult=executeAxis(evaluator.push(),axis,calc,true,null);
  }
 else {
    for (    Member m : nonAllMembers.get(cnt)) {
      evaluator.setContext(m);
      Axis a=evalExecute(nonAllMembers,cnt - 1,evaluator,axis,calc);
      boolean ordered=false;
      if (axis != null) {
        ordered=axis.isOrdered();
      }
      axisResult=mergeAxes(axisResult,a,evaluator,ordered);
    }
  }
  return axisResult;
}

Fixed version (ground truth):
Axis evalExecute(List<List<Member>> nonAllMembers,int cnt,RolapEvaluator evaluator,QueryAxis axis,Calc calc){
  if (cnt < 0) {
    evaluator.setCellReader(aggregatingReader);
    return executeAxis(evaluator.push(),axis,calc,true,null);
  }
 else {
    Axis axisResult=null;
    for (    Member m : nonAllMembers.get(cnt)) {
      evaluator.setContext(m);
      Axis a=evalExecute(nonAllMembers,cnt - 1,evaluator,axis,calc);
      boolean ordered=false;
      if (axis != null) {
        ordered=axis.isOrdered();
      }
      axisResult=mergeAxes(axisResult,a,evaluator,ordered);
    }
    return axisResult;
  }
}