org.apache.cassandra.db

## Class ColumnFamily

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

All Implemented Interfaces:
  java.lang.Iterable<Column>, IRowCacheEntry

Direct Known Subclasses:
  AbstractThreadUnsafeSortedColumns, AtomicSortedColumns

    public abstract class ColumnFamily
    extends java.lang.Object
    implements java.lang.Iterable<Column>, IRowCacheEntry

A sorted map of columns. This represents the backing map of a colum family. Whether the implementation is thread safe or not is left to the implementing classes.

### Nested Class Summary

Nested Classes
`static class` `ColumnFamily.Factory<T extends ColumnFamily>`

### Field Summary

Fields
`protected CFMetaData` `metadata`
`static ColumnFamilySerializer` `serializer`

### Constructor Summary

Constructors
`protected` `ColumnFamily(CFMetaData metadata)`

### Method Summary

Methods
`void` `addAll(ColumnFamily cf, Allocator allocator)`
`abstract void` `addAll(ColumnFamily cm, Allocator allocator, com.google.common.base.Function<Column,Column> transformation)` Adds all the columns of a given column map to this column map.
`void` `addAtom(OnDiskAtom atom)`
`void` `addColumn(java.nio.ByteBuffer name, java.nio.ByteBuffer value, long timestamp)`
`void` `addColumn(java.nio.ByteBuffer name, java.nio.ByteBuffer value, long timestamp, int timeToLive)`
`void` `addColumn(Column column)`
`abstract void` `addColumn(Column column, Allocator allocator)` Adds a column to this column map.
`void` `addCounter(java.nio.ByteBuffer name, long value)`
`void` `addIfRelevant(Column column, DeletionInfo.InOrderTester tester, int gcBefore)`
`void` `addTombstone(java.nio.ByteBuffer name, java.nio.ByteBuffer localDeletionTime, long timestamp)`
`void` `addTombstone(java.nio.ByteBuffer name, int localDeletionTime, long timestamp)`
`java.util.Map<java.nio.ByteBuffer,java.nio.ByteBuffer>` `asMap()`
`abstract void` `clear()` Clear this column family, removing all columns and deletion info.
`abstract ColumnFamily` `cloneMe()` Clones the column map.
`ColumnFamily` `cloneMeShallow()`
`<T extends ColumnFamily> T` `cloneMeShallow(ColumnFamily.Factory<T> factory, boolean reversedInsertOrder)`
`long` `dataSize()`
`void` `delete(ColumnFamily columns)` If `columns` has any tombstones (top-level or range tombstones), they will be applied to this set of columns.
`abstract void` `delete(DeletionInfo info)`
`abstract void` `delete(DeletionTime deletionTime)`
`protected abstract void` `delete(RangeTombstone tombstone)`
`abstract DeletionInfo` `deletionInfo()`
`ColumnFamily` `diff(ColumnFamily cfComposite)`
`static ColumnFamily` `diff(ColumnFamily cf1, ColumnFamily cf2)`
`static java.nio.ByteBuffer` `digest(ColumnFamily cf)`
`boolean` `equals(java.lang.Object o)`
`static ColumnFamily` `fromBytes(java.nio.ByteBuffer bytes)`
`abstract Column` `getColumn(java.nio.ByteBuffer name)` Get a column given its name, returning null if the column is not present.
`abstract int` `getColumnCount()` Returns the number of columns in this map.
`abstract java.lang.Iterable<java.nio.ByteBuffer>` `getColumnNames()` Returns an iterable with the names of columns in this column map in the same order as the underlying columns themselves.
`ColumnStats` `getColumnStats()`
`AbstractType<?>` `getComparator()`
`abstract ColumnFamily.Factory` `getFactory()` Returns the factory used for this ISortedColumns implementation.
`abstract java.util.Collection<Column>` `getReverseSortedColumns()` Returns the columns of this column map as a collection.
`abstract java.util.Collection<Column>` `getSortedColumns()` Returns the columns of this column map as a collection.
`ColumnFamilyType` `getType()`
`int` `hashCode()`
`boolean` `hasIrrelevantData(int gcBefore)`
`boolean` `hasOnlyTombstones(long now)`
`java.util.UUID` `id()`
`DeletionInfo.InOrderTester` `inOrderDeletionTester()` Returns a `DeletionInfo.InOrderTester` for the deletionInfo() of this column family.
`boolean` `isEmpty()` Returns true if this contains no columns or deletion info
`abstract boolean` `isInsertReversed()` Returns if this map only support inserts in reverse order.
`boolean` `isMarkedForDelete()`
`java.util.Iterator<Column>` `iterator()`
`abstract java.util.Iterator<Column>` `iterator(ColumnSlice[] slices)` Returns an iterator over the columns of this map that returns only the matching @param slices.
`long` `maxTimestamp()`
`CFMetaData` `metadata()`
`abstract void` `purgeTombstones(int gcBefore)` Purges top-level and range tombstones whose localDeletionTime is older than gcBefore.
`abstract boolean` `replace(Column oldColumn, Column newColumn)` Replace oldColumn if present by newColumn.
`void` `resolve(ColumnFamily cf)`
`void` `resolve(ColumnFamily cf, Allocator allocator)`
`java.util.Iterator<Column>` `reverseIterator()`
`abstract java.util.Iterator<Column>` `reverseIterator(ColumnSlice[] slices)` Returns a reversed iterator over the columns of this map that returns only the matching @param slices.
`abstract void` `setDeletionInfo(DeletionInfo info)`
`java.nio.ByteBuffer` `toBytes()`
`java.lang.String` `toString()`
`void` `updateDigest(java.security.MessageDigest digest)`

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

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

### Field Detail

#### serializer

    public static final ColumnFamilySerializer serializer

#### metadata

    protected final CFMetaData metadata

### Constructor Detail

#### ColumnFamily

    protected ColumnFamily(CFMetaData metadata)

### Method Detail

#### cloneMeShallow

    public <T extends ColumnFamily> T cloneMeShallow(ColumnFamily.Factory<T> factory,
                                            boolean reversedInsertOrder)

#### cloneMeShallow

    public ColumnFamily cloneMeShallow()

#### getType

    public ColumnFamilyType getType()

#### cloneMe

    public abstract ColumnFamily cloneMe()

Clones the column map.

#### id

    public java.util.UUID id()

#### metadata

    public CFMetaData metadata()

Returns:
  The CFMetaData for this row

#### addIfRelevant

    public void addIfRelevant(Column column,
                     DeletionInfo.InOrderTester tester,
                     int gcBefore)

#### addColumn

    public void addColumn(Column column)

#### addColumn

    public void addColumn(java.nio.ByteBuffer name,
                 java.nio.ByteBuffer value,
                 long timestamp)

#### addColumn

    public void addColumn(java.nio.ByteBuffer name,
                 java.nio.ByteBuffer value,
                 long timestamp,
                 int timeToLive)

#### addCounter

    public void addCounter(java.nio.ByteBuffer name,
                  long value)

#### addTombstone

    public void addTombstone(java.nio.ByteBuffer name,
                    java.nio.ByteBuffer localDeletionTime,
                    long timestamp)

#### addTombstone

    public void addTombstone(java.nio.ByteBuffer name,
                    int localDeletionTime,
                    long timestamp)

#### addAtom

    public void addAtom(OnDiskAtom atom)

#### clear

    public abstract void clear()

Clear this column family, removing all columns and deletion info.

#### inOrderDeletionTester

    public DeletionInfo.InOrderTester inOrderDeletionTester()

Returns a `DeletionInfo.InOrderTester` for the deletionInfo() of this column family. Please note that for ThreadSafe implementation of ColumnFamily, this tester will remain valid even if new tombstones are added to this ColumnFamily *as long as said addition is done in comparator order*. For AtomicSortedColumns, the tester will correspond to the state of when this method is called.

#### getFactory

    public abstract ColumnFamily.Factory getFactory()

Returns the factory used for this ISortedColumns implementation.

#### deletionInfo

    public abstract DeletionInfo deletionInfo()

#### setDeletionInfo

    public abstract void setDeletionInfo(DeletionInfo info)

#### delete

    public abstract void delete(DeletionInfo info)

#### delete

    public abstract void delete(DeletionTime deletionTime)

#### delete

    protected abstract void delete(RangeTombstone tombstone)

#### purgeTombstones

    public abstract void purgeTombstones(int gcBefore)

Purges top-level and range tombstones whose localDeletionTime is older than gcBefore.

Parameters:
  `gcBefore` - a timestamp (in seconds) before which tombstones should be purged

#### addColumn

    public abstract void addColumn(Column column,
                 Allocator allocator)

Adds a column to this column map. If a column with the same name is already present in the map, it will be replaced by the newly added column.

#### addAll

    public abstract void addAll(ColumnFamily cm,
              Allocator allocator,
              com.google.common.base.Function<Column,Column> transformation)

Adds all the columns of a given column map to this column map. This is equivalent to: `for (Column c : cm) addColumn(c, ...);` but is potentially faster.

#### replace

    public abstract boolean replace(Column oldColumn,
                  Column newColumn)

Replace oldColumn if present by newColumn. Returns true if oldColumn was present and thus replaced. oldColumn and newColumn should have the same name.

#### getColumn

    public abstract Column getColumn(java.nio.ByteBuffer name)

Get a column given its name, returning null if the column is not present.

#### getColumnNames

    public abstract java.lang.Iterable<java.nio.ByteBuffer> getColumnNames()

Returns an iterable with the names of columns in this column map in the same order as the underlying columns themselves.

#### getSortedColumns

    public abstract java.util.Collection<Column> getSortedColumns()

Returns the columns of this column map as a collection. The columns in the returned collection should be sorted as the columns in this map.

#### getReverseSortedColumns

    public abstract java.util.Collection<Column> getReverseSortedColumns()

Returns the columns of this column map as a collection. The columns in the returned collection should be sorted in reverse order of the columns in this map.

#### getColumnCount

    public abstract int getColumnCount()

Returns the number of columns in this map.

#### isEmpty

    public boolean isEmpty()

Returns true if this contains no columns or deletion info

#### iterator

    public abstract java.util.Iterator<Column> iterator(ColumnSlice[] slices)

Returns an iterator over the columns of this map that returns only the matching @param slices. The provided slices must be in order and must be non-overlapping.

#### reverseIterator

    public abstract java.util.Iterator<Column> reverseIterator(ColumnSlice[] slices)

Returns a reversed iterator over the columns of this map that returns only the matching @param slices. The provided slices must be in reversed order and must be non-overlapping.

#### isInsertReversed

    public abstract boolean isInsertReversed()

Returns if this map only support inserts in reverse order.

#### delete

    public void delete(ColumnFamily columns)

If `columns` has any tombstones (top-level or range tombstones), they will be applied to this set of columns.

#### addAll

    public void addAll(ColumnFamily cf,
              Allocator allocator)

#### diff

    public ColumnFamily diff(ColumnFamily cfComposite)

#### dataSize

    public long dataSize()

#### maxTimestamp

    public long maxTimestamp()

#### hashCode

    public int hashCode()

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

#### equals

    public boolean equals(java.lang.Object o)

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

#### toString

    public java.lang.String toString()

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

#### digest

    public static java.nio.ByteBuffer digest(ColumnFamily cf)

#### updateDigest

    public void updateDigest(java.security.MessageDigest digest)

#### diff

    public static ColumnFamily diff(ColumnFamily cf1,
                    ColumnFamily cf2)

#### resolve

    public void resolve(ColumnFamily cf)

#### resolve

    public void resolve(ColumnFamily cf,
               Allocator allocator)

#### getColumnStats

    public ColumnStats getColumnStats()

#### isMarkedForDelete

    public boolean isMarkedForDelete()

#### getComparator

    public AbstractType<?> getComparator()

Returns:
  the comparator whose sorting order the contained columns conform to

#### hasOnlyTombstones

    public boolean hasOnlyTombstones(long now)

#### iterator

    public java.util.Iterator<Column> iterator()

Specified by:
  `iterator` in interface `java.lang.Iterable<Column>`

#### reverseIterator

    public java.util.Iterator<Column> reverseIterator()

#### hasIrrelevantData

    public boolean hasIrrelevantData(int gcBefore)

#### asMap

    public java.util.Map<java.nio.ByteBuffer,java.nio.ByteBuffer> asMap()

#### fromBytes

    public static ColumnFamily fromBytes(java.nio.ByteBuffer bytes)

#### toBytes

    public java.nio.ByteBuffer toBytes()