Program: 32120
Project: 32120
Buggy source:
@Override protected void reduce(IntWritable key,Iterable<BinningInfoWritable> values,Context context) throws IOException, InterruptedException {
  long start=System.currentTimeMillis();
  double sum=0d;
  double squaredSum=0d;
  long count=0L, missingCount=0L;
  double min=Double.MAX_VALUE, max=Double.MIN_VALUE;
  List<Double> binBoundaryList=null;
  List<String> binCategories=null;
  long[] binCountPos=null;
  long[] binCountNeg=null;
  double[] binWeightPos=null;
  double[] binWeightNeg=null;
  ColumnConfig columnConfig=this.columnConfigList.get(key.get());
  int binSize=0;
  for (  BinningInfoWritable info : values) {
    if (info.isNumeric() && binBoundaryList == null) {
      binBoundaryList=info.getBinBoundaries();
      binSize=binBoundaryList.size();
      binCountPos=new long[binSize + 1];
      binCountNeg=new long[binSize + 1];
      binWeightPos=new double[binSize + 1];
      binWeightNeg=new double[binSize + 1];
    }
    if (!info.isNumeric() && binCategories == null) {
      binCategories=info.getBinCategories();
      binSize=binCategories.size();
      binCountPos=new long[binSize + 1];
      binCountNeg=new long[binSize + 1];
      binWeightPos=new double[binSize + 1];
      binWeightNeg=new double[binSize + 1];
    }
    count+=info.getTotalCount();
    missingCount+=info.getMissingCount();
    sum+=info.getSum();
    squaredSum+=info.getSquaredSum();
    if (Double.compare(max,info.getMax()) < 0) {
      max=info.getMax();
    }
    if (Double.compare(min,info.getMin()) > 0) {
      min=info.getMin();
    }
    for (int i=0; i < (binSize + 1); i++) {
      binCountPos[i]+=info.getBinCountPos()[i];
      binCountNeg[i]+=info.getBinCountNeg()[i];
      binWeightPos[i]+=info.getBinWeightPos()[i];
      binWeightNeg[i]+=info.getBinWeightNeg()[i];
    }
  }
  double[] binPosRate=computePosRate(binCountPos,binCountNeg);
  String binBounString=null;
  if (columnConfig.isCategorical()) {
    if (binCategories.size() == 0 || binCategories.size() > MAX_CATEGORICAL_BINC_COUNT) {
      LOG.warn("String_Node_Str",key.get(),columnConfig.getColumnName(),binCategories.size());
      return;
    }
    binBounString=Base64Utils.base64Encode("String_Node_Str" + StringUtils.join(binCategories,CalculateStatsUDF.CATEGORY_VAL_SEPARATOR) + "String_Node_Str");
    min=Double.MAX_VALUE;
    max=Double.MIN_VALUE;
    sum=0d;
    squaredSum=0d;
    for (int i=0; i < binPosRate.length; i++) {
      if (Double.compare(max,binPosRate[i]) < 0) {
        max=binPosRate[i];
      }
      if (Double.compare(min,binPosRate[i]) > 0) {
        min=binPosRate[i];
      }
      sum+=binPosRate[i] * (binCountPos[i] + binCountNeg[i]);
      squaredSum+=binPosRate[i] * binPosRate[i] * (binCountPos[i] + binCountNeg[i]);
    }
  }
 else {
    if (binBoundaryList.size() == 0) {
      LOG.warn("String_Node_Str",key.get(),columnConfig.getColumnName(),binBoundaryList.size());
      return;
    }
    binBounString=binBoundaryList.toString();
  }
  ColumnMetrics columnCountMetrics=ColumnStatsCalculator.calculateColumnMetrics(binCountNeg,binCountPos);
  ColumnMetrics columnWeightMetrics=ColumnStatsCalculator.calculateColumnMetrics(binWeightNeg,binWeightPos);
  sb.append(key.get()).append(Constants.DEFAULT_DELIMITER).append(binBounString).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binCountNeg)).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binCountPos)).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(new double[0])).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binPosRate)).append(Constants.DEFAULT_DELIMITER).append(df.format(columnCountMetrics.getKs())).append(Constants.DEFAULT_DELIMITER).append(df.format(columnWeightMetrics.getIv())).append(Constants.DEFAULT_DELIMITER).append(df.format(max)).append(Constants.DEFAULT_DELIMITER).append(df.format(min)).append(Constants.DEFAULT_DELIMITER).append(df.format(sum / count)).append(Constants.DEFAULT_DELIMITER).append(df.format(Math.sqrt(Math.abs((squaredSum - (sum * sum) / count + EPS) / (count - 1))))).append(Constants.DEFAULT_DELIMITER).append(columnConfig.isCategorical() ? "String_Node_Str" : "String_Node_Str").append(Constants.DEFAULT_DELIMITER).append(df.format(sum / count)).append(Constants.DEFAULT_DELIMITER).append(missingCount).append(Constants.DEFAULT_DELIMITER).append(count).append(Constants.DEFAULT_DELIMITER).append(missingCount * 1.0d / count).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binWeightNeg)).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binWeightPos)).append(Constants.DEFAULT_DELIMITER).append(columnCountMetrics.getWoe()).append(Constants.DEFAULT_DELIMITER).append(columnWeightMetrics.getWoe()).append(Constants.DEFAULT_DELIMITER).append(columnWeightMetrics.getKs()).append(Constants.DEFAULT_DELIMITER).append(columnCountMetrics.getIv()).append(Constants.DEFAULT_DELIMITER).append(columnCountMetrics.getBinningWoe().toString()).append(Constants.DEFAULT_DELIMITER).append(columnWeightMetrics.getBinningWoe().toString());
  outputValue.set(sb.toString());
  context.write(NullWritable.get(),outputValue);
  sb.delete(0,sb.length());
  LOG.debug("String_Node_Str",(System.currentTimeMillis() - start));
}

Fixed version (ground truth):
@Override protected void reduce(IntWritable key,Iterable<BinningInfoWritable> values,Context context) throws IOException, InterruptedException {
  long start=System.currentTimeMillis();
  double sum=0d;
  double squaredSum=0d;
  long count=0L, missingCount=0L;
  double min=Double.MAX_VALUE, max=Double.MIN_VALUE;
  List<Double> binBoundaryList=null;
  List<String> binCategories=null;
  long[] binCountPos=null;
  long[] binCountNeg=null;
  double[] binWeightPos=null;
  double[] binWeightNeg=null;
  ColumnConfig columnConfig=this.columnConfigList.get(key.get());
  int binSize=0;
  for (  BinningInfoWritable info : values) {
    if (info.isNumeric() && binBoundaryList == null) {
      binBoundaryList=info.getBinBoundaries();
      binSize=binBoundaryList.size();
      binCountPos=new long[binSize + 1];
      binCountNeg=new long[binSize + 1];
      binWeightPos=new double[binSize + 1];
      binWeightNeg=new double[binSize + 1];
    }
    if (!info.isNumeric() && binCategories == null) {
      binCategories=info.getBinCategories();
      binSize=binCategories.size();
      binCountPos=new long[binSize + 1];
      binCountNeg=new long[binSize + 1];
      binWeightPos=new double[binSize + 1];
      binWeightNeg=new double[binSize + 1];
    }
    count+=info.getTotalCount();
    missingCount+=info.getMissingCount();
    sum+=info.getSum();
    squaredSum+=info.getSquaredSum();
    if (Double.compare(max,info.getMax()) < 0) {
      max=info.getMax();
    }
    if (Double.compare(min,info.getMin()) > 0) {
      min=info.getMin();
    }
    for (int i=0; i < (binSize + 1); i++) {
      binCountPos[i]+=info.getBinCountPos()[i];
      binCountNeg[i]+=info.getBinCountNeg()[i];
      binWeightPos[i]+=info.getBinWeightPos()[i];
      binWeightNeg[i]+=info.getBinWeightNeg()[i];
    }
  }
  double[] binPosRate=computePosRate(binCountPos,binCountNeg);
  String binBounString=null;
  if (columnConfig.isCategorical()) {
    if (binCategories.size() == 0 || binCategories.size() > MAX_CATEGORICAL_BINC_COUNT) {
      LOG.warn("String_Node_Str",key.get(),columnConfig.getColumnName(),binCategories.size());
      return;
    }
    binBounString=Base64Utils.base64Encode("String_Node_Str" + StringUtils.join(binCategories,CalculateStatsUDF.CATEGORY_VAL_SEPARATOR) + "String_Node_Str");
    min=Double.MAX_VALUE;
    max=Double.MIN_VALUE;
    sum=0d;
    squaredSum=0d;
    for (int i=0; i < binPosRate.length; i++) {
      if (!Double.isNaN(binPosRate[i])) {
        if (Double.compare(max,binPosRate[i]) < 0) {
          max=binPosRate[i];
        }
        if (Double.compare(min,binPosRate[i]) > 0) {
          min=binPosRate[i];
        }
        sum+=binPosRate[i] * (binCountPos[i] + binCountNeg[i]);
        squaredSum+=binPosRate[i] * binPosRate[i] * (binCountPos[i] + binCountNeg[i]);
      }
    }
  }
 else {
    if (binBoundaryList.size() == 0) {
      LOG.warn("String_Node_Str",key.get(),columnConfig.getColumnName(),binBoundaryList.size());
      return;
    }
    binBounString=binBoundaryList.toString();
  }
  ColumnMetrics columnCountMetrics=ColumnStatsCalculator.calculateColumnMetrics(binCountNeg,binCountPos);
  ColumnMetrics columnWeightMetrics=ColumnStatsCalculator.calculateColumnMetrics(binWeightNeg,binWeightPos);
  sb.append(key.get()).append(Constants.DEFAULT_DELIMITER).append(binBounString).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binCountNeg)).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binCountPos)).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(new double[0])).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binPosRate)).append(Constants.DEFAULT_DELIMITER).append(df.format(columnCountMetrics.getKs())).append(Constants.DEFAULT_DELIMITER).append(df.format(columnWeightMetrics.getIv())).append(Constants.DEFAULT_DELIMITER).append(df.format(max)).append(Constants.DEFAULT_DELIMITER).append(df.format(min)).append(Constants.DEFAULT_DELIMITER).append(df.format(sum / count)).append(Constants.DEFAULT_DELIMITER).append(df.format(Math.sqrt(Math.abs((squaredSum - (sum * sum) / count + EPS) / (count - 1))))).append(Constants.DEFAULT_DELIMITER).append(columnConfig.isCategorical() ? "String_Node_Str" : "String_Node_Str").append(Constants.DEFAULT_DELIMITER).append(df.format(sum / count)).append(Constants.DEFAULT_DELIMITER).append(missingCount).append(Constants.DEFAULT_DELIMITER).append(count).append(Constants.DEFAULT_DELIMITER).append(missingCount * 1.0d / count).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binWeightNeg)).append(Constants.DEFAULT_DELIMITER).append(Arrays.toString(binWeightPos)).append(Constants.DEFAULT_DELIMITER).append(columnCountMetrics.getWoe()).append(Constants.DEFAULT_DELIMITER).append(columnWeightMetrics.getWoe()).append(Constants.DEFAULT_DELIMITER).append(columnWeightMetrics.getKs()).append(Constants.DEFAULT_DELIMITER).append(columnCountMetrics.getIv()).append(Constants.DEFAULT_DELIMITER).append(columnCountMetrics.getBinningWoe().toString()).append(Constants.DEFAULT_DELIMITER).append(columnWeightMetrics.getBinningWoe().toString());
  outputValue.set(sb.toString());
  context.write(NullWritable.get(),outputValue);
  sb.delete(0,sb.length());
  LOG.debug("String_Node_Str",(System.currentTimeMillis() - start));
}