Program: 32072
Project: 32072
Buggy source:
@Override public DTWorkerParams doCompute(WorkerContext<DTMasterParams,DTWorkerParams> context){
  if (context.isFirstIteration()) {
    return new DTWorkerParams();
  }
  DTMasterParams lastMasterResult=context.getLastMasterResult();
  List<TreeNode> trees=lastMasterResult.getTrees();
  Map<Integer,TreeNode> todoNodes=lastMasterResult.getTodoNodes();
  Map<Integer,NodeStats> statistics=new HashMap<Integer,NodeStats>(todoNodes.size(),1f);
  for (  Map.Entry<Integer,TreeNode> entry : todoNodes.entrySet()) {
    List<Integer> features=entry.getValue().getFeatures();
    if (features.isEmpty()) {
      features=getAllValidFeatures();
    }
    Map<Integer,double[]> featureStatistics=new HashMap<Integer,double[]>(features.size(),1f);
    for (    Integer columnNum : features) {
      ColumnConfig columnConfig=this.columnConfigList.get(columnNum);
      if (columnConfig.isNumerical()) {
        int featureStatsSize=columnConfig.getBinBoundary().size() * this.impurity.getStatsSize();
        featureStatistics.put(columnNum,new double[featureStatsSize]);
      }
 else       if (columnConfig.isCategorical()) {
        int featureStatsSize=(columnConfig.getBinCategory().size() + 1) * this.impurity.getStatsSize();
        featureStatistics.put(columnNum,new double[featureStatsSize]);
      }
    }
    statistics.put(entry.getKey(),new NodeStats(entry.getValue().getTreeId(),entry.getValue().getNode().getId(),featureStatistics));
  }
  this.trainingData.reOpen();
  double squareError=0d;
  for (  Data data : this.trainingData) {
    List<Integer> nodeIndexes=new ArrayList<Integer>(trees.size());
    if (this.isRF) {
      for (      TreeNode treeNode : trees) {
        Node predictNode=predictNodeIndex(treeNode.getNode(),data);
        if (predictNode.getPredict() != null) {
          double error=data.output - predictNode.getPredict().getPredict();
          squareError+=error * error;
        }
        int predictNodeIndex=predictNode.getId();
        nodeIndexes.add(predictNodeIndex);
      }
    }
    if (this.isGBDT) {
      if (lastMasterResult.isSwitchToNextTree()) {
        int currTreeIndex=trees.size() - 1;
        if (currTreeIndex >= 1) {
          double predict=predictNodeIndex(trees.get(currTreeIndex - 1).getNode(),data).getPredict().getPredict();
          if (currTreeIndex == 1) {
            data.predict=1.0f * ((float)predict);
          }
 else {
            data.predict=data.predict + (float)(this.learningRate * predict);
          }
          data.output=-loss.computeGradient(data.predict,data.output);
        }
      }
      Node predictNode=predictNodeIndex(trees.get(trees.size() - 1).getNode(),data);
      if (predictNode.getPredict() != null) {
        double error=data.output - predictNode.getPredict().getPredict();
        squareError+=error * error;
      }
      int predictNodeIndex=predictNode.getId();
      nodeIndexes.add(predictNodeIndex);
    }
    for (    Map.Entry<Integer,TreeNode> entry : todoNodes.entrySet()) {
      Node todoNode=entry.getValue().getNode();
      int treeId=entry.getValue().getTreeId();
      int currPredictIndex=0;
      if (this.isRF) {
        currPredictIndex=nodeIndexes.get(entry.getValue().getTreeId());
      }
      if (this.isGBDT) {
        currPredictIndex=nodeIndexes.get(0);
      }
      if (todoNode.getId() == currPredictIndex) {
        List<Integer> features=entry.getValue().getFeatures();
        if (features.isEmpty()) {
          features=getAllValidFeatures();
        }
        for (        Integer columnNum : features) {
          ColumnConfig config=this.columnConfigList.get(columnNum);
          double[] featuerStatistic=statistics.get(entry.getKey()).getFeatureStatistics().get(columnNum);
          float weight=data.subsampleWeights[treeId];
          if (config.isNumerical()) {
            float value=data.numericInputs[this.numericInputIndexMap.get(columnNum)];
            int binIndex=getBinIndex(value,config.getBinBoundary());
            this.impurity.featureUpdate(featuerStatistic,binIndex,data.output,data.significance,weight);
          }
 else           if (config.isCategorical()) {
            String category=data.categoricalInputs[this.categoricalInputIndexMap.get(columnNum)];
            Integer binIndex=this.categoryIndexMap.get(columnNum).get(category);
            this.impurity.featureUpdate(featuerStatistic,binIndex,data.output,data.significance,weight);
          }
 else {
            throw new IllegalStateException("String_Node_Str");
          }
        }
      }
    }
  }
  for (  Map.Entry<Integer,NodeStats> entry : statistics.entrySet()) {
    NodeStats nodeStats=entry.getValue();
    LOG.info("String_Node_Str",entry.getKey(),nodeStats.getNodeId(),nodeStats.getTreeId());
    Map<Integer,double[]> featureStatistics=nodeStats.getFeatureStatistics();
    for (    Entry<Integer,double[]> feaEntry : featureStatistics.entrySet()) {
      LOG.info("String_Node_Str",feaEntry.getKey(),Arrays.toString(feaEntry.getValue()));
    }
  }
  LOG.debug("String_Node_Str",statistics);
  return new DTWorkerParams(count,squareError,statistics);
}

Fixed version (ground truth):
@Override public DTWorkerParams doCompute(WorkerContext<DTMasterParams,DTWorkerParams> context){
  if (context.isFirstIteration()) {
    return new DTWorkerParams();
  }
  DTMasterParams lastMasterResult=context.getLastMasterResult();
  List<TreeNode> trees=lastMasterResult.getTrees();
  Map<Integer,TreeNode> todoNodes=lastMasterResult.getTodoNodes();
  Map<Integer,NodeStats> statistics=new HashMap<Integer,NodeStats>(todoNodes.size(),1f);
  for (  Map.Entry<Integer,TreeNode> entry : todoNodes.entrySet()) {
    List<Integer> features=entry.getValue().getFeatures();
    if (features.isEmpty()) {
      features=getAllValidFeatures();
    }
    Map<Integer,double[]> featureStatistics=new HashMap<Integer,double[]>(features.size(),1f);
    for (    Integer columnNum : features) {
      ColumnConfig columnConfig=this.columnConfigList.get(columnNum);
      if (columnConfig.isNumerical()) {
        int featureStatsSize=columnConfig.getBinBoundary().size() * this.impurity.getStatsSize();
        featureStatistics.put(columnNum,new double[featureStatsSize]);
      }
 else       if (columnConfig.isCategorical()) {
        int featureStatsSize=(columnConfig.getBinCategory().size() + 1) * this.impurity.getStatsSize();
        featureStatistics.put(columnNum,new double[featureStatsSize]);
      }
    }
    statistics.put(entry.getKey(),new NodeStats(entry.getValue().getTreeId(),entry.getValue().getNode().getId(),featureStatistics));
  }
  this.trainingData.reOpen();
  double squareError=0d;
  for (  Data data : this.trainingData) {
    List<Integer> nodeIndexes=new ArrayList<Integer>(trees.size());
    if (this.isRF) {
      for (      TreeNode treeNode : trees) {
        Node predictNode=predictNodeIndex(treeNode.getNode(),data);
        if (predictNode.getPredict() != null) {
          double error=data.output - predictNode.getPredict().getPredict();
          squareError+=error * error;
        }
        int predictNodeIndex=predictNode.getId();
        nodeIndexes.add(predictNodeIndex);
      }
    }
    if (this.isGBDT) {
      if (lastMasterResult.isSwitchToNextTree()) {
        int currTreeIndex=trees.size() - 1;
        if (currTreeIndex >= 1) {
          double predict=predictNodeIndex(trees.get(currTreeIndex - 1).getNode(),data).getPredict().getPredict();
          if (currTreeIndex == 1) {
            data.predict=1.0f * ((float)predict);
          }
 else {
            data.predict=data.predict + (float)(this.learningRate * predict);
          }
          data.output=-loss.computeGradient(data.predict,data.output);
        }
      }
      Node predictNode=predictNodeIndex(trees.get(trees.size() - 1).getNode(),data);
      int predictNodeIndex=predictNode.getId();
      nodeIndexes.add(predictNodeIndex);
      squareError+=loss.computeError(data.predict,data.output);
    }
    for (    Map.Entry<Integer,TreeNode> entry : todoNodes.entrySet()) {
      Node todoNode=entry.getValue().getNode();
      int treeId=entry.getValue().getTreeId();
      int currPredictIndex=0;
      if (this.isRF) {
        currPredictIndex=nodeIndexes.get(entry.getValue().getTreeId());
      }
      if (this.isGBDT) {
        currPredictIndex=nodeIndexes.get(0);
      }
      if (todoNode.getId() == currPredictIndex) {
        List<Integer> features=entry.getValue().getFeatures();
        if (features.isEmpty()) {
          features=getAllValidFeatures();
        }
        for (        Integer columnNum : features) {
          ColumnConfig config=this.columnConfigList.get(columnNum);
          double[] featuerStatistic=statistics.get(entry.getKey()).getFeatureStatistics().get(columnNum);
          float weight=data.subsampleWeights[treeId];
          if (config.isNumerical()) {
            float value=data.numericInputs[this.numericInputIndexMap.get(columnNum)];
            int binIndex=getBinIndex(value,config.getBinBoundary());
            this.impurity.featureUpdate(featuerStatistic,binIndex,data.output,data.significance,weight);
          }
 else           if (config.isCategorical()) {
            String category=data.categoricalInputs[this.categoricalInputIndexMap.get(columnNum)];
            Integer binIndex=this.categoryIndexMap.get(columnNum).get(category);
            this.impurity.featureUpdate(featuerStatistic,binIndex,data.output,data.significance,weight);
          }
 else {
            throw new IllegalStateException("String_Node_Str");
          }
        }
      }
    }
  }
  for (  Map.Entry<Integer,NodeStats> entry : statistics.entrySet()) {
    NodeStats nodeStats=entry.getValue();
    LOG.info("String_Node_Str",entry.getKey(),nodeStats.getNodeId(),nodeStats.getTreeId());
    Map<Integer,double[]> featureStatistics=nodeStats.getFeatureStatistics();
    for (    Entry<Integer,double[]> feaEntry : featureStatistics.entrySet()) {
      LOG.info("String_Node_Str",feaEntry.getKey(),Arrays.toString(feaEntry.getValue()));
    }
  }
  LOG.debug("String_Node_Str",statistics);
  return new DTWorkerParams(count,squareError,statistics);
}