nus-yam/ex-repair huggingface dataset:
Program: 32150
Project: 32150
Buggy source:
/** 
 * Assemble map data to Encog standard input format.
 * @throws NullPointerException if input is null
 * @throws NumberFormatException if column value is not number format.
 */
public static MLDataPair assembleDataPair(List<ColumnConfig> columnConfigList,Map<String,? extends Object> rawDataMap,double cutoff){
  double[] ideal={Constants.DEFAULT_IDEAL_VALUE};
  List<Double> inputList=new ArrayList<Double>();
  for (  ColumnConfig config : columnConfigList) {
    String key=config.getColumnName();
    if (config.isFinalSelect() && !rawDataMap.containsKey(key)) {
      throw new IllegalStateException(String.format("String_Node_Str",key));
    }
    if (config.isTarget()) {
      continue;
    }
 else     if (config.isFinalSelect()) {
      inputList.add(Normalizer.normalize(config,rawDataMap.get(key).toString(),cutoff));
    }
  }
  int size=inputList.size();
  double[] input=new double[size];
  for (int i=0; i < size; i++) {
    input[i]=inputList.get(i);
  }
  return new BasicMLDataPair(new BasicMLData(input),new BasicMLData(ideal));
}

Fixed version (ground truth):
/** 
 * Assemble map data to Encog standard input format.
 * @throws NullPointerException if input is null
 * @throws NumberFormatException if column value is not number format.
 */
public static MLDataPair assembleDataPair(ModelConfig modelConfig,List<ColumnConfig> columnConfigList,Map<String,? extends Object> rawDataMap,double cutoff){
  double[] ideal={Constants.DEFAULT_IDEAL_VALUE};
  List<Double> inputList=new ArrayList<Double>();
  for (  ColumnConfig config : columnConfigList) {
    String key=config.getColumnName();
    if (config.isFinalSelect() && !rawDataMap.containsKey(key)) {
      throw new IllegalStateException(String.format("String_Node_Str",key));
    }
    if (config.isTarget()) {
      continue;
    }
 else     if (config.isFinalSelect()) {
      String val=rawDataMap.get(key) == null ? null : rawDataMap.get(key).toString();
      Double normalizeValue=null;
switch (modelConfig.getNormalize().getNormType()) {
case WOE:
        List<Double> binWoe;
      if (modelConfig.getNormalize().getIsWeightNorm()) {
        binWoe=config.getColumnBinning().getBinWeightedWoe();
      }
 else {
        binWoe=config.getColumnBinning().getBinCountWoe();
      }
    if (StringUtils.isEmpty(val)) {
      normalizeValue=binWoe.get(binWoe.size() - 1);
    }
 else {
      try {
        int binNum=CommonUtils.getBinNum(config,val);
        binNum=binNum == -1 ? binWoe.size() - 1 : binNum;
        normalizeValue=binWoe.get(binNum);
      }
 catch (      NumberFormatException e) {
        normalizeValue=binWoe.get(binWoe.size() - 1);
      }
    }
  break;
case ZSCALE:
default :
normalizeValue=Normalizer.normalize(config,val,cutoff);
break;
}
inputList.add(normalizeValue);
}
}
int size=inputList.size();
double[] input=new double[size];
for (int i=0; i < size; i++) {
input[i]=inputList.get(i);
}
return new BasicMLDataPair(new BasicMLData(input),new BasicMLData(ideal));
}
Program: 32151
Project: 32151
Buggy source:
/** 
 * Copy src file to dst file in the same FileSystem. Such as copy local source to local destination, copy hdfs source to hdfs dest.
 * @param srcPath    - source file to copy
 * @param destPath   - destination file
 * @param sourceType - local/hdfs
 * @throws IOException -  if any I/O exception in processing
 */
public static void copy(String srcPath,String destPath,SourceType sourceType) throws IOException {
  if (StringUtils.isEmpty(destPath) || StringUtils.isEmpty(destPath) || sourceType == null) {
    throw new IllegalArgumentException(String.format("String_Node_Str",srcPath,destPath,sourceType));
  }
  FileSystem fs=getFileSystemBySourceType(sourceType);
  if (!fs.delete(new Path(destPath),true)) {
  }
  FileUtil.copy(fs,new Path(srcPath),fs,new Path(destPath),false,new Configuration());
}

Fixed version (ground truth):
/** 
 * Copy src file to dst file in the same FileSystem. Such as copy local source to local destination, copy hdfs source to hdfs dest.
 * @param srcPath    - source file to copy
 * @param destPath   - destination file
 * @param sourceType - local/hdfs
 * @throws IOException -  if any I/O exception in processing
 */
public static void copy(String srcPath,String destPath,SourceType sourceType) throws IOException {
  if (StringUtils.isEmpty(srcPath) || StringUtils.isEmpty(destPath) || sourceType == null) {
    throw new IllegalArgumentException(String.format("String_Node_Str",srcPath,destPath,sourceType));
  }
  FileSystem fs=getFileSystemBySourceType(sourceType);
  if (!fs.delete(new Path(destPath),true)) {
  }
  FileUtil.copy(fs,new Path(srcPath),fs,new Path(destPath),false,new Configuration());
}
Program: 32152
Project: 32152
Buggy source:
/** 
 * @return
 * @throws IOException
 */
private String[] getEvalScoreHeader() throws IOException {
  PathFinder pathFinder=new PathFinder(modelConfig);
  SourceType sourceType=evalConfig.getDataSet().getSource();
  String pathHeader=null;
  boolean isDir=ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  if (isDir) {
    pathHeader=pathFinder.getEvalScoreHeaderPath(evalConfig,sourceType);
  }
 else {
    pathHeader=pathFinder.getEvalScorePath(evalConfig,sourceType);
  }
  return CommonUtils.getHeaders(pathHeader,"String_Node_Str",sourceType);
}

Fixed version (ground truth):
/** 
 * @return
 * @throws IOException
 */
private String[] getEvalScoreHeader() throws IOException {
  PathFinder pathFinder=new PathFinder(modelConfig);
  SourceType sourceType=evalConfig.getDataSet().getSource();
  String pathHeader=null;
  boolean isDir=ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  if (isDir) {
    pathHeader=pathFinder.getEvalScoreHeaderPath(evalConfig,sourceType);
  }
 else {
    pathHeader=pathFinder.getEvalScorePath(evalConfig,sourceType);
  }
  return CommonUtils.getHeaders(pathHeader,"String_Node_Str",sourceType,false);
}
Program: 32153
Project: 32153
Buggy source:
public EvalScoreUDF(String source,String pathModelConfig,String pathColumnConfig,String evalSetName) throws IOException {
  super(source,pathModelConfig,pathColumnConfig);
  evalConfig=modelConfig.getEvalConfigByName(evalSetName);
  negTags=modelConfig.getNegTags();
  log.debug("String_Node_Str" + negTags);
  posTags=modelConfig.getPosTags();
  log.debug("String_Node_Str" + posTags);
  if (evalConfig.getModelsPath() != null) {
    this.columnConfigList=ShifuFileUtils.searchColumnConfig(evalConfig,columnConfigList);
  }
  this.header=CommonUtils.getHeaders(evalConfig.getDataSet().getHeaderPath(),evalConfig.getDataSet().getHeaderDelimiter(),evalConfig.getDataSet().getSource());
  List<BasicML> models=CommonUtils.loadBasicModels(modelConfig,evalConfig,evalConfig.getDataSet().getSource());
  modelRunner=new ModelRunner(modelConfig,columnConfigList,this.header,evalConfig.getDataSet().getDataDelimiter(),models);
  modelCnt=models.size();
}

Fixed version (ground truth):
public EvalScoreUDF(String source,String pathModelConfig,String pathColumnConfig,String evalSetName) throws IOException {
  super(source,pathModelConfig,pathColumnConfig);
  evalConfig=modelConfig.getEvalConfigByName(evalSetName);
  negTags=modelConfig.getNegTags();
  log.debug("String_Node_Str" + negTags);
  posTags=modelConfig.getPosTags();
  log.debug("String_Node_Str" + posTags);
  if (evalConfig.getModelsPath() != null) {
    this.columnConfigList=ShifuFileUtils.searchColumnConfig(evalConfig,columnConfigList);
  }
  this.headers=CommonUtils.getHeaders(evalConfig.getDataSet().getHeaderPath(),evalConfig.getDataSet().getHeaderDelimiter(),evalConfig.getDataSet().getSource());
  List<BasicML> models=CommonUtils.loadBasicModels(modelConfig,evalConfig,evalConfig.getDataSet().getSource());
  modelRunner=new ModelRunner(modelConfig,columnConfigList,this.headers,evalConfig.getDataSet().getDataDelimiter(),models);
  modelCnt=models.size();
}
Program: 32154
Project: 32154
Buggy source:
public Tuple exec(Tuple input) throws IOException {
  Map<String,String> rawDataMap=CommonUtils.convertDataIntoMap(input,this.header);
  if (MapUtils.isEmpty(rawDataMap)) {
    return null;
  }
  CaseScoreResult cs=modelRunner.compute(rawDataMap);
  if (cs == null) {
    log.error("String_Node_Str" + input.toDelimitedString("String_Node_Str"));
    return null;
  }
  Tuple tuple=TupleFactory.getInstance().newTuple();
  String tag=rawDataMap.get(modelConfig.getTargetColumnName(evalConfig));
  tuple.append(StringUtils.trimToEmpty(tag));
  String weight=null;
  if (StringUtils.isNotBlank(evalConfig.getDataSet().getWeightColumnName())) {
    weight=rawDataMap.get(evalConfig.getDataSet().getWeightColumnName());
  }
 else {
    weight="String_Node_Str";
  }
  incrementTagCounters(tag,weight);
  tuple.append(weight);
  tuple.append(cs.getAvgScore());
  tuple.append(cs.getMaxScore());
  tuple.append(cs.getMinScore());
  tuple.append(cs.getMedianScore());
  for (  Integer score : cs.getScores()) {
    tuple.append(score);
  }
  List<String> metaColumns=evalConfig.getScoreMetaColumns(modelConfig);
  if (CollectionUtils.isNotEmpty(metaColumns)) {
    for (    String meta : metaColumns) {
      tuple.append(rawDataMap.get(meta));
    }
  }
  return tuple;
}

Fixed version (ground truth):
public Tuple exec(Tuple input) throws IOException {
  Map<String,String> rawDataMap=CommonUtils.convertDataIntoMap(input,this.headers);
  if (MapUtils.isEmpty(rawDataMap)) {
    return null;
  }
  CaseScoreResult cs=modelRunner.compute(rawDataMap);
  if (cs == null) {
    log.error("String_Node_Str" + input.toDelimitedString("String_Node_Str"));
    return null;
  }
  Tuple tuple=TupleFactory.getInstance().newTuple();
  String tag=rawDataMap.get(modelConfig.getTargetColumnName(evalConfig));
  tuple.append(StringUtils.trimToEmpty(tag));
  String weight=null;
  if (StringUtils.isNotBlank(evalConfig.getDataSet().getWeightColumnName())) {
    weight=rawDataMap.get(evalConfig.getDataSet().getWeightColumnName());
  }
 else {
    weight="String_Node_Str";
  }
  incrementTagCounters(tag,weight);
  tuple.append(weight);
  tuple.append(cs.getAvgScore());
  tuple.append(cs.getMaxScore());
  tuple.append(cs.getMinScore());
  tuple.append(cs.getMedianScore());
  for (  Integer score : cs.getScores()) {
    tuple.append(score);
  }
  List<String> metaColumns=evalConfig.getScoreMetaColumns(modelConfig);
  if (CollectionUtils.isNotEmpty(metaColumns)) {
    for (    String meta : metaColumns) {
      tuple.append(rawDataMap.get(meta));
    }
  }
  return tuple;
}
Program: 32155
Project: 32155
Buggy source:
@Test public void testIsConverged(){
  double train_err=1.0;
  double test_err=3.0;
  double threshold1=1.0;
  double threshold2=2.0;
  double threshold3=3.0;
  Assert.assertTrue(ConvergeJudger.isConverged(train_err,test_err,threshold1));
  Assert.assertTrue(ConvergeJudger.isConverged(train_err,test_err,threshold2));
  Assert.assertFalse(ConvergeJudger.isConverged(train_err,test_err,threshold3));
}

Fixed version (ground truth):
@Test public void testIsConverged(){
  double train_err=1.0;
  double test_err=3.0;
  double threshold1=1.0;
  double threshold2=2.0;
  double threshold3=3.0;
  Assert.assertFalse(ConvergeJudger.isConverged(train_err,test_err,threshold1));
  Assert.assertTrue(ConvergeJudger.isConverged(train_err,test_err,threshold2));
  Assert.assertTrue(ConvergeJudger.isConverged(train_err,test_err,threshold3));
}
Program: 32157
Project: 32157
Buggy source:
public static boolean isGoodCandidate(ColumnConfig columnConfig){
  if (columnConfig == null) {
    return false;
  }
  return columnConfig.isCandidate() && (columnConfig.getKs() != null && columnConfig.getKs() > 0 && columnConfig.getIv() != null && columnConfig.getIv() > 0 && ((columnConfig.isCategorical() && columnConfig.getBinCategory() != null && columnConfig.getBinCategory().size() > 1) || (columnConfig.isNumerical() && columnConfig.getBinBoundary() != null && columnConfig.getBinBoundary().size() > 1)));
}

Fixed version (ground truth):
public static boolean isGoodCandidate(ColumnConfig columnConfig){
  if (columnConfig == null) {
    return false;
  }
  return columnConfig.isCandidate() && (columnConfig.getKs() != null && columnConfig.getKs() > 0 && columnConfig.getIv() != null && columnConfig.getIv() > 0 && columnConfig.getMean() != null && columnConfig.getStdDev() != null && ((columnConfig.isCategorical() && columnConfig.getBinCategory() != null && columnConfig.getBinCategory().size() > 1) || (columnConfig.isNumerical() && columnConfig.getBinBoundary() != null && columnConfig.getBinBoundary().size() > 1)));
}
Program: 32158
Project: 32158
Buggy source:
@Override public void handleMsg(Object message){
  if (message instanceof StatsPartRawDataMessage) {
    StatsPartRawDataMessage partData=(StatsPartRawDataMessage)message;
    Map<Integer,List<ValueObject>> columnVoListMap=buildColumnVoListMap(partData.getRawDataList().size());
    DataPrepareStatsResult rt=convertRawDataIntoValueObject(partData.getRawDataList(),columnVoListMap);
    int totalMsgCnt=partData.getTotalMsgCnt();
    for (    Integer columnNum : columnVoListMap.keySet()) {
      columnNumToActorMap.get(columnNum).tell(new StatsValueObjectMessage(totalMsgCnt,columnNum,columnVoListMap.get(columnNum),rt.getMissingMap().containsKey(columnNum) ? rt.getMissingMap().get(columnNum) : 0,rt.getTotal()),getSelf());
    }
  }
 else   if (message instanceof RunModelResultMessage) {
    RunModelResultMessage msg=(RunModelResultMessage)message;
    Map<Integer,List<ColumnScoreObject>> columnScoreListMap=buildColumnScoreListMap();
    convertModelResultIntoColScore(msg.getScoreResultList(),columnScoreListMap);
    int totalMsgCnt=msg.getTotalStreamCnt();
    for (    Entry<Integer,List<ColumnScoreObject>> column : columnScoreListMap.entrySet()) {
      columnNumToActorMap.get(column.getKey()).tell(new ColumnScoreMessage(totalMsgCnt,column.getKey(),column.getValue()),getSelf());
    }
  }
 else {
    unhandled(message);
  }
}

Fixed version (ground truth):
@Override public void handleMsg(Object message){
  if (message instanceof StatsPartRawDataMessage) {
    StatsPartRawDataMessage partData=(StatsPartRawDataMessage)message;
    Map<Integer,List<ValueObject>> columnVoListMap=buildColumnVoListMap(partData.getRawDataList().size());
    DataPrepareStatsResult rt=convertRawDataIntoValueObject(partData.getRawDataList(),columnVoListMap);
    int totalMsgCnt=partData.getTotalMsgCnt();
    for (    Map.Entry<Integer,List<ValueObject>> entry : columnVoListMap.entrySet()) {
      Integer columnNum=entry.getKey();
      columnNumToActorMap.get(columnNum).tell(new StatsValueObjectMessage(totalMsgCnt,columnNum,entry.getValue(),rt.getMissingMap().containsKey(columnNum) ? rt.getMissingMap().get(columnNum) : 0,rt.getTotal()),getSelf());
    }
  }
 else   if (message instanceof RunModelResultMessage) {
    RunModelResultMessage msg=(RunModelResultMessage)message;
    Map<Integer,List<ColumnScoreObject>> columnScoreListMap=buildColumnScoreListMap();
    convertModelResultIntoColScore(msg.getScoreResultList(),columnScoreListMap);
    int totalMsgCnt=msg.getTotalStreamCnt();
    for (    Entry<Integer,List<ColumnScoreObject>> column : columnScoreListMap.entrySet()) {
      columnNumToActorMap.get(column.getKey()).tell(new ColumnScoreMessage(totalMsgCnt,column.getKey(),column.getValue()),getSelf());
    }
  }
 else {
    unhandled(message);
  }
}
Program: 32160
Project: 32160
Buggy source:
/** 
 * Sum the histogram's frequency whose value less than or equal some value 
 * @param hval
 * @return
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - nhu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}

Fixed version (ground truth):
/** 
 * Sum the histogram's frequency whose value less than or equal some value 
 * @param hval
 * @return
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - nhu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2d;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}
Program: 32161
Project: 32161
Buggy source:
public TrainDataPrepWorker(ModelConfig modelConfig,List<ColumnConfig> columnConfigList,ActorRef parentActorRef,ActorRef nextActorRef,List<AbstractTrainer> trainers) throws IOException {
  super(modelConfig,columnConfigList,parentActorRef,nextActorRef);
  this.trainers=trainers;
  if (modelConfig.isTrainOnDisk()) {
    log.info("String_Node_Str");
    ShifuFileUtils.createDirIfNotExists(Constants.TMP,SourceType.LOCAL);
    masterDataSet=new BufferedMLDataSet(new File(Constants.TMP,"String_Node_Str"));
  }
 else {
    log.info("String_Node_Str");
    masterDataSet=new BasicMLDataSet();
  }
  headers=CommonUtils.getHeaders(modelConfig.getHeaderPath(),modelConfig.getHeaderDelimiter(),modelConfig.getDataSet().getSource());
}

Fixed version (ground truth):
public TrainDataPrepWorker(ModelConfig modelConfig,List<ColumnConfig> columnConfigList,ActorRef parentActorRef,ActorRef nextActorRef,List<AbstractTrainer> trainers) throws IOException {
  super(modelConfig,columnConfigList,parentActorRef,nextActorRef);
  this.trainers=trainers;
  if (modelConfig.isTrainOnDisk()) {
    log.info("String_Node_Str");
    ShifuFileUtils.createDirIfNotExists(Constants.TMP,SourceType.LOCAL);
    masterDataSet=new BufferedMLDataSet(new File(Constants.TMP,"String_Node_Str"));
  }
 else {
    log.info("String_Node_Str");
    masterDataSet=new BasicMLDataSet();
  }
}
Program: 32164
Project: 32164
Buggy source:
/** 
 * Load shifuconfig into properties
 * @param props
 * @param fileName
 * @throws IOException
 */
private static void loadProperties(Properties props,String fileName) throws IOException {
  File configFile=new File(fileName);
  if (!configFile.exists()) {
    return;
  }
  FileInputStream inStream=new FileInputStream(configFile);
  try {
    props.load(inStream);
  }
  finally {
    IOUtils.closeQuietly(inStream);
  }
}

Fixed version (ground truth):
/** 
 * Load shifuconfig into properties
 * @param props
 * @param fileName
 * @throws IOException
 */
private static void loadProperties(Properties props,String fileName) throws IOException {
  File configFile=new File(fileName);
  if (!configFile.exists()) {
    return;
  }
  FileInputStream inStream=null;
  try {
    inStream=new FileInputStream(configFile);
    props.load(inStream);
  }
  finally {
    IOUtils.closeQuietly(inStream);
  }
}
Program: 32165
Project: 32165
Buggy source:
/** 
 * set min/max, merge same bins
 * @param bins
 * @return
 */
private List<Double> binMerge(List<Double> bins){
  List<Double> newBins=new ArrayList<Double>();
  if (bins.size() == 0) {
    bins.add(Double.NaN);
    return bins;
  }
  Double cur=bins.get(0);
  newBins.add(cur);
  int i=1;
  while (i < bins.size()) {
    if (Math.abs(cur - bins.get(i)) > 1e-4) {
      newBins.add(bins.get(i));
    }
    cur=bins.get(i);
    i++;
  }
  if (newBins.size() == 1) {
    double val=newBins.get(0);
    newBins=Arrays.asList(new Double[]{Double.NEGATIVE_INFINITY,val});
  }
 else   if (newBins.size() == 2) {
    newBins.set(0,Double.NEGATIVE_INFINITY);
  }
 else {
    newBins.set(0,Double.NEGATIVE_INFINITY);
    newBins.remove(newBins.size() - 1);
  }
  return newBins;
}

Fixed version (ground truth):
/** 
 * set min/max, merge same bins
 * @param bins
 * @return
 */
private List<Double> binMerge(List<Double> bins){
  List<Double> newBins=new ArrayList<Double>();
  if (bins.size() == 0) {
    bins.add(Double.NaN);
    return bins;
  }
  Double cur=bins.get(0);
  newBins.add(cur);
  int i=1;
  while (i < bins.size()) {
    if (Math.abs(cur - bins.get(i)) > 1e-10) {
      newBins.add(bins.get(i));
    }
    cur=bins.get(i);
    i++;
  }
  if (newBins.size() == 1) {
    double val=newBins.get(0);
    newBins=Arrays.asList(new Double[]{Double.NEGATIVE_INFINITY,val});
  }
 else   if (newBins.size() == 2) {
    newBins.set(0,Double.NEGATIVE_INFINITY);
  }
 else {
    newBins.set(0,Double.NEGATIVE_INFINITY);
    newBins.remove(newBins.size() - 1);
  }
  return newBins;
}
Program: 32166
Project: 32166
Buggy source:
/** 
 * run pig stats
 * @throws IOException
 */
private void runPigStats() throws IOException {
  log.info("String_Node_Str");
  ShifuFileUtils.deleteFile(pathFinder.getPreTrainingStatsPath(),modelConfig.getDataSet().getSource());
  Map<String,String> paramsMap=new HashMap<String,String>();
  paramsMap.put("String_Node_Str",CommonUtils.escapePigString(modelConfig.getDataSetDelimiter()));
  paramsMap.put("String_Node_Str",Integer.toString(columnConfigList.size() / 3));
  try {
    if (modelConfig.getBinningAlgorithm().equals(ModelStatsConf.BinningAlgorithm.MunroPat)) {
      PigExecutor.getExecutor().submitJob(modelConfig,pathFinder.getAbsolutePath("String_Node_Str"),paramsMap);
    }
 else {
      PigExecutor.getExecutor().submitJob(modelConfig,pathFinder.getAbsolutePath("String_Node_Str"),paramsMap);
    }
  }
 catch (  IOException e) {
    throw new ShifuException(ShifuErrorCode.ERROR_RUNNING_PIG_JOB,e);
  }
catch (  Throwable e) {
    throw new RuntimeException(e);
  }
  log.info("String_Node_Str");
  updateColumnConfigWithPreTrainingStats();
  saveColumnConfigList();
}

Fixed version (ground truth):
/** 
 * run pig stats
 * @throws IOException
 */
private void runPigStats() throws IOException {
  log.info("String_Node_Str");
  ShifuFileUtils.deleteFile(pathFinder.getPreTrainingStatsPath(),modelConfig.getDataSet().getSource());
  Map<String,String> paramsMap=new HashMap<String,String>();
  paramsMap.put("String_Node_Str",CommonUtils.escapePigString(modelConfig.getDataSetDelimiter()));
  paramsMap.put("String_Node_Str",Integer.toString(columnConfigList.size() / 3));
  try {
    log.info("String_Node_Str",modelConfig.getBinningAlgorithm().toString());
    if (modelConfig.getBinningAlgorithm().equals(ModelStatsConf.BinningAlgorithm.MunroPat)) {
      PigExecutor.getExecutor().submitJob(modelConfig,pathFinder.getAbsolutePath("String_Node_Str"),paramsMap);
    }
 else {
      PigExecutor.getExecutor().submitJob(modelConfig,pathFinder.getAbsolutePath("String_Node_Str"),paramsMap);
    }
  }
 catch (  IOException e) {
    throw new ShifuException(ShifuErrorCode.ERROR_RUNNING_PIG_JOB,e);
  }
catch (  Throwable e) {
    throw new RuntimeException(e);
  }
  log.info("String_Node_Str");
  updateColumnConfigWithPreTrainingStats();
  saveColumnConfigList();
}
Program: 32167
Project: 32167
Buggy source:
@Override public Tuple exec(Tuple input) throws IOException {
  this.accumulate(input);
  Tuple output=TupleFactory.getInstance().newTuple(2);
  output.set(0,columnId);
  output.set(1,StringUtils.join(binning.getDataBin(),CalculateStatsUDF.CATEGORY_VAL_SEPARATOR));
  return output;
}

Fixed version (ground truth):
@Override public Tuple exec(Tuple input) throws IOException {
  if (input == null && input.size() < 2) {
    return null;
  }
  Integer columnId=(Integer)input.get(0);
  DataBag databag=(DataBag)input.get(1);
  ColumnConfig columnConfig=super.columnConfigList.get(columnId);
  AbstractBinning<?> binning=null;
  if (columnConfig.isCategorical()) {
    binning=new CategoricalBinning(-1);
  }
 else {
    if (super.modelConfig.getBinningMethod().equals(BinningMethod.EqualInterval)) {
      binning=new EqualIntervalBinning(modelConfig.getStats().getMaxNumBin());
    }
 else {
switch (this.modelConfig.getBinningAlgorithm()) {
case Native:
        log.info("String_Node_Str");
      binning=new NativeBinning(modelConfig.getStats().getMaxNumBin(),true);
    break;
case SPDT:
  log.info("String_Node_Str");
binning=new EqualPopulationBinning(modelConfig.getStats().getMaxNumBin());
break;
case MunroPat:
log.info("String_Node_Str");
binning=new MunroPatBinning(modelConfig.getStats().getMaxNumBin());
break;
default :
log.info("String_Node_Str");
binning=new MunroPatBinning(modelConfig.getStats().getMaxNumBin());
break;
}
}
}
Iterator<Tuple> iterator=databag.iterator();
while (iterator.hasNext()) {
Tuple element=iterator.next();
if (element == null || element.size() < 2) {
continue;
}
Object value=element.get(1);
if (value != null) {
binning.addData(value.toString());
}
}
Tuple output=TupleFactory.getInstance().newTuple(2);
output.set(0,columnId);
output.set(1,StringUtils.join(binning.getDataBin(),CalculateStatsUDF.CATEGORY_VAL_SEPARATOR));
return output;
}
Program: 32168
Project: 32168
Buggy source:
@Override public void mergeBin(AbstractBinning<?> another){
  CategoricalBinning binning=(CategoricalBinning)another;
  super.mergeBin(another);
  this.categoricalVals.addAll(binning.categoricalVals);
}

Fixed version (ground truth):
@Override public void mergeBin(AbstractBinning<?> another){
  CategoricalBinning binning=(CategoricalBinning)another;
  super.mergeBin(another);
  this.isValid=(this.isValid && binning.isValid);
  if (this.isValid) {
    this.categoricalVals.addAll(binning.categoricalVals);
  }
 else {
    this.categoricalVals.clear();
  }
}
Program: 32169
Project: 32169
Buggy source:
/** 
 * convert @CategoricalBinning to String
 * @return
 */
protected void stringToObj(String objValStr){
  super.stringToObj(objValStr);
  if (categoricalVals == null) {
    categoricalVals=new HashSet<String>();
  }
 else {
    categoricalVals.clear();
  }
  String[] objStrArr=objValStr.split(Character.toString(FIELD_SEPARATOR),-1);
  if (objStrArr.length > 4 && StringUtils.isNotBlank(objStrArr[4])) {
    String[] elements=objStrArr[4].split(Character.toString(SETLIST_SEPARATOR),-1);
    for (    String element : elements) {
      categoricalVals.add(element);
    }
  }
 else {
    log.warn("String_Node_Str" + objValStr);
  }
}

Fixed version (ground truth):
/** 
 * convert @CategoricalBinning to String
 * @return
 */
protected void stringToObj(String objValStr){
  super.stringToObj(objValStr);
  if (categoricalVals == null) {
    categoricalVals=new HashSet<String>();
  }
 else {
    categoricalVals.clear();
  }
  String[] objStrArr=objValStr.split(Character.toString(FIELD_SEPARATOR),-1);
  this.isValid=Boolean.valueOf(objStrArr[4]);
  if (objStrArr.length > 5 && StringUtils.isNotBlank(objStrArr[5])) {
    String[] elements=objStrArr[5].split(Character.toString(SETLIST_SEPARATOR),-1);
    for (    String element : elements) {
      categoricalVals.add(element);
    }
  }
 else {
    log.warn("String_Node_Str" + objValStr);
  }
}
Program: 32170
Project: 32170
Buggy source:
@Override public void addData(String val){
  String fval=StringUtils.trimToEmpty(val);
  if (!isMissingVal(fval)) {
    categoricalVals.add(fval);
  }
 else {
    super.incMissingValCnt();
  }
}

Fixed version (ground truth):
@Override public void addData(String val){
  String fval=StringUtils.trimToEmpty(val);
  if (!isMissingVal(fval)) {
    if (isValid) {
      categoricalVals.add(fval);
    }
    if (categoricalVals.size() > CalculateNewStatsUDF.MAX_CATEGORICAL_BINC_COUNT) {
      isValid=false;
      categoricalVals.clear();
    }
  }
 else {
    super.incMissingValCnt();
  }
}
Program: 32171
Project: 32171
Buggy source:
/** 
 * convert @CategoricalBinning to String
 * @return
 */
public String objToString(){
  return super.objToString() + Character.toString(FIELD_SEPARATOR) + StringUtils.join(categoricalVals,SETLIST_SEPARATOR);
}

Fixed version (ground truth):
/** 
 * convert @CategoricalBinning to String
 * @return
 */
public String objToString(){
  return super.objToString() + Character.toString(FIELD_SEPARATOR) + Boolean.toString(isValid)+ Character.toString(FIELD_SEPARATOR)+ StringUtils.join(categoricalVals,SETLIST_SEPARATOR);
}
Program: 32172
Project: 32172
Buggy source:
/** 
 * Locate histogram unit with just less than s, from some histogram unit
 * @param s
 * @param startPos
 * @return
 */
private LinkNode<HistogramUnit> locateHistogram(double s,LinkNode<HistogramUnit> startPos){
  while (startPos != this.tail) {
    HistogramUnit chu=startPos.data();
    HistogramUnit nhu=startPos.next().data();
    double sc=sum(chu.getHval());
    double sn=sum(nhu.getHval());
    if (sc < s && s <= sn) {
      return startPos;
    }
    startPos=startPos.next();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Locate histogram unit with just less than s, from some histogram unit
 * @param s
 * @param startPos
 * @return
 */
private LinkNode<HistogramUnit> locateHistogram(double s,LinkNode<HistogramUnit> startPos){
  while (startPos != this.tail) {
    if (startPos == null) {
      startPos=this.header;
    }
    HistogramUnit chu=startPos.data();
    HistogramUnit nhu=startPos.next().data();
    double sc=sum(chu.getHval());
    double sn=sum(nhu.getHval());
    if (sc >= s || (sc < s && s <= sn)) {
      return startPos;
    }
    startPos=startPos.next();
  }
  return null;
}
Program: 32173
Project: 32173
Buggy source:
/** 
 * Sum the histogram's frequency whose value less than or equal some value 
 * @param hval
 * @return
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - nhu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2;
  }
  return -1.0;
}

Fixed version (ground truth):
/** 
 * Sum the histogram's frequency whose value less than or equal some value 
 * @param hval
 * @return
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - nhu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}
Program: 32174
Project: 32174
Buggy source:
/** 
 * Generate data bin by expected bin number
 * @param toBinningNum
 * @return
 */
private List<Double> getDataBin(int toBinningNum){
  List<Double> binBorders=new ArrayList<Double>();
  binBorders.add(Double.NEGATIVE_INFINITY);
  if (this.currentHistogramUnitCnt <= toBinningNum) {
    convertHistogramUnitIntoBin(binBorders);
    return binBorders;
  }
  int totalCnt=getTotalInHistogram();
  LinkNode<HistogramUnit> currStartPos=this.header;
  for (int j=1; j < toBinningNum; j++) {
    double s=(double)(j * totalCnt) / toBinningNum;
    LinkNode<HistogramUnit> pos=locateHistogram(s,currStartPos);
    if (pos == null || pos == currStartPos) {
      continue;
    }
 else {
      HistogramUnit chu=pos.data();
      HistogramUnit nhu=pos.next().data();
      double d=s - sum(chu.getHval());
      double a=nhu.getHcnt() - chu.getHcnt();
      double b=2 * chu.getHcnt();
      double c=-2 * d;
      double z=0.0;
      if (Double.compare(a,0) == 0) {
        z=-1 * c / b;
      }
 else {
        z=(-1 * b + Math.sqrt(b * b - 4 * a * c)) / (2 * a);
      }
      double u=chu.getHval() + (nhu.getHval() - chu.getHval()) * z;
      binBorders.add(u);
      currStartPos=pos;
    }
  }
  return binBorders;
}

Fixed version (ground truth):
/** 
 * Generate data bin by expected bin number
 * @param toBinningNum
 * @return
 */
private List<Double> getDataBin(int toBinningNum){
  List<Double> binBorders=new ArrayList<Double>();
  binBorders.add(Double.NEGATIVE_INFINITY);
  if (this.currentHistogramUnitCnt <= toBinningNum) {
    convertHistogramUnitIntoBin(binBorders);
    return binBorders;
  }
  int totalCnt=getTotalInHistogram();
  LinkNode<HistogramUnit> currStartPos=null;
  for (int j=1; j < toBinningNum; j++) {
    double s=(double)(j * totalCnt) / toBinningNum;
    LinkNode<HistogramUnit> pos=locateHistogram(s,currStartPos);
    if (pos == null || pos == currStartPos) {
      continue;
    }
 else {
      HistogramUnit chu=pos.data();
      HistogramUnit nhu=pos.next().data();
      double d=s - sum(chu.getHval());
      if (d < 0) {
        double u=(chu.getHval() + nhu.getHval()) / 2;
        binBorders.add(u);
        currStartPos=pos;
        continue;
      }
      double a=nhu.getHcnt() - chu.getHcnt();
      double b=2 * chu.getHcnt();
      double c=-2 * d;
      double z=0.0;
      if (Double.compare(a,0) == 0) {
        z=-1 * c / b;
      }
 else {
        z=(-1 * b + Math.sqrt(b * b - 4 * a * c)) / (2 * a);
      }
      double u=chu.getHval() + (nhu.getHval() - chu.getHval()) * z;
      binBorders.add(u);
      currStartPos=pos;
    }
  }
  return binBorders;
}
Program: 32175
Project: 32175
Buggy source:
/** 
 * @param minIntervalOpsUnit
 */
private void removeCurrentNode(LinkNode<HistogramUnit> currNode,LinkNode<HistogramUnit> nextNode){
  if (currNode == this.header) {
    nextNode.setPrev(null);
    this.header=nextNode;
  }
 else {
    LinkNode<HistogramUnit> prev=currNode.prev();
    prev.setNext(nextNode);
    nextNode.setPrev(prev);
  }
}

Fixed version (ground truth):
/** 
 * @param currNode
 * @param nextNode
 */
private void removeCurrentNode(LinkNode<HistogramUnit> currNode,LinkNode<HistogramUnit> nextNode){
  if (currNode == this.header) {
    nextNode.setPrev(null);
    this.header=nextNode;
  }
 else {
    LinkNode<HistogramUnit> prev=currNode.prev();
    prev.setNext(nextNode);
    nextNode.setPrev(prev);
  }
}
Program: 32176
Project: 32176
Buggy source:
@Override public void consumeWorkerResults(Iterable<VarSelWorkerResult> workerResults){
  int[] voteStats=new int[columnConfigList.size() + 1];
  for (  VarSelWorkerResult workerResult : workerResults) {
    for (    Integer columnId : workerResult.getColumnIdList()) {
      voteStats[columnId + 1]++;
    }
  }
  int maxVotedColumnId=-1;
  int maxVoteCount=Integer.MIN_VALUE;
  for (int i=0; i < voteStats.length; i++) {
    if (voteStats[i] > maxVoteCount) {
      maxVoteCount=voteStats[i];
      maxVotedColumnId=i;
    }
  }
  LOG.info("String_Node_Str",maxVotedColumnId,maxVoteCount);
  if (maxVotedColumnId > 0) {
    workingSet.add(maxVotedColumnId - 1);
  }
}

Fixed version (ground truth):
@Override public void consumeWorkerResults(Iterable<VarSelWorkerResult> workerResults){
  int[] voteStats=new int[columnConfigList.size() + 1];
  for (  VarSelWorkerResult workerResult : workerResults) {
    for (    Integer columnId : workerResult.getColumnIdList()) {
      voteStats[columnId + 1]++;
    }
  }
  int maxVotedColumnId=-1;
  int maxVoteCount=Integer.MIN_VALUE;
  for (int i=0; i < voteStats.length; i++) {
    if (voteStats[i] > maxVoteCount) {
      maxVoteCount=voteStats[i];
      maxVotedColumnId=i;
    }
  }
  LOG.info("String_Node_Str",(maxVotedColumnId - 1),maxVoteCount);
  if (maxVotedColumnId > 0) {
    workingSet.add(maxVotedColumnId - 1);
  }
}
Program: 32177
Project: 32177
Buggy source:
/** 
 * Create @DerivedField for categorical variable
 * @param config - ColumnConfig for categorical variable
 * @param cutoff - cutoff for normalization
 * @return DerivedField for variable
 */
private DerivedField createCategoricalDerivedField(ColumnConfig config,double cutoff){
  InlineTable inlineTable=new InlineTable();
  for (int i=0; i < config.getBinCategory().size(); i++) {
    String cval=config.getBinCategory().get(i);
    String dval=Normalizer.normalize(config,cval,cutoff).toString();
    Document document=null;
    try {
      document=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    }
 catch (    ParserConfigurationException e) {
      e.printStackTrace();
    }
    Element out=document.createElementNS(NAME_SPACE_URI,ELEMENT_OUT);
    out.setTextContent(dval);
    Element origin=document.createElementNS(NAME_SPACE_URI,ELEMENT_ORIGIN);
    origin.setTextContent(cval);
    inlineTable.withRows(new Row().withContent(origin).withContent(out));
  }
  MapValues mapValues=new MapValues("String_Node_Str").withDataType(DataType.DOUBLE).withDefaultValue("String_Node_Str").withFieldColumnPairs(new FieldColumnPair(new FieldName(config.getColumnName()),"String_Node_Str")).withInlineTable(inlineTable);
  mapValues.setMapMissingTo("String_Node_Str");
  return new DerivedField(OpType.CONTINUOUS,DataType.DOUBLE).withName(FieldName.create(config.getColumnName() + ZSCORE_POSTFIX)).withExpression(mapValues);
}

Fixed version (ground truth):
/** 
 * Create @DerivedField for categorical variable
 * @param config - ColumnConfig for categorical variable
 * @param cutoff - cutoff for normalization
 * @return DerivedField for variable
 */
private DerivedField createCategoricalDerivedField(ColumnConfig config,double cutoff){
  Document document=null;
  try {
    document=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  }
 catch (  ParserConfigurationException e) {
    LOG.error("String_Node_Str",e);
    throw new RuntimeException("String_Node_Str",e);
  }
  String defaultValue="String_Node_Str";
  String missingValue="String_Node_Str";
  InlineTable inlineTable=new InlineTable();
  for (int i=0; i < config.getBinCategory().size(); i++) {
    String cval=config.getBinCategory().get(i);
    String dval=Normalizer.normalize(config,cval,cutoff).toString();
    Element out=document.createElementNS(NAME_SPACE_URI,ELEMENT_OUT);
    out.setTextContent(dval);
    Element origin=document.createElementNS(NAME_SPACE_URI,ELEMENT_ORIGIN);
    origin.setTextContent(cval);
    inlineTable.withRows(new Row().withContent(origin).withContent(out));
    if (StringUtils.isBlank(cval)) {
      missingValue=dval;
    }
  }
  MapValues mapValues=new MapValues("String_Node_Str").withDataType(DataType.DOUBLE).withDefaultValue(defaultValue).withFieldColumnPairs(new FieldColumnPair(new FieldName(config.getColumnName()),ELEMENT_ORIGIN)).withInlineTable(inlineTable).withMapMissingTo(missingValue);
  return new DerivedField(OpType.CONTINUOUS,DataType.DOUBLE).withName(FieldName.create(config.getColumnName() + ZSCORE_POSTFIX)).withExpression(mapValues);
}
Program: 32178
Project: 32178
Buggy source:
@Override public Tuple exec(Tuple input) throws IOException {
  if (input == null) {
    return null;
  }
  Integer columnId=(Integer)input.get(0);
  DataBag databag=(DataBag)input.get(1);
  ColumnConfig columnConfig=super.columnConfigList.get(columnId);
  AbstractBinning<?> binning=null;
  log.info("String_Node_Str" + columnId + "String_Node_Str"+ databag.size());
  Iterator<Tuple> iterator=databag.iterator();
  while (iterator.hasNext()) {
    Tuple element=iterator.next();
    if (element == null || element.size() < 2) {
      continue;
    }
    String objValStr=(String)element.get(1);
    AbstractBinning<?> partialBinning=AbstractBinning.constructBinningFromStr(modelConfig,columnConfig,objValStr);
    if (binning == null) {
      binning=partialBinning;
    }
 else {
      binning.mergeBin(partialBinning);
    }
  }
  Tuple output=TupleFactory.getInstance().newTuple(2);
  output.set(0,columnId);
  output.set(1,StringUtils.join(binning.getDataBin(),CalculateStatsUDF.CATEGORY_VAL_SEPARATOR));
  log.info("String_Node_Str" + columnId);
  return output;
}

Fixed version (ground truth):
@Override public Tuple exec(Tuple input) throws IOException {
  if (input == null) {
    return null;
  }
  Integer columnId=(Integer)input.get(0);
  DataBag databag=(DataBag)input.get(1);
  ColumnConfig columnConfig=super.columnConfigList.get(columnId);
  AbstractBinning<?> binning=null;
  log.info("String_Node_Str" + columnId + "String_Node_Str"+ databag.size());
  Iterator<Tuple> iterator=databag.iterator();
  while (iterator.hasNext()) {
    Tuple element=iterator.next();
    if (element == null || element.size() < 2) {
      continue;
    }
    String objValStr=(String)element.get(1);
    AbstractBinning<?> partialBinning=AbstractBinning.constructBinningFromStr(modelConfig,columnConfig,objValStr);
    if (binning == null) {
      binning=partialBinning;
    }
 else {
      binning.mergeBin(partialBinning);
    }
  }
  Tuple output=TupleFactory.getInstance().newTuple(2);
  output.set(0,columnId);
  List<?> binFields=binning.getDataBin();
  if (binFields.size() > CalculateNewStatsUDF.MAX_CATEGORICAL_BINC_COUNT) {
    output.set(1,"String_Node_Str");
  }
 else {
    output.set(1,StringUtils.join(binning.getDataBin(),CalculateStatsUDF.CATEGORY_VAL_SEPARATOR));
  }
  log.info("String_Node_Str" + columnId);
  return output;
}
Program: 32180
Project: 32180
Buggy source:
/** 
 * Given a column value, return bin list index. Return 0 for Category because of index 0 is started from NEGATIVE_INFINITY.
 * @throws IllegalArgumentException if input is null or empty.
 * @throws NumberFormatException    if columnVal does not contain a parsable number.
 */
public static int getBinNum(ColumnConfig columnConfig,String columnVal){
  if (StringUtils.isEmpty(columnVal) || columnConfig == null) {
    throw new IllegalArgumentException(String.format("String_Node_Str",columnVal,columnConfig));
  }
  if (columnConfig.isCategorical()) {
    List<String> binCategories=columnConfig.getBinCategory();
    for (int i=0; i < binCategories.size(); i++) {
      if (binCategories.get(i).equals(columnVal)) {
        return i;
      }
    }
    return 0;
  }
 else {
    return getNumericBinNum(columnConfig.getBinBoundary(),Double.valueOf(columnVal));
  }
}

Fixed version (ground truth):
/** 
 * Given a column value, return bin list index. Return 0 for Category because of index 0 is started from NEGATIVE_INFINITY.
 * @throws IllegalArgumentException if input is null or empty.
 * @throws NumberFormatException    if columnVal does not contain a parsable number.
 */
public static int getBinNum(ColumnConfig columnConfig,String columnVal){
  if (columnConfig.isCategorical()) {
    List<String> binCategories=columnConfig.getBinCategory();
    for (int i=0; i < binCategories.size(); i++) {
      if (binCategories.get(i).equals(columnVal)) {
        return i;
      }
    }
    return -1;
  }
 else {
    if (StringUtils.isBlank(columnVal)) {
      return -1;
    }
    double dval=0.0;
    try {
      dval=Double.parseDouble(columnVal);
    }
 catch (    Exception e) {
      return -1;
    }
    return getNumericBinNum(columnConfig.getBinBoundary(),dval);
  }
}
Program: 32181
Project: 32181
Buggy source:
@Test public void testSerialObject(){
  CategoricalBinning binning=new CategoricalBinning(10);
  String binStr=binning.objToString();
  String[] fieldArr=binStr.split(Character.toString(AbstractBinning.FIELD_SEPARATOR),-1);
  Assert.assertTrue(fieldArr.length == 5);
}

Fixed version (ground truth):
@Test public void testSerialObject(){
  CategoricalBinning binning=new CategoricalBinning(10);
  String binStr=binning.objToString();
  String[] fieldArr=binStr.split(Character.toString(AbstractBinning.FIELD_SEPARATOR),-1);
  Assert.assertTrue(fieldArr.length == 6);
}
Program: 32183
Project: 32183
Buggy source:
private void writeColumnIdsIntoHDFS(Path path,List<Integer> columnIds){
  PrintWriter pw=null;
  try {
    FSDataOutputStream fos=FileSystem.get(new Configuration()).create(path);
    pw=new PrintWriter(fos);
    pw.println(Integer.toString(columnIds.size()) + "String_Node_Str" + columnIds.toString());
    pw.flush();
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",e);
  }
 finally {
    IOUtils.closeStream(pw);
  }
}

Fixed version (ground truth):
private void writeColumnIdsIntoHDFS(Path path,List<Integer> columnIds){
  PrintWriter pw=null;
  try {
    FSDataOutputStream fos=FileSystem.get(new Configuration()).create(path);
    pw=new PrintWriter(fos);
    pw.println(Integer.toString(columnIds.size()) + "String_Node_Str" + columnIds.toString());
    pw.flush();
  }
 catch (  IOException e) {
    e.printStackTrace();
    LOG.error("String_Node_Str",e);
  }
 finally {
    IOUtils.closeStream(pw);
  }
}
Program: 32184
Project: 32184
Buggy source:
private void votedVariablesSelection() throws ClassNotFoundException, IOException, InterruptedException {
  log.info("String_Node_Str");
  SourceType sourceType=super.getModelConfig().getDataSet().getSource();
  final List<String> args=new ArrayList<String>();
  prepareVarSelParams(args,sourceType);
  Path columnIdsPath=getVotedSelectionPath(sourceType);
  args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,Constants.VAR_SEL_COLUMN_IDS_OUPUT,columnIdsPath.toString()));
  System.out.println(args);
  long start=System.currentTimeMillis();
  GuaguaMapReduceClient guaguaClient=new GuaguaMapReduceClient();
  guaguaClient.creatJob(args.toArray(new String[0])).waitForCompletion(true);
  log.info("String_Node_Str",System.currentTimeMillis() - start);
}

Fixed version (ground truth):
private void votedVariablesSelection() throws ClassNotFoundException, IOException, InterruptedException {
  log.info("String_Node_Str");
  SourceType sourceType=super.getModelConfig().getDataSet().getSource();
  final List<String> args=new ArrayList<String>();
  prepareVarSelParams(args,sourceType);
  Path columnIdsPath=getVotedSelectionPath(sourceType);
  args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,Constants.VAR_SEL_COLUMN_IDS_OUPUT,columnIdsPath.toString()));
  System.out.println(args);
  long start=System.currentTimeMillis();
  GuaguaMapReduceClient guaguaClient=new GuaguaMapReduceClient();
  guaguaClient.creatJob(args.toArray(new String[0])).waitForCompletion(true);
  log.info("String_Node_Str",System.currentTimeMillis() - start);
  persistColumnIds(columnIdsPath);
}