src/java/org/apache/cassandra/db/DataTracker.java
/**
     * @return A subset of the given active sstables that have been marked compacting,
     * or null if the thresholds cannot be met: files that are marked compacting must
     * later be unmarked using unmarkCompacting.
     *
     * Note that we could acquire references on the marked sstables and release them in
     * unmarkCompacting, but since we will never call markCompacted on a sstable marked
     * as compacting (unless there is a serious bug), we can skip this.
     */
@return A subset of the given active sstables that have been marked compacting,
or null if the thresholds cannot be met: files that are marked compacting must
later be unmarked using unmarkCompacting.

Note that we could acquire references on the marked sstables and release them in
unmarkCompacting, but since we will never call markCompacted on a sstable marked
as compacting (unless there is a serious bug), we can skip this.
@return A subset of the given active sstables that have been marked compacting or null if the thresholds cannot be met : files that are marked compacting must later be unmarked using unmarkCompacting . Note that we could acquire references on the marked sstables and release them in unmarkCompacting but since we will never call markCompacted on a sstable marked as compacting ( unless there is a serious bug ) we can skip this .
public Set<SSTableReader> markCompacting(Collection<SSTableReader> tomark, int min, int max)
    {
        if (max < min || max < 1)
            return null;
        if (tomark == null || tomark.isEmpty())
            return null;
        View currentView, newView;
        Set<SSTableReader> subset = null;
        Set<SSTableReader> remaining = new LinkedHashSet<SSTableReader>(tomark);
        do
        {
            currentView = view.get();
            remaining.removeAll(currentView.compacting);
            remaining.retainAll(currentView.sstables);
            if (remaining.size() < min)
                return null;
            subset = new HashSet<SSTableReader>();
            Iterator<SSTableReader> iter = remaining.iterator();
            for (int added = 0; added < max && iter.hasNext(); added++)
                subset.add(iter.next());
            newView = currentView.markCompacting(subset);
        }
        while (!view.compareAndSet(currentView, newView));
        return subset;
    }
public Set < SSTableReader > markCompacting ( Collection < SSTableReader > tomark , int min , int max ) { if ( max < min || max < 1 ) return null ; if ( tomark == null || tomark . isEmpty ( ) ) return null ; View currentView , newView ; Set < SSTableReader > subset = null ; Set < SSTableReader > remaining = new LinkedHashSet < SSTableReader > ( tomark ) ; do { currentView = view . get ( ) ; remaining . removeAll ( currentView . compacting ) ; remaining . retainAll ( currentView . sstables ) ; if ( remaining . size ( ) < min ) return null ; subset = new HashSet < SSTableReader > ( ) ; Iterator < SSTableReader > iter = remaining . iterator ( ) ; for ( int added = 0 ; added < max && iter . hasNext ( ) ; added ++ ) subset . add ( iter . next ( ) ) ; newView = currentView . markCompacting ( subset ) ; } while ( ! view . compareAndSet ( currentView , newView ) ) ; return subset ; }
@return A subset of the given active sstables that have been marked compacting,
 or null if the thresholds cannot be met: files that are marked compacting must
 later be unmarked using unmarkCompacting.
@return A subset of the given active sstables that have been marked compacting or null if the thresholds cannot be met : files that are marked compacting must later be unmarked using unmarkCompacting .
// order preserving set copy of the input // find the subset that is active and not already compacting // cannot meet the min threshold // cap the newly compacting items into a subset set