org.apache.cassandra.db

## Class CounterColumn

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

- All Implemented Interfaces:
    IColumn, OnDiskAtom

      public class CounterColumn
      extends Column

  A column that represents a partitioned counter.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.cassandra.db.OnDiskAtom

      `OnDiskAtom.Serializer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `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

    Constructors
    Constructor and Description
    `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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static CounterColumn` | `create(java.nio.ByteBuffer name, java.nio.ByteBuffer value, long timestamp, long timestampOfLastDelete, IColumnSerializer.Flag flag)`
    `int` | `dataSize()` the size of user-provided data, not including internal overhead
    `IColumn` | `diff(IColumn column)`
    `boolean` | `equals(java.lang.Object o)`
    `java.lang.String` | `getString(AbstractType<?> comparator)`
    `boolean` | `hasCounterId(CounterId id)` Check if a given counterId is found in this CounterColumn context.
    `int` | `hashCode()`
    `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` | `serializedSize(TypeSizes typeSizes)`
    `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, create, getLocalDeletionTime, getMarkedForDeleteAt, getSubColumn, getSubColumns, hasIrrelevantData, isLive, isMarkedForDelete, maxTimestamp, minTimestamp, mostRecentLiveChangeAt, mostRecentNonGCableChangeAt, name, onDiskSerializer, reconcile, serializedSizeForSSTable, 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()

    - #### dataSize

          public int dataSize()

      Description copied from interface: `IColumn`
      the size of user-provided data, not including internal overhead
      Specified by:
        `dataSize` in interface `IColumn`
      Overrides:
        `dataSize` in class `Column`

    - #### serializedSize

          public int serializedSize(TypeSizes typeSizes)

      Specified by:
        `serializedSize` in interface `OnDiskAtom`
      Overrides:
        `serializedSize` 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 `OnDiskAtom`
      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`
      Specified by:
        `validateFields` in interface `OnDiskAtom`
      Overrides:
        `validateFields` in class `Column`
      Throws:
        `MarshalException`

    - #### hasCounterId

          public boolean hasCounterId(CounterId id)

      Check if a given counterId 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 © 2014 The Apache Software Foundation