Program: 108963
Project: 108963
Buggy source:
private void analyze(){
  if (model == null) {
    return;
  }
  final long time=System.currentTimeMillis();
  ModelConfiguration config=model.getOutputConfig();
  if (config == null) {
    config=model.getInputConfig();
  }
  DataHandle data;
  if (target == ModelPart.INPUT) {
    data=config.getInput().getHandle();
  }
 else {
    data=model.getOutput();
  }
  if ((config == null) || (data == null)) {
    reset();
    return;
  }
  if (data != null && model.getViewConfig().isSubset()) {
    data=data.getView();
  }
  final int index=data.getColumnIndexOf(attribute);
  if (index == -1) {
    clearCache();
    reset();
    return;
  }
  if (cache.containsKey(attribute)) {
    return;
  }
  final AttributeType type=config.getInput().getDefinition().getAttributeType(attribute);
  Hierarchy hierarchy=null;
  if (type instanceof Hierarchy) {
    hierarchy=(Hierarchy)type;
  }
 else   if (type == AttributeType.SENSITIVE_ATTRIBUTE) {
    hierarchy=config.getHierarchy(attribute);
  }
  boolean suppressed=false;
  final Map<String,Double> map=new HashMap<String,Double>();
  for (int i=0; i < data.getNumRows(); i++) {
    if (!suppressed) {
      suppressed|=data.isOutlier(i);
    }
    final String val=data.getValue(i,index);
    if (!map.containsKey(val)) {
      map.put(val,1d);
    }
 else {
      map.put(val,map.get(val) + 1);
    }
  }
  final String[] dvals;
  if (hierarchy != null) {
    final int level=data.getGeneralization(attribute);
    final List<String> list=new ArrayList<String>();
    final Set<String> done=new HashSet<String>();
    final String[][] h=hierarchy.getHierarchy();
    for (int i=0; i < h.length; i++) {
      final String val=h[i][level];
      if (map.containsKey(val) || ((model.getAnonymizer() != null) && val.equals(model.getAnonymizer().getSuppressionString()))) {
        if (!done.contains(val)) {
          list.add(val);
          done.add(val);
        }
      }
    }
    if (suppressed) {
      if (!done.contains(model.getAnonymizer().getSuppressionString())) {
        list.add(model.getAnonymizer().getSuppressionString());
        if (!map.containsKey(list.add(model.getAnonymizer().getSuppressionString()))) {
          map.put(model.getAnonymizer().getSuppressionString(),0d);
        }
      }
    }
    dvals=list.toArray(new String[]{});
  }
 else {
    final DataType<?> dtype=data.getDataType(attribute);
    final String[] v=new String[map.size()];
    int i=0;
    for (    final String s : map.keySet()) {
      v[i++]=s;
    }
    Arrays.sort(v,new Comparator<String>(){
      @Override public int compare(      final String arg0,      final String arg1){
        try {
          return dtype.compare(arg0,arg1);
        }
 catch (        final Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
);
    dvals=v;
  }
  double sum=0;
  for (  final double i : map.values()) {
    sum+=i;
  }
  int step=map.size() / MAX_DIMENSION;
  step=Math.max(step,1);
  final int length=(int)Math.ceil((double)map.size() / (double)step);
  controller.getResources().getLogger().info("String_Node_Str" + length + "String_Node_Str"+ step+ "String_Node_Str"+ dvals.length+ "String_Node_Str"+ MAX_DIMENSION);
  int sindex=0;
  final double[] distribution=new double[length];
  for (int i=0; i < dvals.length; i+=step) {
    for (int j=0; j < step; j++) {
      if (sindex < distribution.length) {
        if ((i + j) < dvals.length) {
          distribution[sindex]+=map.get(dvals[i + j]) / sum;
        }
      }
 else {
        controller.getResources().getLogger().warn("String_Node_Str");
      }
    }
    sindex++;
  }
  cache.put(attribute,distribution);
  controller.getResources().getLogger().info("String_Node_Str" + (System.currentTimeMillis() - time));
}

Fixed version (ground truth):
private void analyze(){
  if (model == null) {
    return;
  }
  ModelConfiguration config=model.getOutputConfig();
  if (config == null) {
    config=model.getInputConfig();
  }
  DataHandle data;
  if (target == ModelPart.INPUT) {
    data=config.getInput().getHandle();
  }
 else {
    data=model.getOutput();
  }
  if ((config == null) || (data == null)) {
    reset();
    return;
  }
  if (data != null && model.getViewConfig().isSubset()) {
    data=data.getView();
  }
  final int index=data.getColumnIndexOf(attribute);
  if (index == -1) {
    clearCache();
    reset();
    return;
  }
  if (cache.containsKey(attribute)) {
    return;
  }
  final AttributeType type=config.getInput().getDefinition().getAttributeType(attribute);
  Hierarchy hierarchy=null;
  if (type instanceof Hierarchy) {
    hierarchy=(Hierarchy)type;
  }
 else   if (type == AttributeType.SENSITIVE_ATTRIBUTE) {
    hierarchy=config.getHierarchy(attribute);
  }
  final Map<String,Double> map=new HashMap<String,Double>();
  for (int i=0; i < data.getNumRows(); i++) {
    final String val=data.getValue(i,index);
    if (!map.containsKey(val)) {
      map.put(val,1d);
    }
 else {
      map.put(val,map.get(val) + 1);
    }
  }
  final String[] dvals;
  if (hierarchy != null) {
    final int level=data.getGeneralization(attribute);
    final List<String> list=new ArrayList<String>();
    final Set<String> done=new HashSet<String>();
    final String[][] h=hierarchy.getHierarchy();
    for (int i=0; i < h.length; i++) {
      final String val=h[i][level];
      if (map.containsKey(val)) {
        if (!done.contains(val)) {
          list.add(val);
          done.add(val);
        }
      }
    }
    if (model.getAnonymizer() != null && map.containsKey(model.getAnonymizer().getSuppressionString()) && !done.contains(model.getAnonymizer().getSuppressionString())) {
      list.add(model.getAnonymizer().getSuppressionString());
    }
    dvals=list.toArray(new String[]{});
  }
 else {
    final DataType<?> dtype=data.getDataType(attribute);
    final String[] v=new String[map.size()];
    int i=0;
    for (    final String s : map.keySet()) {
      v[i++]=s;
    }
    Arrays.sort(v,new Comparator<String>(){
      @Override public int compare(      final String arg0,      final String arg1){
        try {
          return dtype.compare(arg0,arg1);
        }
 catch (        final Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
);
    dvals=v;
  }
  double sum=0;
  for (  final double i : map.values()) {
    sum+=i;
  }
  final double[] distribution=new double[map.size()];
  for (int i=0; i < dvals.length; i++) {
    distribution[i]=map.get(dvals[i]) / sum;
  }
  cache.put(attribute,distribution);
}