Buggy code:
public class RowIteratorFactory { private static final int RANGE_FILE_BUFFER_SIZE = 256 * 1024 ; private static final Comparator < IColumnIterator > COMPARE_BY_KEY = new Comparator < IColumnIterator > ( ) { public int compare ( IColumnIterator o1 , IColumnIterator o2 ) { } } ; public static RowIterator getIterator ( final Collection < Memtable > memtables , final Collection < SSTableReader > sstables , final DecoratedKey startWith , final DecoratedKey stopAt , final QueryFilter filter , final AbstractType comparator , final ColumnFamilyStore cfs , final int gcBefore ) { final List < Iterator < IColumnIterator > > iterators = new ArrayList < Iterator < IColumnIterator > > ( ) ; Predicate < IColumnIterator > p = new Predicate < IColumnIterator > ( ) { public boolean apply ( IColumnIterator row ) { return ( ( startWith . compareTo ( row . getKey ( ) ) ) <= 0 ) && ( ( stopAt . isEmpty ( ) ) || ( ( row . getKey ( ) . compareTo ( stopAt ) ) <= 0 ) ) ; } } ; for ( Memtable memtable : memtables ) { iterators . add ( Iterators . filter ( Iterators . transform ( memtable . getEntryIterator ( startWith ) , new RowIteratorFactory . ConvertToColumnIterator ( filter , comparator ) ) , p ) ) ; } for ( SSTableReader sstable : sstables ) { final SSTableScanner scanner = sstable . getScanner ( RowIteratorFactory . RANGE_FILE_BUFFER_SIZE , filter ) ; scanner . seekTo ( startWith ) ; assert scanner instanceof Closeable ; iterators . add ( scanner ) ; } Iterator < IColumnIterator > collated = IteratorUtils . collatedIterator ( RowIteratorFactory . COMPARE_BY_KEY , iterators ) ; final Memtable firstMemtable = memtables . iterator ( ) . next ( ) ; ReducingIterator < IColumnIterator , Row > reduced = new ReducingIterator < IColumnIterator , Row > ( collated ) { private List < IColumnIterator > colIters = new ArrayList < IColumnIterator > ( ) ; private DecoratedKey key ; public void reduce ( IColumnIterator current ) { this . colIters . add ( current ) ; this . key = current . getKey ( ) ; } @ Override protected boolean isEqual ( IColumnIterator o1 , IColumnIterator o2 ) { return ( RowIteratorFactory . COMPARE_BY_KEY . compare ( o1 , o2 ) ) == 0 ; } protected Row getReduced ( ) { Comparator < IColumn > colComparator = QueryFilter . getColumnComparator ( comparator ) ; Iterator < IColumn > colCollated = IteratorUtils . collatedIterator ( colComparator , colIters ) ; ColumnFamily returnCF = null ; ColumnFamily cached = cfs . getRawCachedRow ( key ) ; if ( cached != null ) { QueryFilter keyFilter = new QueryFilter ( key , filter . path , filter . filter ) ; <START_BUG> returnCF = cfs . filterColumnFamily ( cached , keyFilter , CompactionManager . getDefaultGCBefore ( ) ) ; <END_BUG> } else { returnCF = firstMemtable . getColumnFamily ( key ) ; returnCF = ( returnCF == null ) ? ColumnFamily . create ( firstMemtable . getTableName ( ) , filter . getColumnFamilyName ( ) ) : returnCF . cloneMeShallow ( ) ; if ( colCollated . hasNext ( ) ) { filter . collectCollatedColumns ( returnCF , colCollated , gcBefore ) ; } else { returnCF = null ; } } Row rv = new Row ( key , returnCF ) ; colIters . clear ( ) ; key = null ; return rv ; } } ; return new RowIterator ( reduced , iterators ) ; } private static Iterator < Map . Entry < DecoratedKey , ColumnFamily > > memtableEntryIterator ( Memtable memtable , DecoratedKey startWith ) { } private static class ConvertToColumnIterator implements Function < Map . Entry < DecoratedKey , ColumnFamily > , IColumnIterator > { private QueryFilter filter ; private AbstractType comparator ; public ConvertToColumnIterator ( QueryFilter filter , AbstractType comparator ) { } public IColumnIterator apply ( final Map . Entry < DecoratedKey , ColumnFamily > entry ) { } } }

Fix:
returnCF = cfs . filterColumnFamily ( cached , keyFilter , cfs . metadata . gcGraceSeconds ) ;