Program: 32231
Project: 32231
Buggy source:
/** 
 * @param databag
 * @param columnConfig
 * @throws ExecException 
 */
private void statsCategoricalColumnInfo(DataBag databag,ColumnConfig columnConfig) throws ExecException {
  Integer[] binCountPos=new Integer[columnConfig.getBinCategory().size()];
  Integer[] binCountNeg=new Integer[columnConfig.getBinCategory().size()];
  Double[] binWeightCountPos=new Double[columnConfig.getBinCategory().size()];
  Double[] binWeightCountNeg=new Double[columnConfig.getBinCategory().size()];
  initializeZeroArr(binCountPos);
  initializeZeroArr(binCountNeg);
  initializeZeroArr(binWeightCountPos);
  initializeZeroArr(binWeightCountNeg);
  Iterator<Tuple> iterator=databag.iterator();
  while (iterator.hasNext()) {
    Tuple element=iterator.next();
    if (element.size() != 4) {
      continue;
    }
    Object value=element.get(1);
    String tag=(String)element.get(2);
    Double weight=(Double)element.get(3);
    if (value == null || StringUtils.isBlank(value.toString())) {
      missingValueCnt++;
      continue;
    }
    String str=StringUtils.trim(value.toString());
    int binNum=CommonUtils.getBinNum(columnConfig,str);
    if (modelConfig.getPosTags().contains(tag)) {
      increaseInstCnt(binCountPos,binNum);
      increaseInstCnt(binWeightCountPos,binNum,weight);
    }
 else     if (modelConfig.getNegTags().contains(tag)) {
      increaseInstCnt(binCountNeg,binNum);
      increaseInstCnt(binWeightCountNeg,binNum,weight);
    }
  }
  columnConfig.setBinCountPos(Arrays.asList(binCountPos));
  columnConfig.setBinCountNeg(Arrays.asList(binCountNeg));
  columnConfig.setBinWeightedPos(Arrays.asList(binWeightCountPos));
  columnConfig.setBinWeightedNeg(Arrays.asList(binWeightCountNeg));
  calculateBinPosRateAndAvgScore();
  for (int i=0; i < columnConfig.getBinCountPos().size(); i++) {
    int posCount=columnConfig.getBinCountPos().get(i);
    int negCount=columnConfig.getBinCountNeg().get(i);
    for (int j=0; j < posCount; j++) {
      streamStatsCalculator.addData(columnConfig.getBinPosRate().get(i));
    }
    for (int j=0; j < negCount; j++) {
      streamStatsCalculator.addData(columnConfig.getBinPosRate().get(i));
    }
  }
  columnConfig.setMax(streamStatsCalculator.getMax());
  columnConfig.setMean(streamStatsCalculator.getMean());
  columnConfig.setMin(streamStatsCalculator.getMin());
  columnConfig.setMedian(streamStatsCalculator.getMean());
  columnConfig.setStdDev(streamStatsCalculator.getStdDev());
  columnConfig.setMissingCnt(missingValueCnt + invalidValueCnt);
  columnConfig.setTotalCount(databag.size());
  columnConfig.setMissingPercentage(((double)columnConfig.getMissingCount()) / columnConfig.getTotalCount());
}

Fixed version (ground truth):
/** 
 * @param databag
 * @param columnConfig
 * @throws ExecException 
 */
private void statsCategoricalColumnInfo(DataBag databag,ColumnConfig columnConfig) throws ExecException {
  Integer[] binCountPos=new Integer[columnConfig.getBinCategory().size()];
  Integer[] binCountNeg=new Integer[columnConfig.getBinCategory().size()];
  Double[] binWeightCountPos=new Double[columnConfig.getBinCategory().size()];
  Double[] binWeightCountNeg=new Double[columnConfig.getBinCategory().size()];
  initializeZeroArr(binCountPos);
  initializeZeroArr(binCountNeg);
  initializeZeroArr(binWeightCountPos);
  initializeZeroArr(binWeightCountNeg);
  Iterator<Tuple> iterator=databag.iterator();
  while (iterator.hasNext()) {
    Tuple element=iterator.next();
    if (element.size() != 4) {
      continue;
    }
    Object value=element.get(1);
    String tag=(String)element.get(2);
    Double weight=(Double)element.get(3);
    if (value == null || StringUtils.isBlank(value.toString())) {
      missingValueCnt++;
      continue;
    }
    String str=StringUtils.trim(value.toString());
    int binNum=quickLocateCategorialBin(str);
    if (binNum < 0) {
      continue;
    }
    if (modelConfig.getPosTags().contains(tag)) {
      increaseInstCnt(binCountPos,binNum);
      increaseInstCnt(binWeightCountPos,binNum,weight);
    }
 else     if (modelConfig.getNegTags().contains(tag)) {
      increaseInstCnt(binCountNeg,binNum);
      increaseInstCnt(binWeightCountNeg,binNum,weight);
    }
  }
  columnConfig.setBinCountPos(Arrays.asList(binCountPos));
  columnConfig.setBinCountNeg(Arrays.asList(binCountNeg));
  columnConfig.setBinWeightedPos(Arrays.asList(binWeightCountPos));
  columnConfig.setBinWeightedNeg(Arrays.asList(binWeightCountNeg));
  calculateBinPosRateAndAvgScore();
  for (int i=0; i < columnConfig.getBinCountPos().size(); i++) {
    int posCount=columnConfig.getBinCountPos().get(i);
    int negCount=columnConfig.getBinCountNeg().get(i);
    binning.addData(columnConfig.getBinPosRate().get(i),posCount);
    binning.addData(columnConfig.getBinPosRate().get(i),negCount);
    streamStatsCalculator.addData(columnConfig.getBinPosRate().get(i),posCount);
    streamStatsCalculator.addData(columnConfig.getBinPosRate().get(i),negCount);
  }
  columnConfig.setMax(streamStatsCalculator.getMax());
  columnConfig.setMean(streamStatsCalculator.getMean());
  columnConfig.setMin(streamStatsCalculator.getMin());
  if (binning.getMedian() == null) {
    columnConfig.setMedian(streamStatsCalculator.getMean());
  }
 else {
    columnConfig.setMedian(binning.getMedian());
  }
  columnConfig.setStdDev(streamStatsCalculator.getStdDev());
  columnConfig.setMissingCnt(missingValueCnt + invalidValueCnt);
  columnConfig.setTotalCount(databag.size());
  columnConfig.setMissingPercentage(((double)columnConfig.getMissingCount()) / columnConfig.getTotalCount());
}