## org.apache.cassandra.db
Class CounterColumn

    java.lang.Object
      org.apache.cassandra.db.Column
          org.apache.cassandra.db.CounterColumn

All Implemented Interfaces:
  IColumn

    public class CounterColumn

extends Column

A column that represents a partitioned counter.

Field Summary
`protected static CounterContext` `contextManager`

Fields inherited from class org.apache.cassandra.db.Column
`name, timestamp, value`

Fields inherited from interface org.apache.cassandra.db.IColumn
`MAX_NAME_LENGTH`

Constructor Summary
`CounterColumn(java.nio.ByteBuffer name, java.nio.ByteBuffer value, long timestamp)`
`CounterColumn(java.nio.ByteBuffer name, java.nio.ByteBuffer value, long timestamp, long timestampOfLastDelete)`
`CounterColumn(java.nio.ByteBuffer name, long value, long timestamp)`
`CounterColumn(java.nio.ByteBuffer name, long value, long timestamp, long timestampOfLastDelete)`

Method Summary
`static CounterColumn` `create(java.nio.ByteBuffer name, java.nio.ByteBuffer value, long timestamp, long timestampOfLastDelete, IColumnSerializer.Flag flag)`
`IColumn` `diff(IColumn column)`
`boolean` `equals(java.lang.Object o)`
`java.lang.String` `getString(AbstractType<?> comparator)`
`int` `hashCode()`
`boolean` `hasNodeId(NodeId id)` Check if a given nodeId is found in this CounterColumn context.
`IColumn` `localCopy(ColumnFamilyStore cfs)` clones the column for the row cache, interning column names and making copies of other underlying byte buffers
`IColumn` `localCopy(ColumnFamilyStore cfs, Allocator allocator)` clones the column for the memtable, interning column names and making copies of other underlying byte buffers.
`IColumn` `markDeltaToBeCleared()`
`static void` `mergeAndRemoveOldShards(DecoratedKey key, ColumnFamily cf, int gcBefore, int mergeBefore)`
`static void` `mergeAndRemoveOldShards(DecoratedKey key, ColumnFamily cf, int gcBefore, int mergeBefore, boolean sendToOtherReplica)` There is two phase to the removal of old shards.
`IColumn` `reconcile(IColumn column, Allocator allocator)`
`int` `serializationFlags()`
`int` `size()`
`long` `timestampOfLastDelete()`
`long` `total()`
`void` `updateDigest(java.security.MessageDigest digest)`
`void` `validateFields(CFMetaData metadata)`

Methods inherited from class org.apache.cassandra.db.Column
`addColumn, addColumn, create, create, create, create, create, getLocalDeletionTime, getMarkedForDeleteAt, getSubColumn, getSubColumns, hasIrrelevantData, isLive, isMarkedForDelete, maxTimestamp, mostRecentLiveChangeAt, mostRecentNonGCableChangeAt, name, reconcile, serializedSize, serializer, timestamp, validateName, value`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### contextManager

    protected static final CounterContext contextManager

Constructor Detail

### CounterColumn

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

### CounterColumn

    public CounterColumn(java.nio.ByteBuffer name,
                         long value,
                         long timestamp,
                         long timestampOfLastDelete)

### CounterColumn

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

### CounterColumn

    public CounterColumn(java.nio.ByteBuffer name,
                         java.nio.ByteBuffer value,
                         long timestamp,
                         long timestampOfLastDelete)

Method Detail

### create

    public static CounterColumn create(java.nio.ByteBuffer name,
                                       java.nio.ByteBuffer value,
                                       long timestamp,
                                       long timestampOfLastDelete,
                                       IColumnSerializer.Flag flag)

### timestampOfLastDelete

    public long timestampOfLastDelete()

### total

    public long total()

### size

    public int size()

  Specified by:
    `size` in interface `IColumn`
  Overrides:
    `size` in class `Column`

### diff

    public IColumn diff(IColumn column)

  Specified by:
    `diff` in interface `IColumn`
  Overrides:
    `diff` in class `Column`

### updateDigest

    public void updateDigest(java.security.MessageDigest digest)

  Specified by:
    `updateDigest` in interface `IColumn`
  Overrides:
    `updateDigest` in class `Column`

### reconcile

    public IColumn reconcile(IColumn column,
                             Allocator allocator)

  Specified by:
    `reconcile` in interface `IColumn`
  Overrides:
    `reconcile` in class `Column`

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `Column`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Column`

### localCopy

    public IColumn localCopy(ColumnFamilyStore cfs)

  Description copied from interface: `IColumn`
  clones the column for the row cache, interning column names and making copies of other underlying byte buffers

  Specified by:
    `localCopy` in interface `IColumn`
  Overrides:
    `localCopy` in class `Column`

### localCopy

    public IColumn localCopy(ColumnFamilyStore cfs,
                             Allocator allocator)

  Description copied from interface: `IColumn`
  clones the column for the memtable, interning column names and making copies of other underlying byte buffers. Unlike the other localCopy, this uses Allocator to allocate values in contiguous memory regions, which helps avoid heap fragmentation.

  Specified by:
    `localCopy` in interface `IColumn`
  Overrides:
    `localCopy` in class `Column`

### getString

    public java.lang.String getString(AbstractType<?> comparator)

  Specified by:
    `getString` in interface `IColumn`
  Overrides:
    `getString` in class `Column`

### serializationFlags

    public int serializationFlags()

  Specified by:
    `serializationFlags` in interface `IColumn`
  Overrides:
    `serializationFlags` in class `Column`

### validateFields

    public void validateFields(CFMetaData metadata)
                        throws MarshalException

  Specified by:
    `validateFields` in interface `IColumn`
  Overrides:
    `validateFields` in class `Column`
  Throws:
    `MarshalException`

### hasNodeId

    public boolean hasNodeId(NodeId id)

  Check if a given nodeId is found in this CounterColumn context.

### mergeAndRemoveOldShards

    public static void mergeAndRemoveOldShards(DecoratedKey key,
                                               ColumnFamily cf,
                                               int gcBefore,
                                               int mergeBefore)

### mergeAndRemoveOldShards

    public static void mergeAndRemoveOldShards(DecoratedKey key,
                                               ColumnFamily cf,
                                               int gcBefore,
                                               int mergeBefore,
                                               boolean sendToOtherReplica)

  There is two phase to the removal of old shards. First phase: we merge the old shard value to the current shard and 'nulify' the old one. We then send the counter context with the old shard nulified to all other replica. Second phase: once an old shard has been nulified for longer than gc_grace (to be sure all other replica had been aware of the merge), we simply remove that old shard from the context (it's value is 0). This method does both phases. (Note that the sendToOtherReplica flag is here only to facilitate testing. It should be true in real code so use the method above preferably)

### markDeltaToBeCleared

    public IColumn markDeltaToBeCleared()

Copyright © 2013 The Apache Software Foundation