nus-yam/ex-repair huggingface dataset:
Program: 31856
Project: 31856
Buggy source:
/** 
 * delete some evaluation set
 * @param evalSetName
 * @throws Exception
 */
private static int deleteEvalSet(String evalSetName) throws Exception {
  EvalModelProcessor p=new EvalModelProcessor(EvalStep.DELETE,evalSetName);
  return p.run();
}

Fixed version (ground truth):
private static int deleteEvalSet(String evalSetName) throws Exception {
  EvalModelProcessor p=new EvalModelProcessor(EvalStep.DELETE,evalSetName);
  return p.run();
}
Program: 31857
Project: 31857
Buggy source:
/** 
 * @param evalSetNames
 * @throws Exception
 */
public static int runEvalScore(String evalSetNames) throws Exception {
  EvalModelProcessor p=new EvalModelProcessor(EvalStep.SCORE,evalSetNames);
  return p.run();
}

Fixed version (ground truth):
public static int runEvalScore(String evalSetNames) throws Exception {
  EvalModelProcessor p=new EvalModelProcessor(EvalStep.SCORE,evalSetNames);
  return p.run();
}
Program: 31862
Project: 31862
Buggy source:
@Override public int compare(ColumnConfig from,ColumnConfig to){
  return from.getColumnName().compareTo(to.getColumnName());
}

Fixed version (ground truth):
@Override public int compare(FileStatus o1,FileStatus o2){
  return o1.getPath().toString().compareTo(o2.getPath().toString());
}
Program: 31869
Project: 31869
Buggy source:
/** 
 * @param resultMap2
 * @return
 */
private boolean hasAllMessageResult(Map<Integer,StreamBulletin> resultMsgMap){
  Iterator<Entry<Integer,StreamBulletin>> iterator=resultMsgMap.entrySet().iterator();
  while (iterator.hasNext()) {
    Entry<Integer,StreamBulletin> entry=iterator.next();
    if (!entry.getValue().isMessageEnd()) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean hasAllMessageResult(Map<Integer,StreamBulletin> resultMsgMap){
  Iterator<Entry<Integer,StreamBulletin>> iterator=resultMsgMap.entrySet().iterator();
  while (iterator.hasNext()) {
    Entry<Integer,StreamBulletin> entry=iterator.next();
    if (!entry.getValue().isMessageEnd()) {
      return false;
    }
  }
  return true;
}
Program: 31870
Project: 31870
Buggy source:
/** 
 * Write the file header for score file
 * @throws IOException
 */
private void writeScoreHeader() throws IOException {
  StringBuilder buf=new StringBuilder();
  buf.append(modelConfig.getTargetColumnName(evalConfig) == null ? "String_Node_Str" : modelConfig.getTargetColumnName(evalConfig));
  buf.append("String_Node_Str" + (StringUtils.isBlank(evalConfig.getDataSet().getWeightColumnName()) ? "String_Node_Str" : evalConfig.getDataSet().getWeightColumnName()));
  buf.append("String_Node_Str");
  List<BasicML> models=CommonUtils.loadBasicModels(modelConfig,columnConfigList,evalConfig,SourceType.LOCAL);
  for (int i=0; i < models.size(); i++) {
    buf.append("String_Node_Str" + i);
  }
  List<String> metaColumns=evalConfig.getAllMetaColumns(modelConfig);
  if (CollectionUtils.isNotEmpty(metaColumns)) {
    for (    String columnName : metaColumns) {
      buf.append("String_Node_Str" + columnName);
    }
  }
  scoreWriter.write(buf.toString() + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Write the file header for score file
 * @throws IOException if any ip exception
 */
private void writeScoreHeader() throws IOException {
  StringBuilder buf=new StringBuilder();
  buf.append(modelConfig.getTargetColumnName(evalConfig) == null ? "String_Node_Str" : modelConfig.getTargetColumnName(evalConfig));
  buf.append("String_Node_Str" + (StringUtils.isBlank(evalConfig.getDataSet().getWeightColumnName()) ? "String_Node_Str" : evalConfig.getDataSet().getWeightColumnName()));
  buf.append("String_Node_Str");
  List<BasicML> models=CommonUtils.loadBasicModels(modelConfig,columnConfigList,evalConfig,SourceType.LOCAL);
  for (int i=0; i < models.size(); i++) {
    buf.append("String_Node_Str" + i);
  }
  List<String> metaColumns=evalConfig.getAllMetaColumns(modelConfig);
  if (CollectionUtils.isNotEmpty(metaColumns)) {
    for (    String columnName : metaColumns) {
      buf.append("String_Node_Str" + columnName);
    }
  }
  scoreWriter.write(buf.toString() + "String_Node_Str");
}
Program: 31871
Project: 31871
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,false);
}

Fixed version (ground truth):
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: 31872
Project: 31872
Buggy source:
/** 
 * Normalize the raw data, according the ColumnConfig infomation and normalization type. Currently, the cutoff value doesn't affect the computation of WOE or WEIGHT_WOE type. <p> Noticed: currently OLD_ZSCALE and ZSCALE is implemented with the same process method. </p>
 * @param config ColumnConfig to normalize data
 * @param raw raw input data
 * @param cutoff standard deviation cut off
 * @param type normalization type.  {@link ModelNormalizeConf.NormType}
 * @return normalized value. If normType parameter is invalid, then the ZSCALE will be used as default.
 */
public static Double normalize(ColumnConfig config,String raw,Double cutoff,ModelNormalizeConf.NormType type){
switch (type) {
case WOE:
    return woeNormalize(config,raw,false);
case WEIGHT_WOE:
  return woeNormalize(config,raw,true);
case HYBRID:
return hybridNormalize(config,raw,cutoff,false);
case WEIGHT_HYBRID:
return hybridNormalize(config,raw,cutoff,true);
case WOE_ZSCORE:
return woeZScoreNormalize(config,raw,cutoff,false);
case WEIGHT_WOE_ZSCORE:
return woeZScoreNormalize(config,raw,cutoff,true);
case OLD_ZSCALE:
case OLD_ZSCORE:
case ZSCALE:
case ZSCORE:
default :
return zScoreNormalize(config,raw,cutoff);
}
}

Fixed version (ground truth):
/** 
 * Normalize the raw data, according the ColumnConfig infomation and normalization type. Currently, the cutoff value doesn't affect the computation of WOE or WEIGHT_WOE type. <p> Noticed: currently OLD_ZSCALE and ZSCALE is implemented with the same process method. </p>
 * @param config ColumnConfig to normalize data
 * @param raw raw input data
 * @param cutoff standard deviation cut off
 * @param type normalization type of ModelNormalizeConf.NormType
 * @return normalized value. If normType parameter is invalid, then the ZSCALE will be used as default.
 */
public static Double normalize(ColumnConfig config,String raw,Double cutoff,ModelNormalizeConf.NormType type){
switch (type) {
case WOE:
    return woeNormalize(config,raw,false);
case WEIGHT_WOE:
  return woeNormalize(config,raw,true);
case HYBRID:
return hybridNormalize(config,raw,cutoff,false);
case WEIGHT_HYBRID:
return hybridNormalize(config,raw,cutoff,true);
case WOE_ZSCORE:
return woeZScoreNormalize(config,raw,cutoff,false);
case WEIGHT_WOE_ZSCORE:
return woeZScoreNormalize(config,raw,cutoff,true);
case OLD_ZSCALE:
case OLD_ZSCORE:
case ZSCALE:
case ZSCORE:
default :
return zScoreNormalize(config,raw,cutoff);
}
}
Program: 31873
Project: 31873
Buggy source:
/** 
 * set min/max, merge same bins In a very skewed data array, this one may not be well performed
 * @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;
}

Fixed version (ground truth):
/** 
 * set min/max, merge same bins In a very skewed data array, this one may not be well performed
 * @param bins input bins
 * @return merged bins
 */
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: 31874
Project: 31874
Buggy source:
/** 
 * get the eval data path for sub model
 * @param subModelConfig - @ModelConfig for sub model
 * @param evalConfig
 * @return
 */
private String getEvalDataPath(ModelConfig subModelConfig,EvalConfig evalConfig){
  PathFinder pathFinder=new PathFinder(subModelConfig);
  String evalDataPath=pathFinder.getEvalScorePath(evalConfig);
  if (RawSourceData.SourceType.LOCAL.equals(evalConfig.getDataSet().getSource())) {
    evalDataPath=subModelConfig.getModelSetName() + File.separator + evalDataPath;
  }
  return evalDataPath;
}

Fixed version (ground truth):
/** 
 * get the eval data path for sub model
 * @param subModelConfig - @ModelConfig for sub model
 * @param evalConfig eval config
 * @return eval data path
 */
private String getEvalDataPath(ModelConfig subModelConfig,EvalConfig evalConfig){
  PathFinder pathFinder=new PathFinder(subModelConfig);
  String evalDataPath=pathFinder.getEvalScorePath(evalConfig);
  if (RawSourceData.SourceType.LOCAL.equals(evalConfig.getDataSet().getSource())) {
    evalDataPath=subModelConfig.getModelSetName() + File.separator + evalDataPath;
  }
  return evalDataPath;
}
Program: 31875
Project: 31875
Buggy source:
/** 
 * Save ModelConfig into some folder
 * @param folder - folder to host ModelConfig.json
 * @param modelConfig
 * @throws IOException
 */
private void saveModelConfig(String folder,ModelConfig modelConfig) throws IOException {
  JSONUtils.writeValue(new File(folder + File.separator + Constants.MODEL_CONFIG_JSON_FILE_NAME),modelConfig);
}

Fixed version (ground truth):
/** 
 * Save ModelConfig into some folder
 * @param folder - folder to host ModelConfig.json
 * @param modelConfig model config instance
 * @throws IOException any io exception
 */
private void saveModelConfig(String folder,ModelConfig modelConfig) throws IOException {
  JSONUtils.writeValue(new File(folder + File.separator + Constants.MODEL_CONFIG_JSON_FILE_NAME),modelConfig);
}
Program: 31876
Project: 31876
Buggy source:
/** 
 * Create @ModelTrainConf according the @ModelTrainConf.ALGORITHM
 * @param alg - the algorithm, see @ModelTrainConf.ALGORITHM
 * @return
 */
private ModelTrainConf createModelTrainConf(ModelTrainConf.ALGORITHM alg){
  ModelTrainConf trainConf=new ModelTrainConf();
  trainConf.setAlgorithm(alg.name());
  trainConf.setEpochsPerIteration(1);
  trainConf.setParams(ModelTrainConf.createParamsByAlg(alg,trainConf));
  trainConf.setNumTrainEpochs(100);
  if (ModelTrainConf.ALGORITHM.NN.equals(alg)) {
    trainConf.setNumTrainEpochs(200);
  }
 else   if (ModelTrainConf.ALGORITHM.SVM.equals(alg)) {
    trainConf.setNumTrainEpochs(100);
  }
 else   if (ModelTrainConf.ALGORITHM.RF.equals(alg)) {
    trainConf.setNumTrainEpochs(20000);
  }
 else   if (ModelTrainConf.ALGORITHM.GBT.equals(alg)) {
    trainConf.setNumTrainEpochs(20000);
  }
 else   if (ModelTrainConf.ALGORITHM.LR.equals(alg)) {
    trainConf.setNumTrainEpochs(100);
  }
  trainConf.setBaggingWithReplacement(true);
  return trainConf;
}

Fixed version (ground truth):
/** 
 * Create @ModelTrainConf according the @ModelTrainConf.ALGORITHM
 * @param alg - the algorithm, see @ModelTrainConf.ALGORITHM
 * @return train config instance
 */
private ModelTrainConf createModelTrainConf(ModelTrainConf.ALGORITHM alg){
  ModelTrainConf trainConf=new ModelTrainConf();
  trainConf.setAlgorithm(alg.name());
  trainConf.setEpochsPerIteration(1);
  trainConf.setParams(ModelTrainConf.createParamsByAlg(alg,trainConf));
  trainConf.setNumTrainEpochs(100);
  if (ModelTrainConf.ALGORITHM.NN.equals(alg)) {
    trainConf.setNumTrainEpochs(200);
  }
 else   if (ModelTrainConf.ALGORITHM.SVM.equals(alg)) {
    trainConf.setNumTrainEpochs(100);
  }
 else   if (ModelTrainConf.ALGORITHM.RF.equals(alg)) {
    trainConf.setNumTrainEpochs(20000);
  }
 else   if (ModelTrainConf.ALGORITHM.GBT.equals(alg)) {
    trainConf.setNumTrainEpochs(20000);
  }
 else   if (ModelTrainConf.ALGORITHM.LR.equals(alg)) {
    trainConf.setNumTrainEpochs(100);
  }
  trainConf.setBaggingWithReplacement(true);
  return trainConf;
}
Program: 31877
Project: 31877
Buggy source:
/** 
 * Create @VarTrainConf according the @ModelTrainConf.ALGORITHM
 * @param alg - the algorithm, see @ModelTrainConf.ALGORITHM
 * @return
 */
private VarTrainConf createVarTrainConf(ModelTrainConf.ALGORITHM alg){
  VarTrainConf varTrainConf=new VarTrainConf();
  varTrainConf.setVariables(new ArrayList<String>());
  varTrainConf.setModelTrainConf(createModelTrainConf(alg));
  return varTrainConf;
}

Fixed version (ground truth):
/** 
 * Create @VarTrainConf according the @ModelTrainConf.ALGORITHM
 * @param alg - the algorithm, see @ModelTrainConf.ALGORITHM
 * @return train config instance
 */
private VarTrainConf createVarTrainConf(ModelTrainConf.ALGORITHM alg){
  VarTrainConf varTrainConf=new VarTrainConf();
  varTrainConf.setVariables(new ArrayList<String>());
  varTrainConf.setModelTrainConf(createModelTrainConf(alg));
  return varTrainConf;
}
Program: 31878
Project: 31878
Buggy source:
/** 
 * Generate sub model name
 * @param i - sequence to keep unique
 * @param varTrainConf
 * @return
 */
private String genSubModelName(int i,VarTrainConf varTrainConf){
  return this.modelConfig.getBasic().getName() + "String_Node_Str" + varTrainConf.getModelTrainConf().getAlgorithm()+ "String_Node_Str"+ i;
}

Fixed version (ground truth):
/** 
 * Generate sub model name
 * @param i - sequence to keep unique
 * @param varTrainConf train config
 * @return sub model name
 */
private String genSubModelName(int i,VarTrainConf varTrainConf){
  return this.modelConfig.getBasic().getName() + "String_Node_Str" + varTrainConf.getModelTrainConf().getAlgorithm()+ "String_Node_Str"+ i;
}
Program: 31879
Project: 31879
Buggy source:
/** 
 * Load ComboModelTrain from ComboTrain.json
 * @return
 */
private ComboModelTrain loadComboTrain(){
  try {
    return JSONUtils.readValue(new File(Constants.COMBO_CONFIG_JSON_FILE_NAME),ComboModelTrain.class);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str");
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Load ComboModelTrain from ComboTrain.json
 * @return combo model train instance, null if exception
 */
private ComboModelTrain loadComboTrain(){
  try {
    return JSONUtils.readValue(new File(Constants.COMBO_CONFIG_JSON_FILE_NAME),ComboModelTrain.class);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str");
    return null;
  }
}
Program: 31880
Project: 31880
Buggy source:
/** 
 * Get evaluation output file format
 * @param runMode
 * @return
 */
private ColumnFile.FileType genEvalFileType(ModelBasicConf.RunMode runMode){
  return (ModelBasicConf.RunMode.MAPRED.equals(runMode) ? ColumnFile.FileType.PIGSTORAGE : ColumnFile.FileType.CSV);
}

Fixed version (ground truth):
/** 
 * Get evaluation output file format
 * @param runMode run mode
 * @return file type
 */
private ColumnFile.FileType genEvalFileType(ModelBasicConf.RunMode runMode){
  return (ModelBasicConf.RunMode.MAPRED.equals(runMode) ? ColumnFile.FileType.PIGSTORAGE : ColumnFile.FileType.CSV);
}
Program: 31881
Project: 31881
Buggy source:
/** 
 * Clone @ColumnConfig list for sub-models
 * @param columnConfigList
 * @return
 */
private List<ColumnConfig> cloneColumnConfigs(List<ColumnConfig> columnConfigList){
  List<ColumnConfig> columnConfigs=new ArrayList<ColumnConfig>();
  for (  ColumnConfig columnConfig : columnConfigList) {
    columnConfigs.add(columnConfig.clone());
  }
  return columnConfigs;
}

Fixed version (ground truth):
/** 
 * Clone @ColumnConfig list for sub-models
 * @param columnConfigList column config list
 * @return cloned column config list
 */
private List<ColumnConfig> cloneColumnConfigs(List<ColumnConfig> columnConfigList){
  List<ColumnConfig> columnConfigs=new ArrayList<ColumnConfig>();
  for (  ColumnConfig columnConfig : columnConfigList) {
    columnConfigs.add(columnConfig.clone());
  }
  return columnConfigs;
}
Program: 31882
Project: 31882
Buggy source:
/** 
 * Append weight column, if not blank, with uid column as score meta data.
 * @param weightColumnName
 * @return
 */
private String[] genEvalScoreMetaVars(String weightColumnName){
  return new String[]{this.comboModelTrain.getUidColumnName()};
}

Fixed version (ground truth):
/** 
 * Append weight column, if not blank, with uid column as score meta data.
 * @param weightColumnName weight column name
 * @return eval meta vars
 */
private String[] genEvalScoreMetaVars(String weightColumnName){
  return new String[]{this.comboModelTrain.getUidColumnName()};
}
Program: 31883
Project: 31883
Buggy source:
/** 
 * Save ColumnConfig list into some folder
 * @param folder - folder to host ColumnConfig.json
 * @param columnConfigs
 * @throws IOException
 */
private void saveColumnConfigList(String folder,List<ColumnConfig> columnConfigs) throws IOException {
  JSONUtils.writeValue(new File(folder + File.separator + Constants.COLUMN_CONFIG_JSON_FILE_NAME),columnConfigs);
}

Fixed version (ground truth):
/** 
 * Save ColumnConfig list into some folder
 * @param folder - folder to host ColumnConfig.json
 * @param columnConfigs column config list
 * @throws IOException any io exception
 */
private void saveColumnConfigList(String folder,List<ColumnConfig> columnConfigs) throws IOException {
  JSONUtils.writeValue(new File(folder + File.separator + Constants.COLUMN_CONFIG_JSON_FILE_NAME),columnConfigs);
}
Program: 31884
Project: 31884
Buggy source:
/** 
 * Create evaluation tasks for all sub-models
 * @param evalName - the evalset to evaluate
 * @return
 * @throws IOException
 */
private List<Callable<Integer>> createEvaluateTasks(final String evalName) throws IOException {
  List<Callable<Integer>> tasks=new ArrayList<Callable<Integer>>();
  for (int i=0; i < this.comboModelTrain.getVarTrainConfList().size(); i++) {
    VarTrainConf varTrainConf=this.comboModelTrain.getVarTrainConfList().get(i);
    final String subModelName=genSubModelName(i,varTrainConf);
    tasks.add(new Callable<Integer>(){
      @Override public Integer call(){
        try {
          return ProcessManager.runShellProcess(subModelName,new String[][]{new String[]{"String_Node_Str","String_Node_Str","String_Node_Str",evalName}});
        }
 catch (        IOException e) {
          LOG.error("String_Node_Str",e);
          return 1;
        }
      }
    }
);
  }
  return tasks;
}

Fixed version (ground truth):
/** 
 * Create evaluation tasks for all sub-models
 * @param evalName - the evalset to evaluate
 * @return list of callable instance
 * @throws IOException any io exception
 */
private List<Callable<Integer>> createEvaluateTasks(final String evalName) throws IOException {
  List<Callable<Integer>> tasks=new ArrayList<Callable<Integer>>();
  for (int i=0; i < this.comboModelTrain.getVarTrainConfList().size(); i++) {
    VarTrainConf varTrainConf=this.comboModelTrain.getVarTrainConfList().get(i);
    final String subModelName=genSubModelName(i,varTrainConf);
    tasks.add(new Callable<Integer>(){
      @Override public Integer call(){
        try {
          return ProcessManager.runShellProcess(subModelName,new String[][]{new String[]{"String_Node_Str","String_Node_Str","String_Node_Str",evalName}});
        }
 catch (        IOException e) {
          LOG.error("String_Node_Str",e);
          return 1;
        }
      }
    }
);
  }
  return tasks;
}
Program: 31885
Project: 31885
Buggy source:
/** 
 * Create train and eval task for sub-model
 * @param subModelName
 * @param evalSetName
 * @return
 */
private Callable<Integer> createTrainAndEvalTasks(final String subModelName,final String evalSetName) throws IOException {
}

Fixed version (ground truth):
/** 
 * Create train and eval task for sub-model
 * @param subModelName sub model name
 * @param evalSetName eval set name
 * @return callable instance
 */
private Callable<Integer> createTrainAndEvalTasks(final String subModelName,final String evalSetName) throws IOException {
}
Program: 31886
Project: 31886
Buggy source:
/** 
 * Generate assembel model name
 * @param modelName
 * @return
 */
private String genAssembleModelName(String modelName){
  return modelName + "String_Node_Str" + Constants.COMBO_ASSEMBLE;
}

Fixed version (ground truth):
/** 
 * Generate assembel model name
 * @param modelName model name
 * @return assemble model bane
 */
private String genAssembleModelName(String modelName){
  return modelName + "String_Node_Str" + Constants.COMBO_ASSEMBLE;
}
Program: 31887
Project: 31887
Buggy source:
/** 
 * get @EvalConfig from @ModelConfig by evalset name
 * @param mconfig
 * @param name
 * @return
 */
private EvalConfig getEvalConfigByName(ModelConfig mconfig,String name){
  for (  EvalConfig evalConfig : mconfig.getEvals()) {
    if (evalConfig.getName().equalsIgnoreCase(name)) {
      return evalConfig;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * get @EvalConfig from @ModelConfig by evalset name
 * @param mconfig model config
 * @param name eval name
 * @return eval config instance
 */
private EvalConfig getEvalConfigByName(ModelConfig mconfig,String name){
  for (  EvalConfig evalConfig : mconfig.getEvals()) {
    if (evalConfig.getName().equalsIgnoreCase(name)) {
      return evalConfig;
    }
  }
  return null;
}
Program: 31888
Project: 31888
Buggy source:
/** 
 * Evaluate the Combo model performance 1. Evaluate all evaluation sets in sub models; 2. Join the evaluation result data for assemble model; 3. Run evaluation for assemble model
 * @return
 * @throws IOException
 */
private int evalComboModels() throws IOException {
}

Fixed version (ground truth):
/** 
 * Evaluate the Combo model performance 1. Evaluate all evaluation sets in sub models; 2. Join the evaluation result data for assemble model; 3. Run evaluation for assemble model
 * @return 0 success, otherwise failed
 * @throws IOException any io exception
 */
private int evalComboModels() throws IOException {
}
Program: 31889
Project: 31889
Buggy source:
/** 
 * Create configuration file for sub-model if the configuration for parent model exists, it will copy that parent configuration firstly and append new content.
 * @param subModelName
 * @param namesPrefix
 * @param parentNamesFile
 * @param varNames
 * @return
 * @throws IOException
 */
private String createModelNamesFile(String subModelName,String namesPrefix,String parentNamesFile,String... varNames) throws IOException {
  String modelNamesCfg=namesPrefix + "String_Node_Str";
  File mnFile=new File(subModelName + File.separator + modelNamesCfg);
  if (StringUtils.isNotBlank(parentNamesFile)) {
    FileUtils.copyFile(new File(parentNamesFile),mnFile);
  }
  FileWriter writer=new FileWriter(mnFile);
  try {
    for (    String var : varNames) {
      writer.append(var + "String_Node_Str");
    }
  }
 catch (  IOException e) {
  }
 finally {
    writer.close();
  }
  return modelNamesCfg;
}

Fixed version (ground truth):
/** 
 * Create configuration file for sub-model if the configuration for parent model exists, it will copy that parent configuration firstly and append new content.
 * @param subModelName sub model name
 * @param namesPrefix prefix of name
 * @param parentNamesFile parent names of files
 * @param varNames var names
 * @return model file name
 * @throws IOException any io exception
 */
private String createModelNamesFile(String subModelName,String namesPrefix,String parentNamesFile,String... varNames) throws IOException {
  String modelNamesCfg=namesPrefix + "String_Node_Str";
  File mnFile=new File(subModelName + File.separator + modelNamesCfg);
  if (StringUtils.isNotBlank(parentNamesFile)) {
    FileUtils.copyFile(new File(parentNamesFile),mnFile);
  }
  FileWriter writer=new FileWriter(mnFile);
  try {
    for (    String var : varNames) {
      writer.append(var + "String_Node_Str");
    }
  }
 catch (  IOException e) {
  }
 finally {
    writer.close();
  }
  return modelNamesCfg;
}
Program: 31891
Project: 31891
Buggy source:
/** 
 * Generate train data evaluation set name
 * @return
 */
private String genEvalTrainName(){
  return Constants.COMBO_EVAL_TRAIN;
}

Fixed version (ground truth):
/** 
 * Generate train data evaluation set name
 * @return eval train name
 */
private String genEvalTrainName(){
  return Constants.COMBO_EVAL_TRAIN;
}
Program: 31892
Project: 31892
Buggy source:
/** 
 * Save ComboTrain.json into local directory
 * @param comboModelTrain
 * @return
 */
private int saveComboTrain(ComboModelTrain comboModelTrain){
  try {
    JSONUtils.writeValue(new File(Constants.COMBO_CONFIG_JSON_FILE_NAME),comboModelTrain);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str");
    return 1;
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * Save ComboTrain.json into local directory
 * @param comboModelTrain combo model train instance
 * @return 0 success, otherwise failed
 */
private int saveComboTrain(ComboModelTrain comboModelTrain){
  try {
    JSONUtils.writeValue(new File(Constants.COMBO_CONFIG_JSON_FILE_NAME),comboModelTrain);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str");
    return 1;
  }
  return 0;
}
Program: 31893
Project: 31893
Buggy source:
/** 
 * run pig post train
 * @throws IOException
 */
@SuppressWarnings("String_Node_Str") private void runPigPostTrain() throws IOException {
  SourceType sourceType=modelConfig.getDataSet().getSource();
  ShifuFileUtils.deleteFile(pathFinder.getTrainScoresPath(),sourceType);
  ShifuFileUtils.deleteFile(pathFinder.getBinAvgScorePath(),sourceType);
  Map<String,String> paramsMap=new HashMap<String,String>();
  paramsMap.put("String_Node_Str",modelConfig.getHeaderPath());
  paramsMap.put("String_Node_Str",CommonUtils.escapePigString(modelConfig.getHeaderDelimiter()));
  paramsMap.put("String_Node_Str",CommonUtils.escapePigString(modelConfig.getDataSetDelimiter()));
  try {
    PigExecutor.getExecutor().submitJob(modelConfig,pathFinder.getScriptPath("String_Node_Str"),paramsMap);
  }
 catch (  IOException e) {
    throw new ShifuException(ShifuErrorCode.ERROR_RUNNING_PIG_JOB,e);
  }
catch (  Throwable e) {
    throw new RuntimeException(e);
  }
  columnConfigList=updateColumnConfigWithBinAvgScore(columnConfigList);
  saveColumnConfigListAndColumnStats(false);
}

Fixed version (ground truth):
/** 
 * run pig post train
 * @throws IOException for any io exception
 */
@SuppressWarnings("String_Node_Str") private void runPigPostTrain() throws IOException {
  SourceType sourceType=modelConfig.getDataSet().getSource();
  ShifuFileUtils.deleteFile(pathFinder.getTrainScoresPath(),sourceType);
  ShifuFileUtils.deleteFile(pathFinder.getBinAvgScorePath(),sourceType);
  Map<String,String> paramsMap=new HashMap<String,String>();
  paramsMap.put("String_Node_Str",modelConfig.getHeaderPath());
  paramsMap.put("String_Node_Str",CommonUtils.escapePigString(modelConfig.getHeaderDelimiter()));
  paramsMap.put("String_Node_Str",CommonUtils.escapePigString(modelConfig.getDataSetDelimiter()));
  try {
    PigExecutor.getExecutor().submitJob(modelConfig,pathFinder.getScriptPath("String_Node_Str"),paramsMap);
  }
 catch (  IOException e) {
    throw new ShifuException(ShifuErrorCode.ERROR_RUNNING_PIG_JOB,e);
  }
catch (  Throwable e) {
    throw new RuntimeException(e);
  }
  columnConfigList=updateColumnConfigWithBinAvgScore(columnConfigList);
  saveColumnConfigListAndColumnStats(false);
}
Program: 31894
Project: 31894
Buggy source:
/** 
 * run akka post train
 * @throws IOException
 */
private void runAkkaPostTrain() throws IOException {
  SourceType sourceType=modelConfig.getDataSet().getSource();
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getSelectedRawDataPath(sourceType),sourceType);
  log.info("String_Node_Str" + scanners.size());
  AkkaSystemExecutor.getExecutor().submitPostTrainJob(modelConfig,columnConfigList,scanners);
  closeScanners(scanners);
}

Fixed version (ground truth):
/** 
 * run akka post train
 * @throws IOException for any io exception
 */
private void runAkkaPostTrain() throws IOException {
  SourceType sourceType=modelConfig.getDataSet().getSource();
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getSelectedRawDataPath(sourceType),sourceType);
  log.info("String_Node_Str" + scanners.size());
  AkkaSystemExecutor.getExecutor().submitPostTrainJob(modelConfig,columnConfigList,scanners);
  closeScanners(scanners);
}
Program: 31895
Project: 31895
Buggy source:
/** 
 * read the binary average score and update them into column list
 * @param columnConfigList
 * @return
 * @throws IOException
 */
private List<ColumnConfig> updateColumnConfigWithBinAvgScore(List<ColumnConfig> columnConfigList) throws IOException {
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getBinAvgScorePath(),modelConfig.getDataSet().getSource());
  for (  Scanner scanner : scanners) {
    while (scanner.hasNextLine()) {
      List<Integer> scores=new ArrayList<Integer>();
      String[] raw=scanner.nextLine().split("String_Node_Str");
      int columnNum=Integer.parseInt(raw[0]);
      for (int i=1; i < raw.length; i++) {
        scores.add(Integer.valueOf(raw[i]));
      }
      ColumnConfig config=columnConfigList.get(columnNum);
      config.setBinAvgScore(scores);
    }
  }
  closeScanners(scanners);
  return columnConfigList;
}

Fixed version (ground truth):
/** 
 * read the binary average score and update them into column list
 * @param columnConfigList input column config list
 * @return updated column config list
 * @throws IOException for any io exception
 */
private List<ColumnConfig> updateColumnConfigWithBinAvgScore(List<ColumnConfig> columnConfigList) throws IOException {
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getBinAvgScorePath(),modelConfig.getDataSet().getSource());
  for (  Scanner scanner : scanners) {
    while (scanner.hasNextLine()) {
      List<Integer> scores=new ArrayList<Integer>();
      String[] raw=scanner.nextLine().split("String_Node_Str");
      int columnNum=Integer.parseInt(raw[0]);
      for (int i=1; i < raw.length; i++) {
        scores.add(Integer.valueOf(raw[i]));
      }
      ColumnConfig config=columnConfigList.get(columnNum);
      config.setBinAvgScore(scores);
    }
  }
  closeScanners(scanners);
  return columnConfigList;
}
Program: 31896
Project: 31896
Buggy source:
@JsonIgnore public List<String> getScoreMetaColumns(ModelConfig modelConfig) throws IOException {
  if (scoreMetaColumns == null) {
synchronized (this) {
      if (scoreMetaColumns == null) {
        PathFinder pathFinder=new PathFinder(modelConfig);
        if (StringUtils.isNotBlank(scoreMetaColumnNameFile) && SourceType.HDFS.equals(dataSet.getSource())) {
          String path=scoreMetaColumnNameFile;
          File file=new File(scoreMetaColumnNameFile);
          path=new Path(pathFinder.getEvalSetPath(this),file.getName()).toString();
          scoreMetaColumns=CommonUtils.readConfFileIntoList(path,dataSet.getSource(),dataSet.getHeaderDelimiter());
        }
      }
    }
  }
  return scoreMetaColumns;
}

Fixed version (ground truth):
@JsonIgnore public List<String> getScoreMetaColumns(ModelConfig modelConfig) throws IOException {
  if (scoreMetaColumns == null) {
synchronized (this) {
      if (scoreMetaColumns == null) {
        PathFinder pathFinder=new PathFinder(modelConfig);
        if (StringUtils.isNotBlank(scoreMetaColumnNameFile) && SourceType.HDFS.equals(dataSet.getSource())) {
          String path=scoreMetaColumnNameFile;
          File file=new File(scoreMetaColumnNameFile);
          path=new Path(pathFinder.getEvalSetPath(this),file.getName()).toString();
          scoreMetaColumns=CommonUtils.readConfFileIntoList(path,dataSet.getSource(),StringUtils.isBlank(dataSet.getHeaderDelimiter()) ? dataSet.getDataDelimiter() : dataSet.getHeaderDelimiter());
        }
      }
    }
  }
  return scoreMetaColumns;
}
Program: 31900
Project: 31900
Buggy source:
/** 
 * Add model(Classification) schema into tuple schema, if the modelCount > 0
 * @param tupleSchema  - schema for Tuple
 * @param modelCount - model count
 * @param modelName - model name
 */
private void addModelTagSchema(Schema tupleSchema,Integer modelCount,String modelName){
  for (int i=0; i < modelCount; i++) {
    for (int j=0; j < modelConfig.getTags().size(); j++) {
      tupleSchema.add(new FieldSchema(SCHEMA_PREFIX + addModelNameToField(modelName,"String_Node_Str" + i + "String_Node_Str"+ j),DataType.INTEGER));
    }
  }
}

Fixed version (ground truth):
/** 
 * Add model(Classification) schema into tuple schema, if the modelCount > 0
 * @param tupleSchema - schema for Tuple
 * @param modelCount - model count
 * @param modelName - model name
 */
private void addModelTagSchema(Schema tupleSchema,Integer modelCount,String modelName){
  for (int i=0; i < modelCount; i++) {
    for (int j=0; j < modelConfig.getTags().size(); j++) {
      tupleSchema.add(new FieldSchema(SCHEMA_PREFIX + addModelNameToField(modelName,"String_Node_Str" + i + "String_Node_Str"+ j),DataType.INTEGER));
    }
  }
}
Program: 31903
Project: 31903
Buggy source:
public List<Integer> submitTasksAndRetryIfFail(List<Callable<Integer>> tasks,int maxRetryTimes){
  List<Integer> results=new ArrayList<Integer>(tasks.size());
  int[] taskLeftTryTimes=new int[tasks.size()];
  Arrays.fill(taskLeftTryTimes,maxRetryTimes);
  List<TaskFuture> taskFutures=new ArrayList<TaskFuture>();
  for (int i=0; i < tasks.size(); i++) {
    Callable<Integer> task=tasks.get(i);
    Future<Integer> future=executorService.submit(task);
    taskFutures.add(new TaskFuture(i,future));
  }
  int size=taskFutures.size();
  int i=0;
  while (i < size) {
    TaskFuture tf=taskFutures.get(i);
    try {
      Integer res=tf.getFuture().get();
      if (res == null || res != 0) {
        if (!retryTask(tf,tasks,taskFutures,taskLeftTryTimes,maxRetryTimes)) {
          results.set(tf.getTaskId(),res);
        }
      }
 else {
        results.set(tf.getTaskId(),res);
      }
    }
 catch (    InterruptedException e) {
    }
catch (    ExecutionException e) {
      if (!retryTask(tf,tasks,taskFutures,taskLeftTryTimes,maxRetryTimes)) {
        results.set(tf.getTaskId(),1);
      }
    }
    i++;
    size=taskFutures.size();
  }
  return results;
}

Fixed version (ground truth):
public List<Integer> submitTasksAndRetryIfFail(List<Callable<Integer>> tasks,int maxRetryTimes){
  List<Integer> results=new ArrayList<Integer>(tasks.size());
  int[] taskLeftTryTimes=new int[tasks.size()];
  Arrays.fill(taskLeftTryTimes,maxRetryTimes);
  List<TaskFuture> taskFutures=new ArrayList<TaskFuture>();
  for (int i=0; i < tasks.size(); i++) {
    Callable<Integer> task=tasks.get(i);
    Future<Integer> future=executorService.submit(task);
    taskFutures.add(new TaskFuture(i,future));
    results.add(null);
  }
  int size=taskFutures.size();
  int i=0;
  while (i < size) {
    TaskFuture tf=taskFutures.get(i);
    try {
      Integer res=tf.getFuture().get();
      if (res == null || res != 0) {
        if (!retryTask(tf,tasks,taskFutures,taskLeftTryTimes,maxRetryTimes)) {
          results.set(tf.getTaskId(),res);
        }
      }
 else {
        results.set(tf.getTaskId(),res);
      }
    }
 catch (    InterruptedException e) {
    }
catch (    ExecutionException e) {
      if (!retryTask(tf,tasks,taskFutures,taskLeftTryTimes,maxRetryTimes)) {
        results.set(tf.getTaskId(),1);
      }
    }
    i++;
    size=taskFutures.size();
  }
  return results;
}
Program: 31905
Project: 31905
Buggy source:
/** 
 * Get buffered reader with <code>  {@link Constants#DEFAULT_CHARSET}</code> for specified file <p/> !!! Warning: reader instance should be closed by caller.
 * @param path - file path
 * @param sourceType - local/hdfs
 * @throws IOException - if any I/O exception in processing
 * @return buffered reader with <code>{@link Constants#DEFAULT_CHARSET}</code>
 */
public static BufferedReader getReader(String path,SourceType sourceType) throws IOException {
  try {
    return new BufferedReader(new InputStreamReader(getFileSystemBySourceType(sourceType).open(new Path(path)),Constants.DEFAULT_CHARSET));
  }
 catch (  IOException e) {
    if (e.getMessage() != null) {
      if (e.getMessage().toLowerCase().indexOf("String_Node_Str") >= 0) {
        if (sourceType == SourceType.HDFS) {
          return new BufferedReader(new InputStreamReader(HDFSUtils.renewFS().open(new Path(path)),Constants.DEFAULT_CHARSET));
        }
      }
    }
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Get buffered reader with <code>  {@link Constants#DEFAULT_CHARSET}</code> for specified file <p/> !!! Warning: reader instance should be closed by caller.
 * @param path - file path
 * @param sourceType - local/hdfs
 * @throws IOException - if any I/O exception in processing
 * @return buffered reader with <code>{@link Constants#DEFAULT_CHARSET}</code>
 */
public static BufferedReader getReader(String path,SourceType sourceType) throws IOException {
  try {
    return new BufferedReader(new InputStreamReader(getCompressInputStream(getFileSystemBySourceType(sourceType).open(new Path(path)),new Path(path)),Constants.DEFAULT_CHARSET));
  }
 catch (  IOException e) {
    if (e.getMessage() != null) {
      if (e.getMessage().toLowerCase().indexOf("String_Node_Str") >= 0) {
        if (sourceType == SourceType.HDFS) {
          return new BufferedReader(new InputStreamReader(HDFSUtils.renewFS().open(new Path(path)),Constants.DEFAULT_CHARSET));
        }
      }
    }
    throw e;
  }
}
Program: 31909
Project: 31909
Buggy source:
public PMML build(BasicML basicML){
  PMML pmml=new PMML();
  Header header=new Header();
  pmml.setHeader(header);
  header.setCopyright("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  Application application=new Application();
  header.setApplication(application);
  application.setName("String_Node_Str");
  String findContainingJar=JarManager.findContainingJar(TreeEnsemblePMMLTranslator.class);
  JarFile jar=null;
  try {
    jar=new JarFile(findContainingJar);
    final Manifest manifest=jar.getManifest();
    String vendor=manifest.getMainAttributes().getValue("String_Node_Str");
    String version=manifest.getMainAttributes().getValue("String_Node_Str");
    application.setVersion(version);
  }
 catch (  Exception e) {
    LOG.warn(e.getMessage());
  }
 finally {
    if (jar != null) {
      try {
        jar.close();
      }
 catch (      IOException e) {
        LOG.warn(e.getMessage());
      }
    }
  }
  pmml.setDataDictionary(this.dataDictionaryCreator.build());
  Model model=this.modelCreator.build();
  model.setMiningSchema(this.miningSchemaCreator.build());
  model.setModelStats(this.modelStatsCreator.build());
  model.setLocalTransformations(this.localTransformationsCreator.build());
  this.specifCreator.build(basicML,model);
  pmml.withModels(model);
  return pmml;
}

Fixed version (ground truth):
public PMML build(BasicML basicML){
  PMML pmml=new PMML();
  Header header=new Header();
  pmml.setHeader(header);
  header.setCopyright("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  Application application=new Application();
  header.setApplication(application);
  application.setName("String_Node_Str");
  String findContainingJar=JarManager.findContainingJar(TreeEnsemblePMMLTranslator.class);
  JarFile jar=null;
  try {
    jar=new JarFile(findContainingJar);
    final Manifest manifest=jar.getManifest();
    String version=manifest.getMainAttributes().getValue("String_Node_Str");
    application.setVersion(version);
  }
 catch (  Exception e) {
    LOG.warn(e.getMessage());
  }
 finally {
    if (jar != null) {
      try {
        jar.close();
      }
 catch (      IOException e) {
        LOG.warn(e.getMessage());
      }
    }
  }
  pmml.setDataDictionary(this.dataDictionaryCreator.build());
  Model model=this.modelCreator.build();
  model.setMiningSchema(this.miningSchemaCreator.build());
  model.setModelStats(this.modelStatsCreator.build());
  model.setLocalTransformations(this.localTransformationsCreator.build());
  this.specifCreator.build(basicML,model);
  pmml.withModels(model);
  return pmml;
}
Program: 31911
Project: 31911
Buggy source:
private List<Integer> sampleFeaturesForNodeStats(List<Integer> allFeatures,int sample){
  List<Integer> features=new ArrayList<Integer>(sample);
  for (int i=0; i < sample; i++) {
    features.add(allFeatures.get(i));
  }
  Random random=new Random();
  for (int i=sample; i < allFeatures.size(); i++) {
    int replacementIndex=(int)(random.nextDouble() * i);
    if (replacementIndex >= 0 && replacementIndex < sample) {
      features.set(replacementIndex,allFeatures.get(i));
    }
  }
  return features;
}

Fixed version (ground truth):
private List<Integer> sampleFeaturesForNodeStats(List<Integer> allFeatures,int sample){
  List<Integer> features=new ArrayList<Integer>(sample);
  for (int i=0; i < sample; i++) {
    features.add(allFeatures.get(i));
  }
  for (int i=sample; i < allFeatures.size(); i++) {
    int replacementIndex=(int)(featureSamplingRandom.nextDouble() * i);
    if (replacementIndex >= 0 && replacementIndex < sample) {
      features.set(replacementIndex,allFeatures.get(i));
    }
  }
  return features;
}
Program: 31912
Project: 31912
Buggy source:
private long getStatsMem(List<Integer> subsetFeatures){
  long statsMem=0L;
  List<Integer> tempFeatures=subsetFeatures;
  if (subsetFeatures.size() == 0) {
    tempFeatures=getAllValidFeatures();
  }
  for (  Integer columnNum : tempFeatures) {
    ColumnConfig config=this.columnConfigList.get(columnNum);
    if (config.isNumerical()) {
      statsMem+=config.getBinBoundary().size() * this.impurity.getStatsSize() * 8L* 2;
    }
 else     if (config.isCategorical()) {
      statsMem+=(config.getBinCategory().size() + 1) * this.impurity.getStatsSize() * 8L* 2;
    }
  }
  statsMem=statsMem * this.workerNumber / 2;
  return statsMem;
}

Fixed version (ground truth):
private long getStatsMem(List<Integer> subsetFeatures){
  long statsMem=0L;
  List<Integer> tempFeatures=subsetFeatures;
  if (subsetFeatures.size() == 0) {
    tempFeatures=getAllFeatureList(this.columnConfigList,this.isAfterVarSelect);
  }
  for (  Integer columnNum : tempFeatures) {
    ColumnConfig config=this.columnConfigList.get(columnNum);
    if (config.isNumerical()) {
      statsMem+=config.getBinBoundary().size() * this.impurity.getStatsSize() * 8L* 2;
    }
 else     if (config.isCategorical()) {
      statsMem+=(config.getBinCategory().size() + 1) * this.impurity.getStatsSize() * 8L* 2;
    }
  }
  statsMem=statsMem * this.workerNumber / 2;
  return statsMem;
}
Program: 31913
Project: 31913
Buggy source:
/** 
 * 'binBoundary' is ArrayList in fact, so we can use get method. ["-Infinity", 1d, 4d, ....]
 */
public static int getBinIndex(float value,List<Double> binBoundary){
  if (binBoundary.size() <= 1) {
    throw new IllegalArgumentException();
  }
  if (value == Float.POSITIVE_INFINITY) {
    return binBoundary.size() - 1;
  }
  if (value == Float.NEGATIVE_INFINITY) {
    return 0;
  }
  int low=0, high=binBoundary.size() - 1;
  while (low <= high) {
    int mid=(low + high) >>> 1;
    double lowThreshold=binBoundary.get(mid);
    double highThreshold=mid == binBoundary.size() - 1 ? Double.MAX_VALUE : binBoundary.get(mid + 1);
    if (value >= lowThreshold && value < highThreshold) {
      return mid;
    }
    if (value >= highThreshold) {
      low=mid + 1;
    }
 else {
      high=mid - 1;
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * 'binBoundary' is ArrayList in fact, so we can use get method. ["-Infinity", 1d, 4d, ....]
 */
public static int getBinIndex(float value,List<Double> binBoundary){
  if (binBoundary.size() <= 1) {
    return 0;
  }
  if (value == Float.POSITIVE_INFINITY) {
    return binBoundary.size() - 1;
  }
  if (value == Float.NEGATIVE_INFINITY) {
    return 0;
  }
  int low=0, high=binBoundary.size() - 1;
  while (low <= high) {
    int mid=(low + high) >>> 1;
    double lowThreshold=binBoundary.get(mid);
    double highThreshold=mid == binBoundary.size() - 1 ? Double.MAX_VALUE : binBoundary.get(mid + 1);
    if (value >= lowThreshold && value < highThreshold) {
      return mid;
    }
    if (value >= highThreshold) {
      low=mid + 1;
    }
 else {
      high=mid - 1;
    }
  }
  return -1;
}
Program: 31916
Project: 31916
Buggy source:
private void prepareSelect() throws Exception {
  setUp(ModelStep.VARSELECT);
  validateParameters();
  if (isToReset) {
    log.info("String_Node_Str");
    resetAllFinalSelect();
  }
  if (this.modelConfig.getVarSelectFilterNum() > 0) {
    for (    ColumnConfig columnConfig : this.columnConfigList) {
      if (columnConfig.isFinalSelect()) {
        columnConfig.setFinalSelect(false);
      }
    }
  }
  syncDataToHdfs(super.modelConfig.getDataSet().getSource());
}

Fixed version (ground truth):
private void prepareSelect() throws Exception {
  setUp(ModelStep.VARSELECT);
  validateParameters();
  if (isToReset) {
    log.info("String_Node_Str");
    resetAllFinalSelect();
  }
  syncDataToHdfs(super.modelConfig.getDataSet().getSource());
}