Program: 33487
Project: 33487
Buggy source:
@Override public List<Row> process(final ResultMapper resultMapper,final ColumnFamilyStore table,RowIndex currentIndex) throws Exception {
  Set<String> automatonFields=new HashSet<>();
  for (int i=0; i < states.length; i++) {
    automatonFields.add(states[i].getAutomatonField());
  }
  final Map<String,Integer> positions=aggregateFunction.getPositions();
  int position=positions.size();
  for (  String field : automatonFields) {
    aggregateFunction.getPositions().put(field,position++);
  }
  aggregateFunction.getPositions().put(MATCH_ID,position++);
  aggregateFunction.getPositions().put(PATTERN_ID,position++);
  final boolean[] allExpressions=new boolean[positions.size()];
  boolean[] afExpressions=aggregateFunction.getSimpleExpressions();
  for (int i=0; i < afExpressions.length; i++) {
    allExpressions[i]=afExpressions[i];
  }
  for (int i=afExpressions.length - 1; i < allExpressions.length; i++) {
    allExpressions[i]=true;
  }
  aggregateFunction.simpleExpressions=allExpressions;
  TreeMultimap<ByteBuffer,IndexEntryCollector.IndexEntry> docs=resultMapper.collector.docsByRowKey(table.metadata.getKeyValidator());
  NavigableSet<ByteBuffer> rowKeys=docs.keySet();
  List<Tuple> allMatches=new ArrayList<>();
  for (  ByteBuffer rowKey : rowKeys) {
    final DecoratedKey dk=table.partitioner.decorateKey(rowKey);
    ArrayList<IndexEntryCollector.IndexEntry> entries=new ArrayList<>(docs.get(rowKey));
    final ColumnFamily fullSlice=resultMapper.fetchRangeSlice(entries,dk);
    List<Tuple> tuples=Lists.transform(entries,new com.google.common.base.Function<IndexEntryCollector.IndexEntry,Tuple>(){
      @Override public Tuple apply(      IndexEntryCollector.IndexEntry input){
        CellName cellName=resultMapper.clusteringKey(input.primaryKey);
        ColumnFamily cf=resultMapper.fetchSingleRow(dk,fullSlice,cellName);
        Tuple tuple=aggregateFunction.createTuple(options);
        resultMapper.tableMapper.load(positions,tuple,new Row(dk,cf));
        return tuple;
      }
    }
);
    ListIterator<Tuple> iter=tuples.listIterator();
    allMatches.addAll(matchPartition(maxMatches,iter));
  }
  for (  Tuple match : allMatches) {
    aggregateFunction.getGroup().addTuple(match);
  }
  Row row=resultMapper.tableMapper.getRowWithMetaColumn(aggregateFunction.getGroup().toByteBuffer());
  return Collections.singletonList(row);
}

Fixed version (ground truth):
@Override public List<Row> process(final ResultMapper resultMapper,final ColumnFamilyStore table,RowIndex currentIndex) throws Exception {
  Set<String> automatonFields=new HashSet<>();
  for (int i=0; i < states.length; i++) {
    automatonFields.add(states[i].getAutomatonField());
  }
  final Map<String,Integer> positions=aggregateFunction.getPositions();
  int position=positions.size();
  for (  String field : automatonFields) {
    aggregateFunction.getPositions().put(field,position++);
  }
  aggregateFunction.getPositions().put(MATCH_ID,position++);
  aggregateFunction.getPositions().put(PATTERN_ID,position++);
  final boolean[] allExpressions=new boolean[positions.size()];
  boolean[] afExpressions=aggregateFunction.getSimpleExpressions();
  for (int i=0; i < afExpressions.length; i++) {
    allExpressions[i]=afExpressions[i];
  }
  for (int i=afExpressions.length - 1; i < allExpressions.length; i++) {
    allExpressions[i]=true;
  }
  aggregateFunction.simpleExpressions=allExpressions;
  TreeMultimap<ByteBuffer,IndexEntryCollector.IndexEntry> docs=resultMapper.collector.docsByRowKey(table.metadata.getKeyValidator());
  NavigableSet<ByteBuffer> rowKeys=docs.keySet();
  List<Tuple> allMatches=new ArrayList<>();
  for (  ByteBuffer rowKey : rowKeys) {
    final DecoratedKey dk=table.partitioner.decorateKey(rowKey);
    ArrayList<IndexEntryCollector.IndexEntry> entries=new ArrayList<>(docs.get(rowKey));
    final Map<CellName,ColumnFamily> fullSlice=resultMapper.fetchRangeSlice(entries,dk);
    List<Tuple> tuples=Lists.transform(entries,new com.google.common.base.Function<IndexEntryCollector.IndexEntry,Tuple>(){
      @Override public Tuple apply(      IndexEntryCollector.IndexEntry input){
        CellName cellName=resultMapper.makeClusteringKey(input.primaryKey);
        ColumnFamily cf=fullSlice.get(cellName);
        if (cf != null) {
          Tuple tuple=aggregateFunction.createTuple(options);
          resultMapper.tableMapper.load(positions,tuple,new Row(dk,cf));
          return tuple;
        }
        return null;
      }
    }
);
    ListIterator<Tuple> iter=tuples.listIterator();
    allMatches.addAll(matchPartition(maxMatches,iter));
  }
  for (  Tuple match : allMatches) {
    if (match != null)     aggregateFunction.getGroup().addTuple(match);
  }
  Row row=resultMapper.tableMapper.getRowWithMetaColumn(aggregateFunction.getGroup().toByteBuffer());
  return Collections.singletonList(row);
}