nus-yam/ex-repair huggingface dataset:
Program: 61173
Project: 61173
Buggy source:
/** 
 * (re)Parallelize DRM data according to new partitioning hints.
 * @param drmA Input DRM containing data.
 * @param min Hint of minimum number of partitions to parallelize, if not -1.
 * @param exact Hint of exact number of partitions to parallelize, if not -1.
 * @return new DRM holding the same data but parallelized according to new hints.
 */
public static H2ODrm exec(H2ODrm drmA,int min,int exact){
  final Frame frin=drmA.frame;
  final Vec vin=drmA.keys;
  Frame frout=H2OHelper.emptyFrame(frin.numRows(),frin.numCols(),min,exact);
  Vec vout=null;
  if (vin != null) {
    vout=new MRTask(){
      public void map(      Chunk chks[],      NewChunk nc){
        int chunkSize=chks[0].len();
        Vec vins[]=frin.vecs();
        long start=chks[0].start();
        ValueString vstr=new ValueString();
        for (int r=0; r < chunkSize; r++) {
          for (int c=0; c < chks.length; c++) {
            chks[c].set0(r,vins[c].at(start + r));
          }
          nc.addStr(vin.atStr(vstr,start + r));
        }
      }
    }
.doAll(1,frout).outputFrame(null,null).anyVec();
  }
 else {
    new MRTask(){
      public void map(      Chunk chks[]){
        int chunkSize=chks[0].len();
        Vec vins[]=frin.vecs();
        long start=chks[0].start();
        for (int r=0; r < chunkSize; r++) {
          for (int c=0; c < chks.length; c++) {
            chks[c].set0(r,vins[c].at(start + r));
          }
        }
      }
    }
.doAll(frout);
  }
  return new H2ODrm(frout,vout);
}

Fixed version (ground truth):
/** 
 * (re)Parallelize DRM data according to new partitioning hints.
 * @param drmA Input DRM containing data.
 * @param min Hint of minimum number of partitions to parallelize, if not -1.
 * @param exact Hint of exact number of partitions to parallelize, if not -1.
 * @return new DRM holding the same data but parallelized according to new hints.
 */
public static H2ODrm exec(H2ODrm drmA,int min,int exact){
  final Frame frin=drmA.frame;
  final Vec vin=drmA.keys;
  Frame frout=H2OHelper.emptyFrame(frin.numRows(),frin.numCols(),min,exact);
  Vec vout=null;
  if (vin != null) {
    vout=new MRTask(){
      public void map(      Chunk chks[],      NewChunk nc){
        int chunkSize=chks[0].len();
        Vec vins[]=frin.vecs();
        long start=chks[0].start();
        ValueString vstr=new ValueString();
        for (int r=0; r < chunkSize; r++) {
          for (int c=0; c < chks.length; c++) {
            chks[c].set(r,vins[c].at(start + r));
          }
          nc.addStr(vin.atStr(vstr,start + r));
        }
      }
    }
.doAll(1,frout).outputFrame(null,null).anyVec();
  }
 else {
    new MRTask(){
      public void map(      Chunk chks[]){
        int chunkSize=chks[0].len();
        Vec vins[]=frin.vecs();
        long start=chks[0].start();
        for (int r=0; r < chunkSize; r++) {
          for (int c=0; c < chks.length; c++) {
            chks[c].set(r,vins[c].at(start + r));
          }
        }
      }
    }
.doAll(frout);
  }
  return new H2ODrm(frout,vout);
}
Program: 61174
Project: 61174
Buggy source:
public void map(Chunk chks[],NewChunk nc){
  Vec A_vecs[]=fra.vecs();
  Vec B_vecs[]=frb.vecs();
  long A_rows=fra.numRows();
  long B_rows=frb.numRows();
  long start=chks[0].start();
  int chunkSize=chks[0].len();
  ValueString vstr=new ValueString();
  for (int r=0; r < chunkSize; r++) {
    for (int c=0; c < chks.length; c++) {
      if (r + start < A_rows) {
        chks[c].set0(r,A_vecs[c].at(r + start));
        if (keysa != null) {
          nc.addStr(keysa.atStr(vstr,r + start));
        }
      }
 else {
        chks[c].set0(r,B_vecs[c].at(r + start - A_rows));
        if (keysb != null) {
          nc.addStr(keysb.atStr(vstr,r + start - A_rows));
        }
      }
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[],NewChunk nc){
  Vec A_vecs[]=fra.vecs();
  Vec B_vecs[]=frb.vecs();
  long A_rows=fra.numRows();
  long B_rows=frb.numRows();
  long start=chks[0].start();
  int chunkSize=chks[0].len();
  ValueString vstr=new ValueString();
  for (int r=0; r < chunkSize; r++) {
    for (int c=0; c < chks.length; c++) {
      if (r + start < A_rows) {
        chks[c].set(r,A_vecs[c].at(r + start));
        if (keysa != null) {
          nc.addStr(keysa.atStr(vstr,r + start));
        }
      }
 else {
        chks[c].set(r,B_vecs[c].at(r + start - A_rows));
        if (keysb != null) {
          nc.addStr(keysb.atStr(vstr,r + start - A_rows));
        }
      }
    }
  }
}
Program: 61175
Project: 61175
Buggy source:
/** 
 * Combine the rows of two DRMs A and B to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param drmB DRM representing matrix B.
 * @return new DRM containing rows of B below A.
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB){
  final Frame fra=drmA.frame;
  final Vec keysa=drmA.keys;
  final Frame frb=drmB.frame;
  final Vec keysb=drmB.keys;
  Frame frbind=H2OHelper.emptyFrame(fra.numRows() + frb.numRows(),fra.numCols(),-1,-1,fra.anyVec().group());
  Vec keys=null;
  MRTask task=new MRTask(){
    public void map(    Chunk chks[],    NewChunk nc){
      Vec A_vecs[]=fra.vecs();
      Vec B_vecs[]=frb.vecs();
      long A_rows=fra.numRows();
      long B_rows=frb.numRows();
      long start=chks[0].start();
      int chunkSize=chks[0].len();
      ValueString vstr=new ValueString();
      for (int r=0; r < chunkSize; r++) {
        for (int c=0; c < chks.length; c++) {
          if (r + start < A_rows) {
            chks[c].set0(r,A_vecs[c].at(r + start));
            if (keysa != null) {
              nc.addStr(keysa.atStr(vstr,r + start));
            }
          }
 else {
            chks[c].set0(r,B_vecs[c].at(r + start - A_rows));
            if (keysb != null) {
              nc.addStr(keysb.atStr(vstr,r + start - A_rows));
            }
          }
        }
      }
    }
  }
;
  if (keysa == null) {
    keys=task.doAll(1,frbind).outputFrame(null,null).anyVec();
  }
 else {
    task.doAll(frbind);
  }
  return new H2ODrm(frbind,keys);
}

Fixed version (ground truth):
/** 
 * Combine the rows of two DRMs A and B to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param drmB DRM representing matrix B.
 * @return new DRM containing rows of B below A.
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB){
  final Frame fra=drmA.frame;
  final Vec keysa=drmA.keys;
  final Frame frb=drmB.frame;
  final Vec keysb=drmB.keys;
  Frame frbind=H2OHelper.emptyFrame(fra.numRows() + frb.numRows(),fra.numCols(),-1,-1,fra.anyVec().group());
  Vec keys=null;
  MRTask task=new MRTask(){
    public void map(    Chunk chks[],    NewChunk nc){
      Vec A_vecs[]=fra.vecs();
      Vec B_vecs[]=frb.vecs();
      long A_rows=fra.numRows();
      long B_rows=frb.numRows();
      long start=chks[0].start();
      int chunkSize=chks[0].len();
      ValueString vstr=new ValueString();
      for (int r=0; r < chunkSize; r++) {
        for (int c=0; c < chks.length; c++) {
          if (r + start < A_rows) {
            chks[c].set(r,A_vecs[c].at(r + start));
            if (keysa != null) {
              nc.addStr(keysa.atStr(vstr,r + start));
            }
          }
 else {
            chks[c].set(r,B_vecs[c].at(r + start - A_rows));
            if (keysb != null) {
              nc.addStr(keysb.atStr(vstr,r + start - A_rows));
            }
          }
        }
      }
    }
  }
;
  if (keysa == null) {
    keys=task.doAll(1,frbind).outputFrame(null,null).anyVec();
  }
 else {
    task.doAll(frbind);
  }
  return new H2ODrm(frbind,keys);
}
Program: 61176
Project: 61176
Buggy source:
public void map(Chunk chk,NewChunk nc){
  int chunkSize=chk.len();
  long chunkStart=chk.start();
  ValueString vstr=new ValueString();
  if (chunkStart > R.end() || (chunkStart + chunkSize) < R.start()) {
    return;
  }
  for (int r=0; r < chunkSize; r++) {
    if (!R.contains(chunkStart + r)) {
      continue;
    }
    nc.addStr(chk.atStr0(vstr,r));
  }
}

Fixed version (ground truth):
public void map(Chunk chk,NewChunk nc){
  int chunkSize=chk.len();
  long chunkStart=chk.start();
  ValueString vstr=new ValueString();
  if (chunkStart > R.end() || (chunkStart + chunkSize) < R.start()) {
    return;
  }
  for (int r=0; r < chunkSize; r++) {
    if (!R.contains(chunkStart + r)) {
      continue;
    }
    nc.addStr(chk.atStr(vstr,r));
  }
}
Program: 61177
Project: 61177
Buggy source:
/** 
 * Filter rows from intput DRM, to include only row indiced included in R.
 * @param drmA Input DRM.
 * @param R Range object specifying the start and end row numbers to filter.
 * @return new DRM with just the filtered rows.
 */
public static H2ODrm exec(H2ODrm drmA,final Range R){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  Frame Arr=new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      long chunkStart=chks[0].start();
      if (chunkStart > R.end() || (chunkStart + chunkSize) < R.start()) {
        return;
      }
      for (int r=0; r < chunkSize; r++) {
        if (!R.contains(chunkStart + r)) {
          continue;
        }
        for (int c=0; c < chks.length; c++) {
          ncs[c].addNum(chks[c].at0(r));
        }
      }
    }
  }
.doAll(A.numCols(),A).outputFrame(null,null);
  Vec Vrr=(keys == null) ? null : new MRTask(){
    public void map(    Chunk chk,    NewChunk nc){
      int chunkSize=chk.len();
      long chunkStart=chk.start();
      ValueString vstr=new ValueString();
      if (chunkStart > R.end() || (chunkStart + chunkSize) < R.start()) {
        return;
      }
      for (int r=0; r < chunkSize; r++) {
        if (!R.contains(chunkStart + r)) {
          continue;
        }
        nc.addStr(chk.atStr0(vstr,r));
      }
    }
  }
.doAll(1,keys).outputFrame(null,null).anyVec();
  return new H2ODrm(Arr,Vrr);
}

Fixed version (ground truth):
/** 
 * Filter rows from intput DRM, to include only row indiced included in R.
 * @param drmA Input DRM.
 * @param R Range object specifying the start and end row numbers to filter.
 * @return new DRM with just the filtered rows.
 */
public static H2ODrm exec(H2ODrm drmA,final Range R){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  Frame Arr=new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      long chunkStart=chks[0].start();
      if (chunkStart > R.end() || (chunkStart + chunkSize) < R.start()) {
        return;
      }
      for (int r=0; r < chunkSize; r++) {
        if (!R.contains(chunkStart + r)) {
          continue;
        }
        for (int c=0; c < chks.length; c++) {
          ncs[c].addNum(chks[c].atd(r));
        }
      }
    }
  }
.doAll(A.numCols(),A).outputFrame(null,null);
  Vec Vrr=(keys == null) ? null : new MRTask(){
    public void map(    Chunk chk,    NewChunk nc){
      int chunkSize=chk.len();
      long chunkStart=chk.start();
      ValueString vstr=new ValueString();
      if (chunkStart > R.end() || (chunkStart + chunkSize) < R.start()) {
        return;
      }
      for (int r=0; r < chunkSize; r++) {
        if (!R.contains(chunkStart + r)) {
          continue;
        }
        nc.addStr(chk.atStr(vstr,r));
      }
    }
  }
.doAll(1,keys).outputFrame(null,null).anyVec();
  return new H2ODrm(Arr,Vrr);
}
Program: 61178
Project: 61178
Buggy source:
/** 
 * Multiply Frame A with in-core diagonal Matrix (whose diagonal Vector is d) A.numCols() == d.size()
 */
private static Frame execDiagonal(final Frame A,Vector d){
  final H2OBCast<Vector> bd=new H2OBCast<Vector>(d);
  return new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      Vector D=bd.value();
      int chunkSize=chks[0].len();
      for (int c=0; c < ncs.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=(chks[c].at0(r) * D.getQuick(c));
          ncs[c].addNum(v);
        }
      }
    }
  }
.doAll(d.size(),A).outputFrame(null,null);
}

Fixed version (ground truth):
/** 
 * Multiply Frame A with in-core diagonal Matrix (whose diagonal Vector is d) A.numCols() == d.size()
 */
private static Frame execDiagonal(final Frame A,Vector d){
  final H2OBCast<Vector> bd=new H2OBCast<Vector>(d);
  return new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      Vector D=bd.value();
      int chunkSize=chks[0].len();
      for (int c=0; c < ncs.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=(chks[c].atd(r) * D.getQuick(c));
          ncs[c].addNum(v);
        }
      }
    }
  }
.doAll(d.size(),A).outputFrame(null,null);
}
Program: 61179
Project: 61179
Buggy source:
public void map(Chunk chks[],NewChunk ncs[]){
  Matrix B=bb.value();
  int chunkSize=chks[0].len();
  for (int c=0; c < ncs.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (int i=0; i < chks.length; i++) {
        v+=(chks[i].at0(r) * B.getQuick(i,c));
      }
      ncs[c].addNum(v);
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[],NewChunk ncs[]){
  Matrix B=bb.value();
  int chunkSize=chks[0].len();
  for (int c=0; c < ncs.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (int i=0; i < chks.length; i++) {
        v+=(chks[i].atd(r) * B.getQuick(i,c));
      }
      ncs[c].addNum(v);
    }
  }
}
Program: 61180
Project: 61180
Buggy source:
/** 
 * Multiply Frame A with in-core Matrix b A.numCols() == b.rowSize()
 */
private static Frame execCommon(final Frame A,Matrix b){
  final H2OBCast<Matrix> bb=new H2OBCast<Matrix>(b);
  return new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      Matrix B=bb.value();
      int chunkSize=chks[0].len();
      for (int c=0; c < ncs.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (int i=0; i < chks.length; i++) {
            v+=(chks[i].at0(r) * B.getQuick(i,c));
          }
          ncs[c].addNum(v);
        }
      }
    }
  }
.doAll(b.columnSize(),A).outputFrame(null,null);
}

Fixed version (ground truth):
/** 
 * Multiply Frame A with in-core Matrix b A.numCols() == b.rowSize()
 */
private static Frame execCommon(final Frame A,Matrix b){
  final H2OBCast<Matrix> bb=new H2OBCast<Matrix>(b);
  return new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      Matrix B=bb.value();
      int chunkSize=chks[0].len();
      for (int c=0; c < ncs.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (int i=0; i < chks.length; i++) {
            v+=(chks[i].atd(r) * B.getQuick(i,c));
          }
          ncs[c].addNum(v);
        }
      }
    }
  }
.doAll(b.columnSize(),A).outputFrame(null,null);
}
Program: 61181
Project: 61181
Buggy source:
@Override public Iterable<Centroid> call(){
  UpdatableSearcher searcher=StreamingKMeansUtilsMR.searcherFromConfiguration(conf);
  int numClusters=conf.getInt(StreamingKMeansDriver.ESTIMATED_NUM_MAP_CLUSTERS,1);
  double estimateDistanceCutoff=conf.getFloat(StreamingKMeansDriver.ESTIMATED_DISTANCE_CUTOFF,StreamingKMeansDriver.INVALID_DISTANCE_CUTOFF);
  Iterator<Centroid> dataPointsIterator=dataPoints.iterator();
  List<Centroid> dataPointsList=Lists.newArrayList();
  if (estimateDistanceCutoff == StreamingKMeansDriver.INVALID_DISTANCE_CUTOFF) {
    List<Centroid> estimatePoints=Lists.newArrayListWithExpectedSize(NUM_ESTIMATE_POINTS);
    while (dataPointsIterator.hasNext() && estimatePoints.size() < NUM_ESTIMATE_POINTS) {
      Centroid centroid=dataPointsIterator.next();
      estimatePoints.add(centroid);
      dataPointsList.add(centroid);
    }
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str",estimatePoints.size());
    }
    estimateDistanceCutoff=ClusteringUtils.estimateDistanceCutoff(estimatePoints,searcher.getDistanceMeasure());
  }
 else {
    Iterators.addAll(dataPointsList,dataPointsIterator);
  }
  StreamingKMeans streamingKMeans=new StreamingKMeans(searcher,numClusters,estimateDistanceCutoff);
  for (  Centroid aDataPoints : dataPointsList) {
    streamingKMeans.cluster(aDataPoints);
  }
  streamingKMeans.reindexCentroids();
  return streamingKMeans;
}

Fixed version (ground truth):
@Override public Iterable<Centroid> call(){
  UpdatableSearcher searcher=StreamingKMeansUtilsMR.searcherFromConfiguration(conf);
  int numClusters=conf.getInt(StreamingKMeansDriver.ESTIMATED_NUM_MAP_CLUSTERS,1);
  double estimateDistanceCutoff=conf.getFloat(StreamingKMeansDriver.ESTIMATED_DISTANCE_CUTOFF,StreamingKMeansDriver.INVALID_DISTANCE_CUTOFF);
  Iterator<Centroid> dataPointsIterator=dataPoints.iterator();
  if (estimateDistanceCutoff == StreamingKMeansDriver.INVALID_DISTANCE_CUTOFF) {
    List<Centroid> estimatePoints=Lists.newArrayListWithExpectedSize(NUM_ESTIMATE_POINTS);
    while (dataPointsIterator.hasNext() && estimatePoints.size() < NUM_ESTIMATE_POINTS) {
      Centroid centroid=dataPointsIterator.next();
      estimatePoints.add(centroid);
    }
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str",estimatePoints.size());
    }
    estimateDistanceCutoff=ClusteringUtils.estimateDistanceCutoff(estimatePoints,searcher.getDistanceMeasure());
  }
  StreamingKMeans streamingKMeans=new StreamingKMeans(searcher,numClusters,estimateDistanceCutoff);
  if (!dataPointsIterator.hasNext()) {
    dataPointsIterator=dataPoints.iterator();
  }
  while (dataPointsIterator.hasNext()) {
    streamingKMeans.cluster(dataPointsIterator.next());
  }
  streamingKMeans.reindexCentroids();
  return streamingKMeans;
}
Program: 61182
Project: 61182
Buggy source:
/** 
 * Story: User can produce final canopy centers using a EuclideanDistanceMeasure and a CanopyReducer which clusters input centroid points to produce an output set of final canopy centroid points.
 */
@Test public void testCanopyReducerEuclidean() throws Exception {
  CanopyReducer reducer=new CanopyReducer();
  Configuration conf=getConfiguration();
  conf.set(CanopyConfigKeys.DISTANCE_MEASURE_KEY,"String_Node_Str");
  conf.set(CanopyConfigKeys.T1_KEY,String.valueOf(3.1));
  conf.set(CanopyConfigKeys.T2_KEY,String.valueOf(2.1));
  conf.set(CanopyConfigKeys.CF_KEY,"String_Node_Str");
  DummyRecordWriter<Text,ClusterWritable> writer=new DummyRecordWriter<Text,ClusterWritable>();
  Reducer<Text,VectorWritable,Text,ClusterWritable>.Context context=DummyRecordWriter.build(reducer,conf,writer,Text.class,VectorWritable.class);
  reducer.setup(context);
  List<VectorWritable> points=getPointsWritable();
  reducer.reduce(new Text("String_Node_Str"),points,context);
  Set<Text> keys=writer.getKeys();
  assertEquals("String_Node_Str",3,keys.size());
  int i=0;
  for (  Text key : keys) {
    List<ClusterWritable> data=writer.getValue(key);
    ClusterWritable clusterWritable=data.get(0);
    Canopy canopy=(Canopy)clusterWritable.getValue();
    assertEquals(euclideanCentroids.get(i).asFormatString() + "String_Node_Str" + canopy.computeCentroid().asFormatString(),euclideanCentroids.get(i),canopy.computeCentroid());
    i++;
  }
}

Fixed version (ground truth):
/** 
 * Story: User can produce final canopy centers using a EuclideanDistanceMeasure and a CanopyReducer which clusters input centroid points to produce an output set of final canopy centroid points.
 */
@Test public void testCanopyReducerEuclidean() throws Exception {
  CanopyReducer reducer=new CanopyReducer();
  Configuration conf=getConfiguration();
  conf.set(CanopyConfigKeys.DISTANCE_MEASURE_KEY,"String_Node_Str");
  conf.set(CanopyConfigKeys.T1_KEY,String.valueOf(3.1));
  conf.set(CanopyConfigKeys.T2_KEY,String.valueOf(2.1));
  conf.set(CanopyConfigKeys.CF_KEY,"String_Node_Str");
  DummyRecordWriter<Text,ClusterWritable> writer=new DummyRecordWriter<Text,ClusterWritable>();
  Reducer<Text,VectorWritable,Text,ClusterWritable>.Context context=DummyRecordWriter.build(reducer,conf,writer,Text.class,VectorWritable.class);
  reducer.setup(context);
  List<VectorWritable> points=getPointsWritable();
  reducer.reduce(new Text("String_Node_Str"),points,context);
  Iterable<Text> keys=writer.getKeysInInsertionOrder();
  assertEquals("String_Node_Str",3,Iterables.size(keys));
  int i=0;
  for (  Text key : keys) {
    List<ClusterWritable> data=writer.getValue(key);
    ClusterWritable clusterWritable=data.get(0);
    Canopy canopy=(Canopy)clusterWritable.getValue();
    assertEquals(euclideanCentroids.get(i).asFormatString() + "String_Node_Str" + canopy.computeCentroid().asFormatString(),euclideanCentroids.get(i),canopy.computeCentroid());
    i++;
  }
}
Program: 61183
Project: 61183
Buggy source:
/** 
 * Story: User can produce final canopy centers using a ManhattanDistanceMeasure and a CanopyReducer which clusters input centroid points to produce an output set of final canopy centroid points.
 */
@Test public void testCanopyReducerManhattan() throws Exception {
  CanopyReducer reducer=new CanopyReducer();
  Configuration conf=getConfiguration();
  conf.set(CanopyConfigKeys.DISTANCE_MEASURE_KEY,"String_Node_Str");
  conf.set(CanopyConfigKeys.T1_KEY,String.valueOf(3.1));
  conf.set(CanopyConfigKeys.T2_KEY,String.valueOf(2.1));
  conf.set(CanopyConfigKeys.CF_KEY,"String_Node_Str");
  DummyRecordWriter<Text,ClusterWritable> writer=new DummyRecordWriter<Text,ClusterWritable>();
  Reducer<Text,VectorWritable,Text,ClusterWritable>.Context context=DummyRecordWriter.build(reducer,conf,writer,Text.class,VectorWritable.class);
  reducer.setup(context);
  List<VectorWritable> points=getPointsWritable();
  reducer.reduce(new Text("String_Node_Str"),points,context);
  Set<Text> keys=writer.getKeys();
  assertEquals("String_Node_Str",3,keys.size());
  int i=0;
  for (  Text key : keys) {
    List<ClusterWritable> data=writer.getValue(key);
    ClusterWritable clusterWritable=data.get(0);
    Canopy canopy=(Canopy)clusterWritable.getValue();
    assertEquals(manhattanCentroids.get(i).asFormatString() + "String_Node_Str" + canopy.computeCentroid().asFormatString(),manhattanCentroids.get(i),canopy.computeCentroid());
    i++;
  }
}

Fixed version (ground truth):
/** 
 * Story: User can produce final canopy centers using a ManhattanDistanceMeasure and a CanopyReducer which clusters input centroid points to produce an output set of final canopy centroid points.
 */
@Test public void testCanopyReducerManhattan() throws Exception {
  CanopyReducer reducer=new CanopyReducer();
  Configuration conf=getConfiguration();
  conf.set(CanopyConfigKeys.DISTANCE_MEASURE_KEY,"String_Node_Str");
  conf.set(CanopyConfigKeys.T1_KEY,String.valueOf(3.1));
  conf.set(CanopyConfigKeys.T2_KEY,String.valueOf(2.1));
  conf.set(CanopyConfigKeys.CF_KEY,"String_Node_Str");
  DummyRecordWriter<Text,ClusterWritable> writer=new DummyRecordWriter<Text,ClusterWritable>();
  Reducer<Text,VectorWritable,Text,ClusterWritable>.Context context=DummyRecordWriter.build(reducer,conf,writer,Text.class,VectorWritable.class);
  reducer.setup(context);
  List<VectorWritable> points=getPointsWritable();
  reducer.reduce(new Text("String_Node_Str"),points,context);
  Iterable<Text> keys=writer.getKeysInInsertionOrder();
  assertEquals("String_Node_Str",3,Iterables.size(keys));
  int i=0;
  for (  Text key : keys) {
    List<ClusterWritable> data=writer.getValue(key);
    ClusterWritable clusterWritable=data.get(0);
    Canopy canopy=(Canopy)clusterWritable.getValue();
    assertEquals(manhattanCentroids.get(i).asFormatString() + "String_Node_Str" + canopy.computeCentroid().asFormatString(),manhattanCentroids.get(i),canopy.computeCentroid());
    i++;
  }
}
Program: 61184
Project: 61184
Buggy source:
private void cloneWritable(Writable from,Writable to) throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  DataOutputStream dos=new DataOutputStream(baos);
  from.write(dos);
  dos.close();
  ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray());
  DataInputStream dis=new DataInputStream(bais);
  to.readFields(dis);
}

Fixed version (ground truth):
private Writable cloneWritable(Writable original) throws IOException {
  Writable clone;
  try {
    clone=original.getClass().asSubclass(Writable.class).newInstance();
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str",e);
  }
  ByteArrayOutputStream bytes=new ByteArrayOutputStream();
  original.write(new DataOutputStream(bytes));
  clone.readFields(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray())));
  return clone;
}
Program: 61185
Project: 61185
Buggy source:
@Override public void write(K key,V value){
  try {
    if (!(key instanceof NullWritable)) {
      K newKey=(K)key.getClass().newInstance();
      cloneWritable(key,newKey);
      key=newKey;
    }
    V newValue=(V)value.getClass().newInstance();
    cloneWritable(value,newValue);
    value=newValue;
  }
 catch (  InstantiationException e) {
    log.error(e.getMessage());
  }
catch (  IllegalAccessException e) {
    log.error(e.getMessage());
  }
catch (  IOException e) {
    log.error(e.getMessage());
  }
  List<V> points=data.get(key);
  if (points == null) {
    points=Lists.newArrayList();
    data.put(key,points);
  }
  points.add(value);
}

Fixed version (ground truth):
@Override public void write(K key,V value){
  try {
    K keyToUse=key instanceof NullWritable ? key : (K)cloneWritable(key);
    V valueToUse=(V)cloneWritable(value);
    keysInInsertionOrder.add(keyToUse);
    List<V> points=data.get(key);
    if (points == null) {
      points=Lists.newArrayList();
      data.put(keyToUse,points);
    }
    points.add(valueToUse);
  }
 catch (  IOException e) {
    throw new RuntimeException(e.getMessage(),e);
  }
}
Program: 61187
Project: 61187
Buggy source:
@Override protected void setup(Context context) throws IOException, InterruptedException {
  super.setup(context);
  Path uHatPath=new Path(context.getConfiguration().get(PROP_UHAT_PATH));
  Path sigmaPath=new Path(context.getConfiguration().get(PROP_SIGMA_PATH));
  FileSystem fs=FileSystem.get(uHatPath.toUri(),context.getConfiguration());
  uHat=new DenseMatrix(SSVDHelper.loadDistributedRowMatrix(fs,uHatPath,context.getConfiguration()));
  kp=uHat.columnSize();
  k=context.getConfiguration().getInt(PROP_K,kp);
  uRow=new DenseVector(k);
  uRowWritable=new VectorWritable(uRow);
  SSVDSolver.OutputScalingEnum outputScaling=SSVDSolver.OutputScalingEnum.valueOf(context.getConfiguration().get(PROP_OUTPUT_SCALING));
switch (outputScaling) {
case SIGMA:
    sValues=SSVDHelper.loadVector(sigmaPath,context.getConfiguration());
  break;
case HALFSIGMA:
sValues=SSVDHelper.loadVector(sigmaPath,context.getConfiguration());
sValues.assign(Functions.SQRT);
break;
default :
}
}

Fixed version (ground truth):
@Override protected void setup(Context context) throws IOException, InterruptedException {
  super.setup(context);
  Path uHatPath=new Path(context.getConfiguration().get(PROP_UHAT_PATH));
  Path sigmaPath=new Path(context.getConfiguration().get(PROP_SIGMA_PATH));
  FileSystem fs=FileSystem.get(uHatPath.toUri(),context.getConfiguration());
  uHat=SSVDHelper.drmLoadAsDense(fs,uHatPath,context.getConfiguration());
  kp=uHat.columnSize();
  k=context.getConfiguration().getInt(PROP_K,kp);
  uRow=new DenseVector(k);
  uRowWritable=new VectorWritable(uRow);
  SSVDSolver.OutputScalingEnum outputScaling=SSVDSolver.OutputScalingEnum.valueOf(context.getConfiguration().get(PROP_OUTPUT_SCALING));
switch (outputScaling) {
case SIGMA:
    sValues=SSVDHelper.loadVector(sigmaPath,context.getConfiguration());
  break;
case HALFSIGMA:
sValues=SSVDHelper.loadVector(sigmaPath,context.getConfiguration());
sValues.assign(Functions.SQRT);
break;
default :
}
}
Program: 61188
Project: 61188
Buggy source:
@Override protected void setup(Context context) throws IOException, InterruptedException {
  super.setup(context);
  Configuration conf=context.getConfiguration();
  FileSystem fs=FileSystem.get(conf);
  Path uHatPath=new Path(conf.get(PROP_UHAT_PATH));
  Path sigmaPath=new Path(conf.get(PROP_SIGMA_PATH));
  uHat=new DenseMatrix(SSVDHelper.loadDistributedRowMatrix(fs,uHatPath,conf));
  kp=uHat.columnSize();
  k=context.getConfiguration().getInt(PROP_K,kp);
  vRow=new DenseVector(k);
  vRowWritable=new VectorWritable(vRow);
  sValues=SSVDHelper.loadVector(sigmaPath,conf);
  SSVDSolver.OutputScalingEnum outputScaling=SSVDSolver.OutputScalingEnum.valueOf(context.getConfiguration().get(PROP_OUTPUT_SCALING));
switch (outputScaling) {
case SIGMA:
    sValues.assign(1.0);
  break;
case HALFSIGMA:
sValues=SSVDHelper.loadVector(sigmaPath,context.getConfiguration());
sValues.assign(Functions.SQRT);
break;
default :
}
String xiPathStr=conf.get(PROP_XI_PATH);
if (xiPathStr != null) {
xi=SSVDHelper.loadAndSumUpVectors(new Path(xiPathStr),conf);
sq=SSVDHelper.loadAndSumUpVectors(new Path(conf.get(PROP_SQ_PATH)),conf);
}
}

Fixed version (ground truth):
@Override protected void setup(Context context) throws IOException, InterruptedException {
  super.setup(context);
  Configuration conf=context.getConfiguration();
  FileSystem fs=FileSystem.get(conf);
  Path uHatPath=new Path(conf.get(PROP_UHAT_PATH));
  Path sigmaPath=new Path(conf.get(PROP_SIGMA_PATH));
  uHat=SSVDHelper.drmLoadAsDense(fs,uHatPath,conf);
  kp=uHat.columnSize();
  k=context.getConfiguration().getInt(PROP_K,kp);
  vRow=new DenseVector(k);
  vRowWritable=new VectorWritable(vRow);
  sValues=SSVDHelper.loadVector(sigmaPath,conf);
  SSVDSolver.OutputScalingEnum outputScaling=SSVDSolver.OutputScalingEnum.valueOf(context.getConfiguration().get(PROP_OUTPUT_SCALING));
switch (outputScaling) {
case SIGMA:
    sValues.assign(1.0);
  break;
case HALFSIGMA:
sValues=SSVDHelper.loadVector(sigmaPath,context.getConfiguration());
sValues.assign(Functions.SQRT);
break;
default :
}
String xiPathStr=conf.get(PROP_XI_PATH);
if (xiPathStr != null) {
xi=SSVDHelper.loadAndSumUpVectors(new Path(xiPathStr),conf);
sq=SSVDHelper.loadAndSumUpVectors(new Path(conf.get(PROP_SQ_PATH)),conf);
}
}
Program: 61189
Project: 61189
Buggy source:
@Override public double similarity(double dots,double normA,double normB,int numberOfColumns){
  double euclideanDistance=Math.sqrt(normA - 2 * dots + normB);
  return 1.0 / (1.0 + euclideanDistance);
}

Fixed version (ground truth):
@Override public double similarity(double dots,double normA,double normB,int numberOfColumns){
  double euclideanDistance=Math.sqrt(Math.max(0.0,normA - 2 * dots + normB));
  return 1.0 / (1.0 + euclideanDistance);
}
Program: 61190
Project: 61190
Buggy source:
public int numFeatures(){
  return userFeatures[0].length;
}

Fixed version (ground truth):
public int numFeatures(){
  return userFeatures.length > 0 ? userFeatures[0].length : 0;
}
Program: 61193
Project: 61193
Buggy source:
/** 
 * Populates a list with clusters present in clusters-*-final directory.
 * @param clusterOutputPath The output path of the clustering.
 * @param conf The Hadoop Configuration
 * @return The list of clusters found by the clustering.
 * @throws IOException
 */
private static List<Cluster> populateClusterModels(Path clusterOutputPath,Configuration conf) throws IOException {
  List<Cluster> clusterModels=new ArrayList<Cluster>();
  Cluster cluster=null;
  Path finalClustersPath=finalClustersPath(conf,clusterOutputPath);
  Iterator<?> it=new SequenceFileDirValueIterator<Writable>(finalClustersPath,PathType.LIST,PathFilters.partFilter(),null,false,conf);
  while (it.hasNext()) {
    ClusterWritable next=(ClusterWritable)it.next();
    cluster=(Cluster)next.getValue();
    if (cluster instanceof DirichletCluster) {
      ((DirichletCluster)cluster).getModel().configure(conf);
    }
    clusterModels.add(cluster);
  }
  return clusterModels;
}

Fixed version (ground truth):
/** 
 * Populates a list with clusters present in clusters-*-final directory.
 * @param clusterOutputPath The output path of the clustering.
 * @param conf The Hadoop Configuration
 * @return The list of clusters found by the clustering.
 * @throws IOException
 */
private static List<Cluster> populateClusterModels(Path clusterOutputPath,Configuration conf) throws IOException {
  List<Cluster> clusterModels=new ArrayList<Cluster>();
  Cluster cluster=null;
  Path finalClustersPath=finalClustersPath(conf,clusterOutputPath);
  Iterator<?> it=new SequenceFileDirValueIterator<Writable>(finalClustersPath,PathType.LIST,PathFilters.partFilter(),null,false,conf);
  while (it.hasNext()) {
    ClusterWritable next=(ClusterWritable)it.next();
    cluster=(Cluster)next.getValue();
    cluster.configure(conf);
    clusterModels.add(cluster);
  }
  return clusterModels;
}
Program: 61194
Project: 61194
Buggy source:
public static List<Cluster> populateClusterModels(Path clusterOutputPath,Configuration conf) throws IOException {
  List<Cluster> clusters=new ArrayList<Cluster>();
  Cluster cluster=null;
  FileSystem fileSystem=clusterOutputPath.getFileSystem(conf);
  FileStatus[] clusterFiles=fileSystem.listStatus(clusterOutputPath,PathFilters.finalPartFilter());
  Iterator<?> it=new SequenceFileDirValueIterator<Writable>(clusterFiles[0].getPath(),PathType.LIST,PathFilters.partFilter(),null,false,conf);
  while (it.hasNext()) {
    ClusterWritable next=(ClusterWritable)it.next();
    cluster=next.getValue();
    if (cluster instanceof DirichletCluster) {
      ((DirichletCluster)cluster).getModel().configure(conf);
    }
    clusters.add(cluster);
  }
  return clusters;
}

Fixed version (ground truth):
public static List<Cluster> populateClusterModels(Path clusterOutputPath,Configuration conf) throws IOException {
  List<Cluster> clusters=new ArrayList<Cluster>();
  Cluster cluster=null;
  FileSystem fileSystem=clusterOutputPath.getFileSystem(conf);
  FileStatus[] clusterFiles=fileSystem.listStatus(clusterOutputPath,PathFilters.finalPartFilter());
  Iterator<?> it=new SequenceFileDirValueIterator<Writable>(clusterFiles[0].getPath(),PathType.LIST,PathFilters.partFilter(),null,false,conf);
  while (it.hasNext()) {
    ClusterWritable next=(ClusterWritable)it.next();
    cluster=next.getValue();
    cluster.configure(conf);
    clusters.add(cluster);
  }
  return clusters;
}
Program: 61195
Project: 61195
Buggy source:
public void readFromSeqFiles(Path path) throws IOException {
  Configuration config=new Configuration();
  List<Cluster> clusters=Lists.newArrayList();
  for (  ClusterWritable cw : new SequenceFileDirValueIterable<ClusterWritable>(path,PathType.LIST,PathFilters.logsCRCFilter(),config)) {
    clusters.add(cw.getValue());
  }
  this.models=clusters;
  modelClass=models.get(0).getClass().getName();
  this.policy=readPolicy(path);
}

Fixed version (ground truth):
public void readFromSeqFiles(Configuration conf,Path path) throws IOException {
  Configuration config=new Configuration();
  List<Cluster> clusters=Lists.newArrayList();
  for (  ClusterWritable cw : new SequenceFileDirValueIterable<ClusterWritable>(path,PathType.LIST,PathFilters.logsCRCFilter(),config)) {
    Cluster cluster=cw.getValue();
    cluster.configure(conf);
    clusters.add(cluster);
  }
  this.models=clusters;
  modelClass=models.get(0).getClass().getName();
  this.policy=readPolicy(path);
}
Program: 61196
Project: 61196
Buggy source:
@Override public Vector classify(Vector instance){
  Vector score=model.createScoringVector();
  for (int label=0; label < model.numLabels(); label++) {
    score.set(label,getScoreForLabelInstance(label,instance));
  }
  return score;
}

Fixed version (ground truth):
@Override public Vector classify(Vector instance){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 61197
Project: 61197
Buggy source:
protected double getScoreForLabelInstance(int label,Vector instance){
  double result=0.0;
  Iterator<Element> elements=instance.iterateNonZero();
  while (elements.hasNext()) {
    result+=getScoreForLabelFeature(label,elements.next().index());
  }
  return result / model.thetaNormalizer(label);
}

Fixed version (ground truth):
protected double getScoreForLabelInstance(int label,Vector instance){
  double result=0.0;
  Iterator<Element> elements=instance.iterateNonZero();
  while (elements.hasNext()) {
    Element e=elements.next();
    result+=e.get() * getScoreForLabelFeature(label,e.index());
  }
  return result / model.thetaNormalizer(label);
}
Program: 61198
Project: 61198
Buggy source:
public static NaiveBayesModel materialize(Path output,Configuration conf) throws IOException {
  FileSystem fs=output.getFileSystem(conf);
  Vector weightsPerLabel=null;
  Vector perLabelThetaNormalizer=null;
  Vector weightsPerFeature=null;
  Matrix weightsPerLabelAndFeature;
  float alphaI;
  FSDataInputStream in=fs.open(new Path(output,"String_Node_Str"));
  try {
    alphaI=in.readFloat();
    weightsPerFeature=VectorWritable.readVector(in);
    weightsPerLabel=VectorWritable.readVector(in);
    perLabelThetaNormalizer=VectorWritable.readVector(in);
    weightsPerLabelAndFeature=new SparseMatrix(weightsPerLabel.size(),weightsPerFeature.size());
    for (int label=0; label < weightsPerLabelAndFeature.numRows(); label++) {
      weightsPerLabelAndFeature.assignRow(label,VectorWritable.readVector(in));
    }
  }
  finally {
    Closeables.closeQuietly(in);
  }
  NaiveBayesModel model=new NaiveBayesModel(weightsPerLabelAndFeature,weightsPerFeature,weightsPerLabel,perLabelThetaNormalizer,alphaI);
  model.validate();
  return model;
}

Fixed version (ground truth):
public static NaiveBayesModel materialize(Path output,Configuration conf) throws IOException {
  FileSystem fs=output.getFileSystem(conf);
  Vector weightsPerLabel=null;
  Vector perLabelThetaNormalizer=null;
  Vector weightsPerFeature=null;
  Matrix weightsPerLabelAndFeature;
  float alphaI;
  FSDataInputStream in=fs.open(new Path(output,"String_Node_Str"));
  try {
    alphaI=in.readFloat();
    weightsPerFeature=VectorWritable.readVector(in);
    weightsPerLabel=new DenseVector(VectorWritable.readVector(in));
    perLabelThetaNormalizer=new DenseVector(VectorWritable.readVector(in));
    weightsPerLabelAndFeature=new SparseRowMatrix(weightsPerLabel.size(),weightsPerFeature.size());
    for (int label=0; label < weightsPerLabelAndFeature.numRows(); label++) {
      weightsPerLabelAndFeature.assignRow(label,VectorWritable.readVector(in));
    }
  }
  finally {
    Closeables.closeQuietly(in);
  }
  NaiveBayesModel model=new NaiveBayesModel(weightsPerLabelAndFeature,weightsPerFeature,weightsPerLabel,perLabelThetaNormalizer,alphaI);
  model.validate();
  return model;
}
Program: 61199
Project: 61199
Buggy source:
@Override protected void setup(Context context) throws IOException, InterruptedException {
  Configuration conf=context.getConfiguration();
  Path modelPath=HadoopUtil.cachedFile(conf);
  NaiveBayesModel model=NaiveBayesModel.materialize(modelPath,conf);
  boolean compl=Boolean.parseBoolean(conf.get(TestNaiveBayesDriver.COMPLEMENTARY));
  if (compl) {
    classifier=new ComplementaryNaiveBayesClassifier(model);
  }
 else {
    classifier=new StandardNaiveBayesClassifier(model);
  }
}

Fixed version (ground truth):
@Override protected void setup(Context context) throws IOException, InterruptedException {
  super.setup(context);
  System.out.println("String_Node_Str");
  Configuration conf=context.getConfiguration();
  Path modelPath=HadoopUtil.cachedFile(conf);
  NaiveBayesModel model=NaiveBayesModel.materialize(modelPath,conf);
  boolean compl=Boolean.parseBoolean(conf.get(TestNaiveBayesDriver.COMPLEMENTARY));
  if (compl) {
    classifier=new ComplementaryNaiveBayesClassifier(model);
  }
 else {
    classifier=new StandardNaiveBayesClassifier(model);
  }
}
Program: 61200
Project: 61200
Buggy source:
@Override protected void map(Text key,VectorWritable value,Context context) throws IOException, InterruptedException {
  Vector result=classifier.classify(value.get());
  context.write(key,new VectorWritable(result));
}

Fixed version (ground truth):
@Override protected void map(Text key,VectorWritable value,Context context) throws IOException, InterruptedException {
  Vector result=classifier.classifyFull(value.get());
  context.write(key,new VectorWritable(result));
}
Program: 61202
Project: 61202
Buggy source:
@Override protected void map(IntWritable key,MultiLabelVectorWritable instance,Context ctx) throws IOException, InterruptedException {
  VectorWritable vw=new VectorWritable(instance.getVector());
  ctx.write(new IntWritable(instance.getLabels()[0]),vw);
}

Fixed version (ground truth):
@Override protected void map(Text labelText,VectorWritable instance,Context ctx) throws IOException, InterruptedException {
  String label=labelText.toString();
  if (labelIndex.containsKey(label)) {
    ctx.write(new IntWritable(labelIndex.get(label)),instance);
  }
 else {
    ctx.getCounter(Counter.SKIPPED_INSTANCES).increment(1);
  }
}
Program: 61203
Project: 61203
Buggy source:
@Override public void train(int label,Vector instance){
  double weight=Math.log((instance.zSum() + alphaI()) / (labelWeight(label) + alphaI() * numFeatures()));
  updatePerLabelThetaNormalizer(label,weight);
}

Fixed version (ground truth):
@Override public void train(int label,Vector instance){
  double sigmaK=labelWeight(label);
  Iterator<Vector.Element> it=instance.iterateNonZero();
  while (it.hasNext()) {
    Vector.Element e=it.next();
    double numerator=e.get() + alphaI();
    double denominator=sigmaK + alphaI() * numFeatures();
    double weight=Math.log(numerator / denominator);
    updatePerLabelThetaNormalizer(label,weight);
  }
}
Program: 61204
Project: 61204
Buggy source:
@Override protected void cleanup(Context ctx) throws IOException, InterruptedException {
  ctx.write(new Text(TrainNaiveBayesJob.LABEL_THETA_NORMALIZER),new VectorWritable(trainer.retrievePerLabelThetaNormalizer()));
}

Fixed version (ground truth):
@Override protected void cleanup(Context ctx) throws IOException, InterruptedException {
  ctx.write(new Text(TrainNaiveBayesJob.LABEL_THETA_NORMALIZER),new VectorWritable(trainer.retrievePerLabelThetaNormalizer()));
  super.cleanup(ctx);
}
Program: 61205
Project: 61205
Buggy source:
@Override protected void setup(Context ctx) throws IOException, InterruptedException {
  Configuration conf=ctx.getConfiguration();
  float alphaI=conf.getFloat(ALPHA_I,1.0f);
  Map<String,Vector> scores=BayesUtils.readScoresFromCache(conf);
  if (conf.getBoolean(TRAIN_COMPLEMENTARY,false)) {
    trainer=new ComplementaryThetaTrainer(scores.get(TrainNaiveBayesJob.WEIGHTS_PER_FEATURE),scores.get(TrainNaiveBayesJob.WEIGHTS_PER_LABEL),alphaI);
  }
 else {
    trainer=new StandardThetaTrainer(scores.get(TrainNaiveBayesJob.WEIGHTS_PER_FEATURE),scores.get(TrainNaiveBayesJob.WEIGHTS_PER_LABEL),alphaI);
  }
}

Fixed version (ground truth):
@Override protected void setup(Context ctx) throws IOException, InterruptedException {
  super.setup(ctx);
  Configuration conf=ctx.getConfiguration();
  float alphaI=conf.getFloat(ALPHA_I,1.0f);
  Map<String,Vector> scores=BayesUtils.readScoresFromCache(conf);
  if (conf.getBoolean(TRAIN_COMPLEMENTARY,false)) {
    trainer=new ComplementaryThetaTrainer(scores.get(TrainNaiveBayesJob.WEIGHTS_PER_FEATURE),scores.get(TrainNaiveBayesJob.WEIGHTS_PER_LABEL),alphaI);
  }
 else {
    trainer=new StandardThetaTrainer(scores.get(TrainNaiveBayesJob.WEIGHTS_PER_FEATURE),scores.get(TrainNaiveBayesJob.WEIGHTS_PER_LABEL),alphaI);
  }
}
Program: 61206
Project: 61206
Buggy source:
@Override public void write(Cluster cluster) throws IOException {
  StringBuilder line=new StringBuilder();
  line.append(createNode(String.valueOf(cluster.getId())));
  List<WeightedVectorWritable> points=getClusterIdToPoints().get(cluster.getId());
  if (points != null) {
    for (    WeightedVectorWritable point : points) {
      Vector theVec=point.getVector();
      String vecStr;
      if (theVec instanceof NamedVector) {
        vecStr=((NamedVector)theVec).getName();
        line.append(createNode(vecStr));
      }
 else {
        vecStr=theVec.asFormatString();
        vecStr=VEC_PATTERN.matcher(vecStr).replaceAll("String_Node_Str");
        line.append(createNode(vecStr));
      }
      line.append(createEdge(String.valueOf(cluster.getId()),vecStr));
    }
    getWriter().append(line).append("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void write(Cluster cluster) throws IOException {
  StringBuilder line=new StringBuilder();
  line.append(createNode(String.valueOf(cluster.getId())));
  List<WeightedVectorWritable> points=getClusterIdToPoints().get(cluster.getId());
  if (points != null) {
    for (    WeightedVectorWritable point : points) {
      Vector theVec=point.getVector();
      String vecStr;
      if (theVec instanceof NamedVector) {
        vecStr=((NamedVector)theVec).getName();
        line.append(createNode(vecStr));
      }
 else {
        vecStr=theVec.asFormatString();
        vecStr=VEC_PATTERN.matcher(vecStr).replaceAll("String_Node_Str");
        line.append(createNode(vecStr));
      }
      line.append(createEdge(String.valueOf(cluster.getId()),vecStr));
    }
  }
  getWriter().append(line).append("String_Node_Str");
}
Program: 61207
Project: 61207
Buggy source:
@Override public void map(IntWritable docId,VectorWritable document,Context context) throws IOException, InterruptedException {
  Vector topicVector=new DenseVector(new double[numTopics]).assign(1 / numTopics);
  modelTrainer.train(document.get(),topicVector,true,maxIters);
}

Fixed version (ground truth):
@Override public void map(IntWritable docId,VectorWritable document,Context context) throws IOException, InterruptedException {
  Vector topicVector=new DenseVector(new double[numTopics]).assign(1.0 / numTopics);
  modelTrainer.train(document.get(),topicVector,true,maxIters);
}
Program: 61208
Project: 61208
Buggy source:
public static Pair<Matrix,Vector> loadModel(Configuration conf,Path... modelPaths) throws IOException {
  int numTopics=-1;
  int numTerms=-1;
  List<Pair<Integer,Vector>> rows=Lists.newArrayList();
  for (  Path modelPath : modelPaths) {
    for (    Pair<IntWritable,VectorWritable> row : new SequenceFileIterable<IntWritable,VectorWritable>(modelPath,true,conf)) {
      rows.add(Pair.of(row.getFirst().get(),row.getSecond().get()));
      numTopics=Math.max(numTopics,row.getFirst().get());
      if (numTerms < 0) {
        numTerms=row.getSecond().get().size();
      }
    }
  }
  if (rows.isEmpty()) {
    throw new IOException(modelPaths + "String_Node_Str");
  }
  numTopics++;
  Matrix model=new DenseMatrix(numTopics,numTerms);
  Vector topicSums=new DenseVector(numTopics);
  for (  Pair<Integer,Vector> pair : rows) {
    model.viewRow(pair.getFirst()).assign(pair.getSecond());
    topicSums.set(pair.getFirst(),pair.getSecond().norm(1));
  }
  return Pair.of(model,topicSums);
}

Fixed version (ground truth):
public static Pair<Matrix,Vector> loadModel(Configuration conf,Path... modelPaths) throws IOException {
  int numTopics=-1;
  int numTerms=-1;
  List<Pair<Integer,Vector>> rows=Lists.newArrayList();
  for (  Path modelPath : modelPaths) {
    for (    Pair<IntWritable,VectorWritable> row : new SequenceFileIterable<IntWritable,VectorWritable>(modelPath,true,conf)) {
      rows.add(Pair.of(row.getFirst().get(),row.getSecond().get()));
      numTopics=Math.max(numTopics,row.getFirst().get());
      if (numTerms < 0) {
        numTerms=row.getSecond().get().size();
      }
    }
  }
  if (rows.isEmpty()) {
    throw new IOException(Arrays.toString(modelPaths) + "String_Node_Str");
  }
  numTopics++;
  Matrix model=new DenseMatrix(numTopics,numTerms);
  Vector topicSums=new DenseVector(numTopics);
  for (  Pair<Integer,Vector> pair : rows) {
    model.viewRow(pair.getFirst()).assign(pair.getSecond());
    topicSums.set(pair.getFirst(),pair.getSecond().norm(1));
  }
  return Pair.of(model,topicSums);
}
Program: 61209
Project: 61209
Buggy source:
public String toString(){
  String buf="String_Node_Str";
  for (int x=0; x < numTopics; x++) {
    String v=dictionary != null ? vectorToSortedString(topicTermCounts.viewRow(x).normalize(1),dictionary) : topicTermCounts.viewRow(x).asFormatString();
    buf+=v + "String_Node_Str";
  }
  return buf;
}

Fixed version (ground truth):
@Override public String toString(){
  String buf="String_Node_Str";
  for (int x=0; x < numTopics; x++) {
    String v=dictionary != null ? vectorToSortedString(topicTermCounts.viewRow(x).normalize(1),dictionary) : topicTermCounts.viewRow(x).asFormatString();
    buf+=v + "String_Node_Str";
  }
  return buf;
}