Program: 7962
Project: 7962
Buggy source:
/** 
 * Result has (row, column, version, kvtype, id, value)
 * @throws SQLException
 */
private Map<byte[],Map<byte[],byte[]>> filteredLatestColumnsWithKey(ResultSet result,ReadPointer readPointer,int limit) throws SQLException {
  if (limit <= 0) {
    limit=Integer.MAX_VALUE;
  }
  Map<byte[],Map<byte[],byte[]>> map=new TreeMap<byte[],Map<byte[],byte[]>>(Bytes.BYTES_COMPARATOR);
  if (result == null) {
    return map;
  }
  boolean newRow=true;
  byte[] lastRow=new byte[0];
  byte[] curCol=new byte[0];
  byte[] lastCol=new byte[0];
  long lastDelete=-1;
  long undeleted=-1;
  while (result.next()) {
    byte[] rowKey=result.getBytes(1);
    if (!Bytes.equals(lastRow,rowKey)) {
      newRow=true;
      lastRow=rowKey;
    }
    long curVersion=result.getLong(3);
    if (!readPointer.isVisible(curVersion)) {
      continue;
    }
    byte[] column=result.getBytes(2);
    if (!newRow && Bytes.equals(lastCol,column)) {
      continue;
    }
    if (newRow || !Bytes.equals(curCol,column)) {
      curCol=column;
      lastDelete=-1;
      undeleted=-1;
    }
    Type type=Type.from(result.getInt(4));
    if (type.isUndeleteAll()) {
      undeleted=curVersion;
      continue;
    }
    if (type.isDeleteAll()) {
      if (undeleted == curVersion) {
        continue;
      }
 else {
        lastCol=column;
        continue;
      }
    }
    if (type.isDelete()) {
      lastDelete=curVersion;
      continue;
    }
    if (curVersion == lastDelete) {
      continue;
    }
    lastCol=column;
    Map<byte[],byte[]> colMap=map.get(rowKey);
    if (colMap == null) {
      colMap=new TreeMap<byte[],byte[]>(Bytes.BYTES_COMPARATOR);
      map.put(rowKey,colMap);
    }
    colMap.put(column,result.getBytes(6));
    if (map.size() >= limit)     break;
  }
  return map;
}

Fixed version (ground truth):
/** 
 * Result has (row, column, version, kvtype, id, value).
 * @throws SQLException
 */
private Map<byte[],Map<byte[],byte[]>> filteredLatestColumnsWithKey(ResultSet result,ReadPointer readPointer,int limit) throws SQLException {
  if (limit <= 0) {
    limit=Integer.MAX_VALUE;
  }
  Map<byte[],Map<byte[],byte[]>> map=new TreeMap<byte[],Map<byte[],byte[]>>(Bytes.BYTES_COMPARATOR);
  if (result == null) {
    return map;
  }
  boolean newRow=true;
  byte[] lastRow=new byte[0];
  byte[] curCol=new byte[0];
  byte[] lastCol=new byte[0];
  long lastDelete=-1;
  long undeleted=-1;
  while (result.next()) {
    byte[] rowKey=result.getBytes(1);
    if (!Bytes.equals(lastRow,rowKey)) {
      newRow=true;
      lastRow=rowKey;
    }
    long curVersion=result.getLong(3);
    if (!readPointer.isVisible(curVersion)) {
      continue;
    }
    byte[] column=result.getBytes(2);
    if (!newRow && Bytes.equals(lastCol,column)) {
      continue;
    }
    if (newRow || !Bytes.equals(curCol,column)) {
      curCol=column;
      lastDelete=-1;
      undeleted=-1;
    }
    Type type=Type.from(result.getInt(4));
    if (type.isUndeleteAll()) {
      undeleted=curVersion;
      continue;
    }
    if (type.isDeleteAll()) {
      if (undeleted == curVersion) {
        continue;
      }
 else {
        lastCol=column;
        continue;
      }
    }
    if (type.isDelete()) {
      lastDelete=curVersion;
      continue;
    }
    if (curVersion == lastDelete) {
      continue;
    }
    lastCol=column;
    Map<byte[],byte[]> colMap=map.get(rowKey);
    if (colMap == null) {
      colMap=new TreeMap<byte[],byte[]>(Bytes.BYTES_COMPARATOR);
      map.put(rowKey,colMap);
    }
    colMap.put(column,result.getBytes(6));
    if (map.size() >= limit) {
      break;
    }
  }
  return map;
}