Interface Cell

All Superinterfaces:
HeapSize
All Known Subinterfaces:
ExtendedCell, RawCell
All Known Implementing Classes:
BufferedDataBlockEncoder.OffheapDecodedExtendedCell, BufferedDataBlockEncoder.OnheapDecodedCell, ByteBufferChunkKeyValue, ByteBufferExtendedCell, ByteBufferKeyOnlyKeyValue, ByteBufferKeyValue, IndividualBytesFieldCell, KeyOnlyFilter.KeyOnlyByteBufferExtendedCell, KeyOnlyFilter.KeyOnlyCell, KeyValue, KeyValue.KeyOnlyKeyValue, MapReduceExtendedCell, Mutation.CellWrapper, NoTagByteBufferChunkKeyValue, NoTagsByteBufferKeyValue, NoTagsKeyValue, PrivateCellUtil.EmptyByteBufferExtendedCell, PrivateCellUtil.EmptyCell, PrivateCellUtil.FirstOnRowByteBufferExtendedCell, PrivateCellUtil.FirstOnRowCell, PrivateCellUtil.FirstOnRowColByteBufferExtendedCell, PrivateCellUtil.FirstOnRowColCell, PrivateCellUtil.FirstOnRowColTSByteBufferExtendedCell, PrivateCellUtil.FirstOnRowColTSCell, PrivateCellUtil.FirstOnRowDeleteFamilyCell, PrivateCellUtil.LastOnRowByteBufferExtendedCell, PrivateCellUtil.LastOnRowCell, PrivateCellUtil.LastOnRowColByteBufferExtendedCell, PrivateCellUtil.LastOnRowColCell, PrivateCellUtil.TagRewriteByteBufferExtendedCell, PrivateCellUtil.TagRewriteCell, PrivateCellUtil.ValueAndTagRewriteByteBufferExtendedCell, PrivateCellUtil.ValueAndTagRewriteCell, SizeCachedByteBufferKeyValue, SizeCachedKeyValue, SizeCachedNoTagsByteBufferKeyValue, SizeCachedNoTagsKeyValue

@Public public interface Cell extends HeapSize
The unit of storage in HBase consisting of the following fields:
 1) row
 2) column family
 3) column qualifier
 4) timestamp
 5) type
 6) MVCC version
 7) value
 

Uniqueness is determined by the combination of row, column family, column qualifier, timestamp, and type.

The natural comparator will perform a bitwise comparison on row, column family, and column qualifier. Less intuitively, it will then treat the greater timestamp as the lesser value with the goal of sorting newer cells first.

Cell implements Comparable<Cell> which is only meaningful when comparing to other keys in the same table. It uses CellComparator which does not work on the -ROOT- and hbase:meta tables.

In the future, we may consider adding a boolean isOnHeap() method and a getValueBuffer() method that can be used to pass a value directly from an off-heap ByteBuffer to the network without copying into an on-heap byte[].

Historic note: the original Cell implementation (KeyValue) requires that all fields be encoded as consecutive bytes in the same byte[], whereas this interface allows fields to reside in separate byte[]'s.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    The valid types for user to build the cell.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Contiguous bytes composed of legal HDFS filename characters which may start at any index in the containing array.
    byte
    Returns Number of family bytes.
    int
    Returns Array index of first family byte
    byte[]
    Contiguous raw bytes that may start at any index in the containing array.
    int
    Returns Number of qualifier bytes.
    int
    Returns Array index of first qualifier byte
    byte[]
    Contiguous raw bytes that may start at any index in the containing array.
    short
    Returns Number of row bytes.
    int
    Returns Array index of first row byte
    long
    Deprecated.
    As of HBase-2.0.
    int
    Returns Serialized size (defaults to include tag length if has some tags).
    byte[]
    Deprecated.
    As of HBase-2.0.
    int
    Deprecated.
    As of HBase-2.0.
    int
    Deprecated.
    As of HBase-2.0.
    long
    Return a long value representing time at which this cell was "Put" into the row.
    default Cell.Type
    Returns the type of cell in a human readable format using Cell.Type.
    byte
    Deprecated.
    As of HBase-2.0.
    byte[]
    Contiguous raw bytes that may start at any index in the containing array.
    int
    Returns Number of value bytes.
    int
    Returns Array index of first value byte

    Methods inherited from interface org.apache.hadoop.hbase.io.HeapSize

    heapSize
  • Method Details

    • getRowArray

      byte[] getRowArray()
      Contiguous raw bytes that may start at any index in the containing array. Max length is Short.MAX_VALUE which is 32,767 bytes.
      Returns:
      The array containing the row bytes.
    • getRowOffset

      Returns Array index of first row byte
    • getRowLength

      short getRowLength()
      Returns Number of row bytes. Must be < rowArray.length - offset.
    • getFamilyArray

      byte[] getFamilyArray()
      Contiguous bytes composed of legal HDFS filename characters which may start at any index in the containing array. Max length is Byte.MAX_VALUE, which is 127 bytes.
      Returns:
      the array containing the family bytes.
    • getFamilyOffset

      Returns Array index of first family byte
    • getFamilyLength

      Returns Number of family bytes. Must be < familyArray.length - offset.
    • getQualifierArray

      Contiguous raw bytes that may start at any index in the containing array.
      Returns:
      The array containing the qualifier bytes.
    • getQualifierOffset

      Returns Array index of first qualifier byte
    • getQualifierLength

      Returns Number of qualifier bytes. Must be < qualifierArray.length - offset.
    • getTimestamp

      long getTimestamp()
      Return a long value representing time at which this cell was "Put" into the row. Typically represents the time of insertion, but can be any value from 0 to Long.MAX_VALUE.
    • getTypeByte

      Deprecated.
      As of HBase-2.0. Will be removed in HBase-3.0. Use getType().
      Return the byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
    • getSequenceId

      Deprecated.
      As of HBase-2.0. Will be removed in HBase-3.0.
      A region-specific unique monotonically increasing sequence ID given to each Cell. It always exists for cells in the memstore but is not retained forever. It will be kept for HConstants.KEEP_SEQID_PERIOD days, but generally becomes irrelevant after the cell's row is no longer involved in any operations that require strict consistency.
      Returns:
      seqId (always > 0 if exists), or 0 if it no longer exists
    • getValueArray

      byte[] getValueArray()
      Contiguous raw bytes that may start at any index in the containing array. Max length is Integer.MAX_VALUE which is 2,147,483,647 bytes.
      Returns:
      The array containing the value bytes.
    • getValueOffset

      Returns Array index of first value byte
    • getValueLength

      Returns Number of value bytes. Must be < valueArray.length - offset.
    • getSerializedSize

      Returns Serialized size (defaults to include tag length if has some tags).
    • getTagsArray

      Deprecated.
      As of HBase-2.0. Will be removed in HBase-3.0. Tags are are now internal.
      Contiguous raw bytes representing tags that may start at any index in the containing array.
      Returns:
      the tags byte array
    • getTagsOffset

      Deprecated.
      As of HBase-2.0. Will be removed in HBase-3.0. Tags are are now internal.
      Return the first offset where the tags start in the Cell
    • getTagsLength

      Deprecated.
      As of HBase-2.0. Will be removed in HBase-3.0. Tags are are now internal.
      HBase internally uses 2 bytes to store tags length in Cell. As the tags length is always a non-negative number, to make good use of the sign bit, the max of tags length is defined 2 * Short.MAX_VALUE + 1 = 65535. As a result, the return type is int, because a short is not capable of handling that. Please note that even if the return type is int, the max tags length is far less than Integer.MAX_VALUE.
      Returns:
      the total length of the tags in the Cell.
    • getType

      default Cell.Type getType()
      Returns the type of cell in a human readable format using Cell.Type. Note : This does not expose the internal types of Cells like KeyValue.Type.Maximum and KeyValue.Type.Minimum
      Returns:
      The data type this cell: one of Put, Delete, etc