org.apache.cassandra.db

## Class ColumnFamilyStore

- java.lang.Object
- - org.apache.cassandra.db.ColumnFamilyStore

All Implemented Interfaces:
  ColumnFamilyStoreMBean

    public class ColumnFamilyStore
    extends java.lang.Object
    implements ColumnFamilyStoreMBean

### Nested Class Summary

Nested Classes
`static class` `ColumnFamilyStore.AbstractScanIterator`
`static class` `ColumnFamilyStore.FlushLargestColumnFamily` Finds the largest memtable, as a percentage of *either* on- or off-heap memory limits, and immediately queues it for flushing.
`static class` `ColumnFamilyStore.RefViewFragment`
`static class` `ColumnFamilyStore.ViewFragment`

### Field Summary

Fields
`static com.google.common.base.Function<View,java.util.List<SSTableReader>>` `CANONICAL_SSTABLES`
`Directories` `directories`
`static ColumnFamilyStore` `discardFlushResults`
`SecondaryIndexManager` `indexManager`
`Keyspace` `keyspace`
`CFMetaData` `metadata`
`ColumnFamilyMetrics` `metric`
`java.lang.String` `name`
`IPartitioner` `partitioner`
`OpOrder` `readOrdering`
`long` `sampleLatencyNanos`
`static com.google.common.base.Function<View,java.util.List<SSTableReader>>` `UNREPAIRED_SSTABLES`

### Constructor Summary

Constructors
Constructor and Description
`ColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamilyName, IPartitioner partitioner, int generation, CFMetaData metadata, Directories directories, boolean loadSSTables)`
`ColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamilyName, IPartitioner partitioner, int generation, CFMetaData metadata, Directories directories, boolean loadSSTables, boolean registerBookkeeping)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addSSTable(SSTableReader sstable)`
`void` `addSSTables(java.util.Collection<SSTableReader> sstables)`
`static java.lang.Iterable<ColumnFamilyStore>` `all()`
`void` `apply(DecoratedKey key, ColumnFamily columnFamily, SecondaryIndexManager.Updater indexer, OpOrder.Group opGroup, ReplayPosition replayPosition)` Insert/Update the column family for this key.
`void` `beginLocalSampling(java.lang.String sampler, int capacity)` begin sampling for a specific sampler with a given capacity.
`void` `cleanupCache()`
`protected static void` `clearEphemeralSnapshots(Directories directories)`
`void` `clearSnapshot(java.lang.String snapshotName)` Clear all the snapshots for a given column family.
`void` `clearUnsafe()` For testing.
`java.lang.Iterable<ColumnFamilyStore>` `concatWithIndexes()`
`boolean` `containsCachedRow(DecoratedKey key)`
`static ColumnFamilyStore` `createColumnFamilyStore(Keyspace keyspace, CFMetaData metadata, boolean loadSSTables)`
`static ColumnFamilyStore` `createColumnFamilyStore(Keyspace keyspace, java.lang.String columnFamily, IPartitioner partitioner, CFMetaData metadata, boolean loadSSTables)`
`void` `disableAutoCompaction()`
`void` `discardSSTables(long truncatedAt)` Discard all SSTables that were created before given timestamp.
`void` `enableAutoCompaction()`
`void` `enableAutoCompaction(boolean waitForFutures)` used for tests - to be able to check things after a minor compaction
`long` `estimatedKeysForRange(Range<Token> range)`
`long` `estimateKeys()`
`java.util.List<Row>` `filter(ColumnFamilyStore.AbstractScanIterator rowIterator, ExtendedFilter filter)`
`javax.management.openmbean.CompositeData` `finishLocalSampling(java.lang.String sampler, int count)`
`ReplayPosition` `forceBlockingFlush()`
`CompactionManager.AllSSTableOpStatus` `forceCleanup(int jobs)`
`com.google.common.util.concurrent.ListenableFuture<ReplayPosition>` `forceFlush()` Flush if there is unflushed data in the memtables
`com.google.common.util.concurrent.ListenableFuture<ReplayPosition>` `forceFlush(ReplayPosition flushIfDirtyBefore)` Flush if there is unflushed data that was written to the CommitLog before @param flushIfDirtyBefore (inclusive).
`void` `forceMajorCompaction()`
`void` `forceMajorCompaction(boolean splitOutput)` force a major compaction of this column family
`int` `gcBefore(long now)`
`Refs<SSTableReader>` `getAndReferenceOverlappingSSTables(java.lang.Iterable<SSTableReader> sstables)` like getOverlappingSSTables, but acquires references before returning
`static java.lang.Runnable` `getBackgroundCompactionTaskSubmitter()`
`java.util.List<java.lang.String>` `getBuiltIndexes()` Returns a list of the names of the built column indexes for current store
`ClockAndCount` `getCachedCounter(java.nio.ByteBuffer partitionKey, CellName cellName)`
`ColumnFamily` `getColumnFamily(DecoratedKey key, Composite start, Composite finish, boolean reversed, int limit, long timestamp)`
`ColumnFamily` `getColumnFamily(QueryFilter filter)` get a list of columns starting from a given column, in a specified order.
`java.lang.String` `getColumnFamilyName()`
`java.util.Map<java.lang.String,java.lang.String>` `getCompactionParameters()`
`java.lang.String` `getCompactionParametersJson()`
`AbstractCompactionStrategy` `getCompactionStrategy()`
`java.lang.String` `getCompactionStrategyClass()` Gets the compaction strategy class name
`CellNameType` `getComparator()`
`java.util.Map<java.lang.String,java.lang.String>` `getCompressionParameters()` Get the compression parameters
`double` `getDroppableTombstoneRatio()` Get the ratio of droppable tombstones to real columns (and non-droppable tombstones)
`long` `getExpectedCompactedFileSize(java.lang.Iterable<SSTableReader> sstables, OperationType operation)` Calculate expected file size of SSTable after compaction.
`static ColumnFamilyStore` `getIfExists(java.lang.String ksName, java.lang.String cfName)` Returns a ColumnFamilyStore by ksname and cfname if it exists, null otherwise Differently from others, this method does not throw exception if the keyspace or table does not exist.
`static ColumnFamilyStore` `getIfExists(java.util.UUID cfId)` Returns a ColumnFamilyStore by cfId if it exists, null otherwise Differently from others, this method does not throw exception if the table does not exist.
`int` `getMaximumCompactionThreshold()` Gets the maximum number of sstables in queue before compaction kicks off
`SSTableReader` `getMaxSizeFile(java.lang.Iterable<SSTableReader> sstables)`
`int` `getMeanColumns()`
`int` `getMinimumCompactionThreshold()` Gets the minimum number of sstables in queue before compaction kicks off
`java.util.Collection<SSTableReader>` `getOverlappingSSTables(java.lang.Iterable<SSTableReader> sstables)`
`java.lang.Iterable<SSTableReader>` `getPermittedToCompactSSTables()`
`java.util.List<Row>` `getRangeSlice(AbstractBounds<RowPosition> range, java.util.List<IndexExpression> rowFilter, IDiskAtomFilter columnFilter, int maxResults)`
`java.util.List<Row>` `getRangeSlice(AbstractBounds<RowPosition> range, java.util.List<IndexExpression> rowFilter, IDiskAtomFilter columnFilter, int maxResults, long now)`
`java.util.List<Row>` `getRangeSlice(AbstractBounds<RowPosition> range, java.util.List<IndexExpression> rowFilter, IDiskAtomFilter columnFilter, int maxResults, long now, boolean countCQL3Rows, boolean isPaging)`
`java.util.List<Row>` `getRangeSlice(ExtendedFilter filter)`
`ColumnFamily` `getRawCachedRow(DecoratedKey key)`
`java.util.Set<SSTableReader>` `getRepairedSSTables()`
`long` `getSnapshotCreationTime(java.lang.String snapshotName)`
`java.util.Map<java.lang.String,Pair<java.lang.Long,java.lang.Long>>` `getSnapshotDetails()`
`Refs<SSTableReader>` `getSnapshotSSTableReader(java.lang.String tag)`
`int[]` `getSSTableCountPerLevel()`
`java.util.Collection<SSTableReader>` `getSSTables()`
`java.util.List<java.lang.String>` `getSSTablesForKey(java.lang.String key)` Returns a list of filenames that contain the given key on this node
`java.lang.String` `getTempSSTablePath(java.io.File directory)`
`java.lang.String` `getTempSSTablePath(java.io.File directory, SSTableFormat.Type format)`
`ColumnFamily` `getTopLevelColumns(QueryFilter filter, int gcBefore)`
`Tracker` `getTracker()` Package protected for access from the CompactionManager.
`java.util.Set<SSTableReader>` `getUncompactingSSTables()`
`int` `getUnleveledSSTables()`
`java.util.Set<SSTableReader>` `getUnrepairedSSTables()`
`boolean` `hasUnreclaimedSpace()`
`void` `invalidate()` call when dropping or renaming a CF.
`void` `invalidate(boolean expectMBean)`
`void` `invalidateCachedRow(DecoratedKey key)`
`void` `invalidateCachedRow(RowCacheKey key)`
`int` `invalidateCounterCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)`
`int` `invalidateRowCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)`
`boolean` `isAutoCompactionDisabled()`
`boolean` `isCounterCacheEnabled()`
`boolean` `isEmpty()`
`boolean` `isFilterFullyCoveredBy(IDiskAtomFilter filter, ColumnFamily cachedCf, long now)`
`boolean` `isIndex()` true if this CFS contains secondary index data
`boolean` `isKeyCacheEnabled()`
`boolean` `isRowCacheEnabled()`
`boolean` `isValid()`
`java.lang.Iterable<DecoratedKey>` `keySamples(Range<Token> range)`
`void` `loadNewSSTables()` #Scan through Keyspace/ColumnFamily's data directory determine which SSTables should be loaded and load them
`static void` `loadNewSSTables(java.lang.String ksName, java.lang.String cfName)` See #`StorageService.loadNewSSTables(String, String)` for more info
`ExtendedFilter` `makeExtendedFilter(AbstractBounds<RowPosition> range, IDiskAtomFilter columnFilter, java.util.List<IndexExpression> rowFilter, int maxResults, boolean countCQL3Rows, boolean isPaging, long timestamp)`
`ExtendedFilter` `makeExtendedFilter(AbstractBounds<RowPosition> keyRange, SliceQueryFilter columnRange, Composite columnStart, Composite columnStop, java.util.List<IndexExpression> rowFilter, int maxResults, boolean countCQL3Rows, long now)` Allows generic range paging with the slice column filter.
`LifecycleTransaction` `markAllCompacting(OperationType operationType)`
`void` `markObsolete(java.util.Collection<SSTableReader> sstables, OperationType compactionType)`
`void` `maybeUpdateRowCache(DecoratedKey key)`
`void` `putCachedCounter(java.nio.ByteBuffer partitionKey, CellName cellName, ClockAndCount clockAndCount)`
`SliceQueryFilter` `readFilterForCache()`
`boolean` `rebuildOnFailedScrub(java.lang.Throwable failure)` CASSANDRA-5174 : For an index cfs we may be able to discard everything and just rebuild the index when a scrub fails.
`void` `rebuildSecondaryIndex(java.lang.String idxName)`
`static void` `rebuildSecondaryIndex(java.lang.String ksName, java.lang.String cfName, java.lang.String... idxNames)`
`void` `reload()`
`static ColumnFamily` `removeDeleted(ColumnFamily cf, int gcBefore)` Removes deleted columns and purges gc-able tombstones.
`static ColumnFamily` `removeDeleted(ColumnFamily cf, int gcBefore, SecondaryIndexManager.Updater indexer)`
`static ColumnFamily` `removeDeletedCF(ColumnFamily cf, int gcBefore)` Purges gc-able top-level and range tombstones, returning `cf` if there are any columns or tombstones left, null otherwise.
`static ColumnFamily` `removeDeletedColumnsOnly(ColumnFamily cf, int gcBefore, SecondaryIndexManager.Updater indexer)` Removes only per-cell tombstones, cells that are shadowed by a row-level or range tombstone, or columns that have been dropped from the schema (for CQL3 tables only).
`static void` `removeUnfinishedCompactionLeftovers(CFMetaData metadata, java.util.Map<java.lang.Integer,java.util.UUID> unfinishedCompactions)` Replacing compacted sstables is atomic as far as observers of Tracker are concerned, but not on the filesystem: first the new sstables are renamed to "live" status (i.e., the tmp marker is removed), then their ancestors are removed.
`void` `resumeFlushing()`
`<V> V` `runWithCompactionsDisabled(java.util.concurrent.Callable<V> callable, boolean interruptValidation)`
`CompactionManager.AllSSTableOpStatus` `scrub(boolean disableSnapshot, boolean skipCorrupted, boolean alwaysFail, boolean checkData, boolean reinsertOverflowedTTLRows, int jobs)`
`CompactionManager.AllSSTableOpStatus` `scrub(boolean disableSnapshot, boolean skipCorrupted, boolean checkData, boolean reinsertOverflowedTTLRows, int jobs)`
`static void` `scrubDataDirectories(CFMetaData metadata)` Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files and compacted sstables.
`java.util.List<Row>` `search(AbstractBounds<RowPosition> range, java.util.List<IndexExpression> clause, IDiskAtomFilter dataFilter, int maxResults)`
`java.util.List<Row>` `search(AbstractBounds<RowPosition> range, java.util.List<IndexExpression> clause, IDiskAtomFilter dataFilter, int maxResults, long now)`
`java.util.List<Row>` `search(ExtendedFilter filter)`
`ColumnFamilyStore.ViewFragment` `select(com.google.common.base.Function<View,java.util.List<SSTableReader>> filter)`
`ColumnFamilyStore.RefViewFragment` `selectAndReference(com.google.common.base.Function<View,java.util.List<SSTableReader>> filter)`
`void` `setCompactionParameters(java.util.Map<java.lang.String,java.lang.String> options)` Sets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted
`void` `setCompactionParametersJson(java.lang.String options)` Sets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted
`void` `setCompactionStrategyClass(java.lang.String compactionStrategyClass)` Sets the compaction strategy by class name
`void` `setCompactionThresholds(int minThreshold, int maxThreshold)` Sets the maximum and maximum number of SSTables in queue before compaction kicks off
`void` `setCompressionParameters(java.util.Map<java.lang.String,java.lang.String> opts)` Set the compression parameters
`void` `setCrcCheckChance(double crcCheckChance)` Set new crc check chance
`void` `setMaximumCompactionThreshold(int maxCompactionThreshold)` Sets the maximum number of sstables in queue before compaction kicks off
`void` `setMinimumCompactionThreshold(int minCompactionThreshold)` Sets the minimum number of sstables in queue before compaction kicks off
`static void` `shutdownPostFlushExecutor()`
`void` `simulateFailedFlush()`
`java.util.Set<SSTableReader>` `snapshot(java.lang.String snapshotName)` Take a snap shot of this columnfamily store.
`java.util.Set<SSTableReader>` `snapshot(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral)`
`boolean` `snapshotExists(java.lang.String snapshotName)`
`void` `snapshotWithoutFlush(java.lang.String snapshotName)`
`java.util.Set<SSTableReader>` `snapshotWithoutFlush(java.lang.String snapshotName, com.google.common.base.Predicate<SSTableReader> predicate, boolean ephemeral)`
`CompactionManager.AllSSTableOpStatus` `sstablesRewrite(boolean excludeCurrentVersion, int jobs)`
`com.google.common.util.concurrent.ListenableFuture<ReplayPosition>` `switchMemtable()`
`com.google.common.util.concurrent.ListenableFuture<ReplayPosition>` `switchMemtableIfCurrent(Memtable memtable)` Switches the memtable iff the live memtable is the one provided
`java.lang.String` `toString()`
`long` `trueSnapshotsSize()`
`void` `truncateBlocking()` Truncate deletes the entire column family's data with no expensive tombstone creation
`void` `truncateBlocking(boolean takeSnapshot)` Truncate deletes the column family's data with no expensive tombstone creation, optionally snapshotting the data.
`CompactionManager.AllSSTableOpStatus` `verify(boolean extendedVerify)`
`com.google.common.base.Function<View,java.util.List<SSTableReader>>` `viewFilter(AbstractBounds<RowPosition> rowBounds)`
`com.google.common.base.Function<View,java.util.List<SSTableReader>>` `viewFilter(java.util.Collection<AbstractBounds<RowPosition>> rowBoundsCollection, boolean includeRepaired)`
`com.google.common.base.Function<View,java.util.List<SSTableReader>>` `viewFilter(DecoratedKey key)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### discardFlushResults

    public static volatile ColumnFamilyStore discardFlushResults

#### keyspace

    public final Keyspace keyspace

#### name

    public final java.lang.String name

#### metadata

    public final CFMetaData metadata

#### partitioner

    public final IPartitioner partitioner

#### readOrdering

    public final OpOrder readOrdering

#### indexManager

    public final SecondaryIndexManager indexManager

#### directories

    public final Directories directories

#### metric

    public final ColumnFamilyMetrics metric

#### sampleLatencyNanos

    public volatile long sampleLatencyNanos

#### CANONICAL_SSTABLES

    public static final com.google.common.base.Function<View,java.util.List<SSTableReader>> CANONICAL_SSTABLES

#### UNREPAIRED_SSTABLES

    public static final com.google.common.base.Function<View,java.util.List<SSTableReader>> UNREPAIRED_SSTABLES

### Constructor Detail

#### ColumnFamilyStore

    public ColumnFamilyStore(Keyspace keyspace,
                             java.lang.String columnFamilyName,
                             IPartitioner partitioner,
                             int generation,
                             CFMetaData metadata,
                             Directories directories,
                             boolean loadSSTables)

#### ColumnFamilyStore

    public ColumnFamilyStore(Keyspace keyspace,
                             java.lang.String columnFamilyName,
                             IPartitioner partitioner,
                             int generation,
                             CFMetaData metadata,
                             Directories directories,
                             boolean loadSSTables,
                             boolean registerBookkeeping)

### Method Detail

#### shutdownPostFlushExecutor

    public static void shutdownPostFlushExecutor()
                                          throws java.lang.InterruptedException

Throws:
  `java.lang.InterruptedException`

#### reload

    public void reload()

#### getBackgroundCompactionTaskSubmitter

    public static java.lang.Runnable getBackgroundCompactionTaskSubmitter()

#### setCompactionParametersJson

    public void setCompactionParametersJson(java.lang.String options)

Description copied from interface: `ColumnFamilyStoreMBean`
Sets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted

Specified by:
  `setCompactionParametersJson` in interface `ColumnFamilyStoreMBean`
Parameters:
  `options` - compaction options with the same syntax as when doing ALTER ... WITH compaction = {..}

#### getCompactionParametersJson

    public java.lang.String getCompactionParametersJson()

Specified by:
  `getCompactionParametersJson` in interface `ColumnFamilyStoreMBean`

#### setCompactionParameters

    public void setCompactionParameters(java.util.Map<java.lang.String,java.lang.String> options)

Description copied from interface: `ColumnFamilyStoreMBean`
Sets the compaction parameters locally for this node Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted

Specified by:
  `setCompactionParameters` in interface `ColumnFamilyStoreMBean`
Parameters:
  `options` - compaction options map

#### getCompactionParameters

    public java.util.Map<java.lang.String,java.lang.String> getCompactionParameters()

Specified by:
  `getCompactionParameters` in interface `ColumnFamilyStoreMBean`

#### setCompactionStrategyClass

    public void setCompactionStrategyClass(java.lang.String compactionStrategyClass)

Description copied from interface: `ColumnFamilyStoreMBean`
Sets the compaction strategy by class name

Specified by:
  `setCompactionStrategyClass` in interface `ColumnFamilyStoreMBean`
Parameters:
  `compactionStrategyClass` - the name of the compaction strategy class

#### getCompactionStrategyClass

    public java.lang.String getCompactionStrategyClass()

Description copied from interface: `ColumnFamilyStoreMBean`
Gets the compaction strategy class name

Specified by:
  `getCompactionStrategyClass` in interface `ColumnFamilyStoreMBean`

#### getCompressionParameters

    public java.util.Map<java.lang.String,java.lang.String> getCompressionParameters()

Description copied from interface: `ColumnFamilyStoreMBean`
Get the compression parameters

Specified by:
  `getCompressionParameters` in interface `ColumnFamilyStoreMBean`

#### setCompressionParameters

    public void setCompressionParameters(java.util.Map<java.lang.String,java.lang.String> opts)

Description copied from interface: `ColumnFamilyStoreMBean`
Set the compression parameters

Specified by:
  `setCompressionParameters` in interface `ColumnFamilyStoreMBean`
Parameters:
  `opts` - map of string names to values

#### setCrcCheckChance

    public void setCrcCheckChance(double crcCheckChance)

Description copied from interface: `ColumnFamilyStoreMBean`
Set new crc check chance

Specified by:
  `setCrcCheckChance` in interface `ColumnFamilyStoreMBean`

#### invalidate

    public void invalidate()

call when dropping or renaming a CF. Performs mbean housekeeping and invalidates CFS to other operations

#### invalidate

    public void invalidate(boolean expectMBean)

#### createColumnFamilyStore

    public static ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace,
                                                            CFMetaData metadata,
                                                            boolean loadSSTables)

#### createColumnFamilyStore

    public static ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace,
                                                            java.lang.String columnFamily,
                                                            IPartitioner partitioner,
                                                            CFMetaData metadata,
                                                            boolean loadSSTables)

#### scrubDataDirectories

    public static void scrubDataDirectories(CFMetaData metadata)

Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files and compacted sstables. Files that cannot be recognized will be ignored.

#### removeUnfinishedCompactionLeftovers

    public static void removeUnfinishedCompactionLeftovers(CFMetaData metadata,
                                                           java.util.Map<java.lang.Integer,java.util.UUID> unfinishedCompactions)

Replacing compacted sstables is atomic as far as observers of Tracker are concerned, but not on the filesystem: first the new sstables are renamed to "live" status (i.e., the tmp marker is removed), then their ancestors are removed. If an unclean shutdown happens at the right time, we can thus end up with both the new ones and their ancestors "live" in the system. This is harmless for normal data, but for counters it can cause overcounts. To prevent this, we record sstables being compacted in the system keyspace. If we find unfinished compactions, we remove the new ones (since those may be incomplete -- under LCS, we may create multiple sstables from any given ancestor).

#### loadNewSSTables

    public static void loadNewSSTables(java.lang.String ksName,
                                       java.lang.String cfName)

See #`StorageService.loadNewSSTables(String, String)` for more info

Parameters:
  `ksName` - The keyspace name
  `cfName` - The columnFamily name

#### loadNewSSTables

    public void loadNewSSTables()

#Scan through Keyspace/ColumnFamily's data directory determine which SSTables should be loaded and load them

Specified by:
  `loadNewSSTables` in interface `ColumnFamilyStoreMBean`

#### rebuildSecondaryIndex

    public void rebuildSecondaryIndex(java.lang.String idxName)

#### rebuildSecondaryIndex

    public static void rebuildSecondaryIndex(java.lang.String ksName,
                                             java.lang.String cfName,
                                             java.lang.String... idxNames)

#### getColumnFamilyName

    public java.lang.String getColumnFamilyName()

Specified by:
  `getColumnFamilyName` in interface `ColumnFamilyStoreMBean`
Returns:
  the name of the column family

#### getTempSSTablePath

    public java.lang.String getTempSSTablePath(java.io.File directory)

#### getTempSSTablePath

    public java.lang.String getTempSSTablePath(java.io.File directory,
                                               SSTableFormat.Type format)

#### switchMemtableIfCurrent

    public com.google.common.util.concurrent.ListenableFuture<ReplayPosition> switchMemtableIfCurrent(Memtable memtable)

Switches the memtable iff the live memtable is the one provided

Parameters:
  `memtable` -

#### switchMemtable

    public com.google.common.util.concurrent.ListenableFuture<ReplayPosition> switchMemtable()

#### forceFlush

    public com.google.common.util.concurrent.ListenableFuture<ReplayPosition> forceFlush()

Flush if there is unflushed data in the memtables

Returns:
  a Future yielding the commit log position that can be guaranteed to have been successfully written to sstables for this table once the future completes

#### forceFlush

    public com.google.common.util.concurrent.ListenableFuture<ReplayPosition> forceFlush(ReplayPosition flushIfDirtyBefore)

Flush if there is unflushed data that was written to the CommitLog before @param flushIfDirtyBefore (inclusive).

Returns:
  a Future yielding the commit log position that can be guaranteed to have been successfully written to sstables for this table once the future completes

#### forceBlockingFlush

    public ReplayPosition forceBlockingFlush()

#### simulateFailedFlush

    public void simulateFailedFlush()

#### resumeFlushing

    public void resumeFlushing()

#### maybeUpdateRowCache

    public void maybeUpdateRowCache(DecoratedKey key)

#### apply

    public void apply(DecoratedKey key,
                      ColumnFamily columnFamily,
                      SecondaryIndexManager.Updater indexer,
                      OpOrder.Group opGroup,
                      ReplayPosition replayPosition)

Insert/Update the column family for this key. Caller is responsible for acquiring Keyspace.switchLock param @ lock - lock that needs to be used. param @ key - key for update/insert param @ columnFamily - columnFamily changes

#### removeDeletedCF

    public static ColumnFamily removeDeletedCF(ColumnFamily cf,
                                               int gcBefore)

Purges gc-able top-level and range tombstones, returning `cf` if there are any columns or tombstones left, null otherwise.

Parameters:
  `gcBefore` - a timestamp (in seconds); tombstones with a localDeletionTime before this will be purged

#### removeDeleted

    public static ColumnFamily removeDeleted(ColumnFamily cf,
                                             int gcBefore)

Removes deleted columns and purges gc-able tombstones.

Returns:
  an updated `cf` if any columns or tombstones remain, null otherwise

#### removeDeleted

    public static ColumnFamily removeDeleted(ColumnFamily cf,
                                             int gcBefore,
                                             SecondaryIndexManager.Updater indexer)

#### removeDeletedColumnsOnly

    public static ColumnFamily removeDeletedColumnsOnly(ColumnFamily cf,
                                                        int gcBefore,
                                                        SecondaryIndexManager.Updater indexer)

Removes only per-cell tombstones, cells that are shadowed by a row-level or range tombstone, or columns that have been dropped from the schema (for CQL3 tables only).

Returns:
  the updated ColumnFamily

#### getOverlappingSSTables

    public java.util.Collection<SSTableReader> getOverlappingSSTables(java.lang.Iterable<SSTableReader> sstables)

Parameters:
  `sstables` -
Returns:
  sstables whose key range overlaps with that of the given sstables, not including itself. (The given sstables may or may not overlap with each other.)

#### getAndReferenceOverlappingSSTables

    public Refs<SSTableReader> getAndReferenceOverlappingSSTables(java.lang.Iterable<SSTableReader> sstables)

like getOverlappingSSTables, but acquires references before returning

#### addSSTable

    public void addSSTable(SSTableReader sstable)

#### addSSTables

    public void addSSTables(java.util.Collection<SSTableReader> sstables)

#### getExpectedCompactedFileSize

    public long getExpectedCompactedFileSize(java.lang.Iterable<SSTableReader> sstables,
                                             OperationType operation)

Calculate expected file size of SSTable after compaction. If operation type is `CLEANUP` and we're not dealing with an index sstable, then we calculate expected file size with checking token range to be eliminated. Otherwise, we just add up all the files' size, which is the worst case file size for compaction of all the list of files given.

Parameters:
  `sstables` - SSTables to calculate expected compacted file size
  `operation` - Operation type
Returns:
  Expected file size of SSTable after compaction

#### getMaxSizeFile

    public SSTableReader getMaxSizeFile(java.lang.Iterable<SSTableReader> sstables)

#### forceCleanup

    public CompactionManager.AllSSTableOpStatus forceCleanup(int jobs)
                                                      throws java.util.concurrent.ExecutionException,
                                                             java.lang.InterruptedException

Throws:
  `java.util.concurrent.ExecutionException`
  `java.lang.InterruptedException`

#### scrub

    public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot,
                                                      boolean skipCorrupted,
                                                      boolean checkData,
                                                      boolean reinsertOverflowedTTLRows,
                                                      int jobs)
                                               throws java.util.concurrent.ExecutionException,
                                                      java.lang.InterruptedException

Throws:
  `java.util.concurrent.ExecutionException`
  `java.lang.InterruptedException`

#### scrub

    public CompactionManager.AllSSTableOpStatus scrub(boolean disableSnapshot,
                                                      boolean skipCorrupted,
                                                      boolean alwaysFail,
                                                      boolean checkData,
                                                      boolean reinsertOverflowedTTLRows,
                                                      int jobs)
                                               throws java.util.concurrent.ExecutionException,
                                                      java.lang.InterruptedException

Throws:
  `java.util.concurrent.ExecutionException`
  `java.lang.InterruptedException`

#### rebuildOnFailedScrub

    public boolean rebuildOnFailedScrub(java.lang.Throwable failure)

CASSANDRA-5174 : For an index cfs we may be able to discard everything and just rebuild the index when a scrub fails.

Returns:
  true if we are an index cfs and we successfully rebuilt the index

#### verify

    public CompactionManager.AllSSTableOpStatus verify(boolean extendedVerify)
                                                throws java.util.concurrent.ExecutionException,
                                                       java.lang.InterruptedException

Throws:
  `java.util.concurrent.ExecutionException`
  `java.lang.InterruptedException`

#### sstablesRewrite

    public CompactionManager.AllSSTableOpStatus sstablesRewrite(boolean excludeCurrentVersion,
                                                                int jobs)
                                                         throws java.util.concurrent.ExecutionException,
                                                                java.lang.InterruptedException

Throws:
  `java.util.concurrent.ExecutionException`
  `java.lang.InterruptedException`

#### markObsolete

    public void markObsolete(java.util.Collection<SSTableReader> sstables,
                             OperationType compactionType)

#### isValid

    public boolean isValid()

#### getTracker

    public Tracker getTracker()

Package protected for access from the CompactionManager.

#### getSSTables

    public java.util.Collection<SSTableReader> getSSTables()

#### getPermittedToCompactSSTables

    public java.lang.Iterable<SSTableReader> getPermittedToCompactSSTables()

#### getUncompactingSSTables

    public java.util.Set<SSTableReader> getUncompactingSSTables()

#### getColumnFamily

    public ColumnFamily getColumnFamily(DecoratedKey key,
                                        Composite start,
                                        Composite finish,
                                        boolean reversed,
                                        int limit,
                                        long timestamp)

#### readFilterForCache

    public SliceQueryFilter readFilterForCache()

#### isFilterFullyCoveredBy

    public boolean isFilterFullyCoveredBy(IDiskAtomFilter filter,
                                          ColumnFamily cachedCf,
                                          long now)

#### gcBefore

    public int gcBefore(long now)

#### getColumnFamily

    public ColumnFamily getColumnFamily(QueryFilter filter)

get a list of columns starting from a given column, in a specified order. only the latest version of a column is returned.

Returns:
  null if there is no data and no tombstones; otherwise a ColumnFamily

#### getUnrepairedSSTables

    public java.util.Set<SSTableReader> getUnrepairedSSTables()

#### getRepairedSSTables

    public java.util.Set<SSTableReader> getRepairedSSTables()

#### selectAndReference

    public ColumnFamilyStore.RefViewFragment selectAndReference(com.google.common.base.Function<View,java.util.List<SSTableReader>> filter)

#### select

    public ColumnFamilyStore.ViewFragment select(com.google.common.base.Function<View,java.util.List<SSTableReader>> filter)

#### viewFilter

    public com.google.common.base.Function<View,java.util.List<SSTableReader>> viewFilter(DecoratedKey key)

Returns:
  a ViewFragment containing the sstables and memtables that may need to be merged for the given @param key, according to the interval tree

#### viewFilter

    public com.google.common.base.Function<View,java.util.List<SSTableReader>> viewFilter(AbstractBounds<RowPosition> rowBounds)

Returns:
  a ViewFragment containing the sstables and memtables that may need to be merged for rows within @param rowBounds, inclusive, according to the interval tree.

#### viewFilter

    public com.google.common.base.Function<View,java.util.List<SSTableReader>> viewFilter(java.util.Collection<AbstractBounds<RowPosition>> rowBoundsCollection,
                                                                                          boolean includeRepaired)

Returns:
  a ViewFragment containing the sstables and memtables that may need to be merged for rows for all of @param rowBoundsCollection, inclusive, according to the interval tree.

#### getSSTablesForKey

    public java.util.List<java.lang.String> getSSTablesForKey(java.lang.String key)

Description copied from interface: `ColumnFamilyStoreMBean`
Returns a list of filenames that contain the given key on this node

Specified by:
  `getSSTablesForKey` in interface `ColumnFamilyStoreMBean`
Returns:
  list of filenames containing the key

#### getTopLevelColumns

    public ColumnFamily getTopLevelColumns(QueryFilter filter,
                                           int gcBefore)

#### beginLocalSampling

    public void beginLocalSampling(java.lang.String sampler,
                                   int capacity)

Description copied from interface: `ColumnFamilyStoreMBean`
begin sampling for a specific sampler with a given capacity. The cardinality may be larger than the capacity, but depending on the use case it may affect its accuracy

Specified by:
  `beginLocalSampling` in interface `ColumnFamilyStoreMBean`

#### finishLocalSampling

    public javax.management.openmbean.CompositeData finishLocalSampling(java.lang.String sampler,
                                                                        int count)
                                                                 throws javax.management.openmbean.OpenDataException

Specified by:
  `finishLocalSampling` in interface `ColumnFamilyStoreMBean`
Returns:
  top count items for the sampler since beginLocalSampling was called
Throws:
  `javax.management.openmbean.OpenDataException`

#### cleanupCache

    public void cleanupCache()

#### getRangeSlice

    public java.util.List<Row> getRangeSlice(AbstractBounds<RowPosition> range,
                                             java.util.List<IndexExpression> rowFilter,
                                             IDiskAtomFilter columnFilter,
                                             int maxResults)

#### getRangeSlice

    public java.util.List<Row> getRangeSlice(AbstractBounds<RowPosition> range,
                                             java.util.List<IndexExpression> rowFilter,
                                             IDiskAtomFilter columnFilter,
                                             int maxResults,
                                             long now)

#### makeExtendedFilter

    public ExtendedFilter makeExtendedFilter(AbstractBounds<RowPosition> keyRange,
                                             SliceQueryFilter columnRange,
                                             Composite columnStart,
                                             Composite columnStop,
                                             java.util.List<IndexExpression> rowFilter,
                                             int maxResults,
                                             boolean countCQL3Rows,
                                             long now)

Allows generic range paging with the slice column filter. Typically, suppose we have rows A, B, C ... Z having each some columns in [1, 100]. And suppose we want to page through the query that for all rows returns the columns within [25, 75]. For that, we need to be able to do a range slice starting at (row r, column c) and ending at (row Z, column 75), *but* that only return columns in [25, 75]. That is what this method allows. The columnRange is the "window" of columns we are interested in each row, and columnStart (resp. columnEnd) is the start (resp. end) for the first (resp. last) requested row.

#### getRangeSlice

    public java.util.List<Row> getRangeSlice(AbstractBounds<RowPosition> range,
                                             java.util.List<IndexExpression> rowFilter,
                                             IDiskAtomFilter columnFilter,
                                             int maxResults,
                                             long now,
                                             boolean countCQL3Rows,
                                             boolean isPaging)

#### makeExtendedFilter

    public ExtendedFilter makeExtendedFilter(AbstractBounds<RowPosition> range,
                                             IDiskAtomFilter columnFilter,
                                             java.util.List<IndexExpression> rowFilter,
                                             int maxResults,
                                             boolean countCQL3Rows,
                                             boolean isPaging,
                                             long timestamp)

#### getRangeSlice

    public java.util.List<Row> getRangeSlice(ExtendedFilter filter)

#### search

    public java.util.List<Row> search(AbstractBounds<RowPosition> range,
                                      java.util.List<IndexExpression> clause,
                                      IDiskAtomFilter dataFilter,
                                      int maxResults)

#### search

    public java.util.List<Row> search(AbstractBounds<RowPosition> range,
                                      java.util.List<IndexExpression> clause,
                                      IDiskAtomFilter dataFilter,
                                      int maxResults,
                                      long now)

#### search

    public java.util.List<Row> search(ExtendedFilter filter)

#### filter

    public java.util.List<Row> filter(ColumnFamilyStore.AbstractScanIterator rowIterator,
                                      ExtendedFilter filter)

#### getComparator

    public CellNameType getComparator()

#### snapshotWithoutFlush

    public void snapshotWithoutFlush(java.lang.String snapshotName)

#### snapshotWithoutFlush

    public java.util.Set<SSTableReader> snapshotWithoutFlush(java.lang.String snapshotName,
                                                             com.google.common.base.Predicate<SSTableReader> predicate,
                                                             boolean ephemeral)

Parameters:
  `ephemeral` - If this flag is set to true, the snapshot will be cleaned during next startup

#### clearEphemeralSnapshots

    protected static void clearEphemeralSnapshots(Directories directories)

#### getSnapshotSSTableReader

    public Refs<SSTableReader> getSnapshotSSTableReader(java.lang.String tag)
                                                 throws java.io.IOException

Throws:
  `java.io.IOException`

#### snapshot

    public java.util.Set<SSTableReader> snapshot(java.lang.String snapshotName)

Take a snap shot of this columnfamily store.

Parameters:
  `snapshotName` - the name of the associated with the snapshot

#### snapshot

    public java.util.Set<SSTableReader> snapshot(java.lang.String snapshotName,
                                                 com.google.common.base.Predicate<SSTableReader> predicate,
                                                 boolean ephemeral)

Parameters:
  `ephemeral` - If this flag is set to true, the snapshot will be cleaned up during next startup

#### snapshotExists

    public boolean snapshotExists(java.lang.String snapshotName)

#### getSnapshotCreationTime

    public long getSnapshotCreationTime(java.lang.String snapshotName)

#### clearSnapshot

    public void clearSnapshot(java.lang.String snapshotName)

Clear all the snapshots for a given column family.

Parameters:
  `snapshotName` - the user supplied snapshot name. If left empty, all the snapshots will be cleaned.

#### getSnapshotDetails

    public java.util.Map<java.lang.String,Pair<java.lang.Long,java.lang.Long>> getSnapshotDetails()

Returns:
  Return a map of all snapshots to space being used The pair for a snapshot has true size and size on disk.

#### hasUnreclaimedSpace

    public boolean hasUnreclaimedSpace()

#### getRawCachedRow

    public ColumnFamily getRawCachedRow(DecoratedKey key)

Returns:
  the cached row for @param key if it is already present in the cache. That is, unlike getThroughCache, it will not readAndCache the row if it is not present, nor are these calls counted in cache statistics. Note that this WILL cause deserialization of a SerializingCache row, so if all you need to know is whether a row is present or not, use containsCachedRow instead.

#### invalidateRowCache

    public int invalidateRowCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)

#### invalidateCounterCache

    public int invalidateCounterCache(java.util.Collection<Bounds<Token>> boundsToInvalidate)

#### containsCachedRow

    public boolean containsCachedRow(DecoratedKey key)

Returns:
  true if @param key is contained in the row cache

#### invalidateCachedRow

    public void invalidateCachedRow(RowCacheKey key)

#### invalidateCachedRow

    public void invalidateCachedRow(DecoratedKey key)

#### getCachedCounter

    public ClockAndCount getCachedCounter(java.nio.ByteBuffer partitionKey,
                                          CellName cellName)

#### putCachedCounter

    public void putCachedCounter(java.nio.ByteBuffer partitionKey,
                                 CellName cellName,
                                 ClockAndCount clockAndCount)

#### forceMajorCompaction

    public void forceMajorCompaction()
                              throws java.lang.InterruptedException,
                                     java.util.concurrent.ExecutionException

Throws:
  `java.lang.InterruptedException`
  `java.util.concurrent.ExecutionException`

#### forceMajorCompaction

    public void forceMajorCompaction(boolean splitOutput)
                              throws java.lang.InterruptedException,
                                     java.util.concurrent.ExecutionException

Description copied from interface: `ColumnFamilyStoreMBean`
force a major compaction of this column family

Specified by:
  `forceMajorCompaction` in interface `ColumnFamilyStoreMBean`
Parameters:
  `splitOutput` - true if the output of the major compaction should be split in several sstables
Throws:
  `java.lang.InterruptedException`
  `java.util.concurrent.ExecutionException`

#### all

    public static java.lang.Iterable<ColumnFamilyStore> all()

#### keySamples

    public java.lang.Iterable<DecoratedKey> keySamples(Range<Token> range)

#### estimatedKeysForRange

    public long estimatedKeysForRange(Range<Token> range)

#### clearUnsafe

    public void clearUnsafe()

For testing. No effort is made to clear historical or even the current memtables, nor for thread safety. All we do is wipe the sstable containers clean, while leaving the actual data files present on disk. (This allows tests to easily call loadNewSSTables on them.)

#### truncateBlocking

    public void truncateBlocking()

Truncate deletes the entire column family's data with no expensive tombstone creation

#### truncateBlocking

    public void truncateBlocking(boolean takeSnapshot)

Truncate deletes the column family's data with no expensive tombstone creation, optionally snapshotting the data.

Parameters:
  `takeSnapshot` - whether or not to take a snapshot `true` if snapshot should be taken, `false` otherwise

#### runWithCompactionsDisabled

    public <V> V runWithCompactionsDisabled(java.util.concurrent.Callable<V> callable,
                                            boolean interruptValidation)

#### markAllCompacting

    public LifecycleTransaction markAllCompacting(OperationType operationType)

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### disableAutoCompaction

    public void disableAutoCompaction()

#### enableAutoCompaction

    public void enableAutoCompaction()

#### enableAutoCompaction

    public void enableAutoCompaction(boolean waitForFutures)

used for tests - to be able to check things after a minor compaction

Parameters:
  `waitForFutures` - if we should block until autocompaction is done

#### isAutoCompactionDisabled

    public boolean isAutoCompactionDisabled()

Specified by:
  `isAutoCompactionDisabled` in interface `ColumnFamilyStoreMBean`

#### getCompactionStrategy

    public AbstractCompactionStrategy getCompactionStrategy()

#### setCompactionThresholds

    public void setCompactionThresholds(int minThreshold,
                                        int maxThreshold)

Description copied from interface: `ColumnFamilyStoreMBean`
Sets the maximum and maximum number of SSTables in queue before compaction kicks off

Specified by:
  `setCompactionThresholds` in interface `ColumnFamilyStoreMBean`

#### getMinimumCompactionThreshold

    public int getMinimumCompactionThreshold()

Description copied from interface: `ColumnFamilyStoreMBean`
Gets the minimum number of sstables in queue before compaction kicks off

Specified by:
  `getMinimumCompactionThreshold` in interface `ColumnFamilyStoreMBean`

#### setMinimumCompactionThreshold

    public void setMinimumCompactionThreshold(int minCompactionThreshold)

Description copied from interface: `ColumnFamilyStoreMBean`
Sets the minimum number of sstables in queue before compaction kicks off

Specified by:
  `setMinimumCompactionThreshold` in interface `ColumnFamilyStoreMBean`

#### getMaximumCompactionThreshold

    public int getMaximumCompactionThreshold()

Description copied from interface: `ColumnFamilyStoreMBean`
Gets the maximum number of sstables in queue before compaction kicks off

Specified by:
  `getMaximumCompactionThreshold` in interface `ColumnFamilyStoreMBean`

#### setMaximumCompactionThreshold

    public void setMaximumCompactionThreshold(int maxCompactionThreshold)

Description copied from interface: `ColumnFamilyStoreMBean`
Sets the maximum number of sstables in queue before compaction kicks off

Specified by:
  `setMaximumCompactionThreshold` in interface `ColumnFamilyStoreMBean`

#### getMeanColumns

    public int getMeanColumns()

#### estimateKeys

    public long estimateKeys()

Specified by:
  `estimateKeys` in interface `ColumnFamilyStoreMBean`

#### isIndex

    public boolean isIndex()

true if this CFS contains secondary index data

#### concatWithIndexes

    public java.lang.Iterable<ColumnFamilyStore> concatWithIndexes()

#### getBuiltIndexes

    public java.util.List<java.lang.String> getBuiltIndexes()

Description copied from interface: `ColumnFamilyStoreMBean`
Returns a list of the names of the built column indexes for current store

Specified by:
  `getBuiltIndexes` in interface `ColumnFamilyStoreMBean`
Returns:
  list of the index names

#### getUnleveledSSTables

    public int getUnleveledSSTables()

Specified by:
  `getUnleveledSSTables` in interface `ColumnFamilyStoreMBean`
Returns:
  the number of SSTables in L0. Always return 0 if Leveled compaction is not enabled.

#### getSSTableCountPerLevel

    public int[] getSSTableCountPerLevel()

Specified by:
  `getSSTableCountPerLevel` in interface `ColumnFamilyStoreMBean`
Returns:
  sstable count for each level. null unless leveled compaction is used. array index corresponds to level(int[0] is for level 0, ...).

#### isEmpty

    public boolean isEmpty()

#### isRowCacheEnabled

    public boolean isRowCacheEnabled()

#### isCounterCacheEnabled

    public boolean isCounterCacheEnabled()

#### isKeyCacheEnabled

    public boolean isKeyCacheEnabled()

#### discardSSTables

    public void discardSSTables(long truncatedAt)

Discard all SSTables that were created before given timestamp. Caller should first ensure that comapctions have quiesced.

Parameters:
  `truncatedAt` - The timestamp of the truncation (all SSTables before that timestamp are going be marked as compacted)

#### getDroppableTombstoneRatio

    public double getDroppableTombstoneRatio()

Description copied from interface: `ColumnFamilyStoreMBean`
Get the ratio of droppable tombstones to real columns (and non-droppable tombstones)

Specified by:
  `getDroppableTombstoneRatio` in interface `ColumnFamilyStoreMBean`
Returns:
  ratio

#### trueSnapshotsSize

    public long trueSnapshotsSize()

Specified by:
  `trueSnapshotsSize` in interface `ColumnFamilyStoreMBean`
Returns:
  the size of SSTables in "snapshots" subdirectory which aren't live anymore

#### getIfExists

    public static ColumnFamilyStore getIfExists(java.util.UUID cfId)

Returns a ColumnFamilyStore by cfId if it exists, null otherwise Differently from others, this method does not throw exception if the table does not exist.

#### getIfExists

    public static ColumnFamilyStore getIfExists(java.lang.String ksName,
                                                java.lang.String cfName)

Returns a ColumnFamilyStore by ksname and cfname if it exists, null otherwise Differently from others, this method does not throw exception if the keyspace or table does not exist.