Class ByteBufferKeyValue

java.lang.Object
org.apache.hadoop.hbase.ByteBufferExtendedCell
org.apache.hadoop.hbase.ByteBufferKeyValue
All Implemented Interfaces:
Cell, ExtendedCell, HeapSize, RawCell
Direct Known Subclasses:
ByteBufferChunkKeyValue, NoTagsByteBufferKeyValue, SizeCachedByteBufferKeyValue

@Private public class ByteBufferKeyValue extends ByteBufferExtendedCell
This Cell is an implementation of ByteBufferExtendedCell where the data resides in off heap/ on heap ByteBuffer
  • Field Details

  • Constructor Details

  • Method Details

    • getBuffer

    • getOffset

      public int getOffset()
    • getRowArray

      public byte[] getRowArray()
      Description copied from interface: Cell
      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

      public int getRowOffset()
      Description copied from interface: Cell
      Returns Array index of first row byte
    • getRowLength

      public short getRowLength()
      Description copied from interface: Cell
      Returns Number of row bytes. Must be < rowArray.length - offset.
    • getFamilyArray

      public byte[] getFamilyArray()
      Description copied from interface: Cell
      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

      public int getFamilyOffset()
      Description copied from interface: Cell
      Returns Array index of first family byte
    • getFamilyLength

      public byte getFamilyLength()
      Description copied from interface: Cell
      Returns Number of family bytes. Must be < familyArray.length - offset.
    • getFamilyLengthPosition

    • getFamilyLengthPosition

      int getFamilyLengthPosition(int rowLength)
    • getFamilyLength

      byte getFamilyLength(int famLenPos)
    • getQualifierArray

      public byte[] getQualifierArray()
      Description copied from interface: Cell
      Contiguous raw bytes that may start at any index in the containing array.
      Returns:
      The array containing the qualifier bytes.
    • getQualifierOffset

      public int getQualifierOffset()
      Description copied from interface: Cell
      Returns Array index of first qualifier byte
    • getQualifierLength

      public int getQualifierLength()
      Description copied from interface: Cell
      Returns Number of qualifier bytes. Must be < qualifierArray.length - offset.
    • getQualifierLength

      int getQualifierLength(int keyLength, int rlength, int flength)
    • getTimestamp

      public long getTimestamp()
      Description copied from interface: Cell
      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.
    • getTimestamp

      long getTimestamp(int keyLength)
    • getKeyLength

    • getTimestampOffset

      private int getTimestampOffset(int keyLen)
    • getTypeByte

      public byte getTypeByte()
      Description copied from interface: ExtendedCell
      Returns The byte representation of the KeyValue.TYPE of this cell: one of Put, Delete, etc
    • getTypeByte

      byte getTypeByte(int keyLen)
    • getSequenceId

      public long getSequenceId()
      Description copied from interface: ExtendedCell
      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
    • setSequenceId

      public void setSequenceId(long seqId)
      Description copied from interface: ExtendedCell
      Sets with the given seqId.
      Parameters:
      seqId - sequence ID
    • getValueArray

      public byte[] getValueArray()
      Description copied from interface: Cell
      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

      public int getValueOffset()
      Description copied from interface: Cell
      Returns Array index of first value byte
    • getValueLength

      public int getValueLength()
      Description copied from interface: Cell
      Returns Number of value bytes. Must be < valueArray.length - offset.
    • getTagsArray

      public byte[] getTagsArray()
      Description copied from interface: RawCell
      Contiguous raw bytes representing tags that may start at any index in the containing array.
      Returns:
      the tags byte array
    • getTagsOffset

      public int getTagsOffset()
      Description copied from interface: RawCell
      Return the first offset where the tags start in the Cell
    • getTagsLength

      public int getTagsLength()
      Description copied from interface: RawCell
      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.
    • getRowByteBuffer

      Description copied from class: ByteBufferExtendedCell
      Returns The ByteBuffer containing the row bytes.
      Specified by:
      getRowByteBuffer in class ByteBufferExtendedCell
    • getRowPosition

      public int getRowPosition()
      Description copied from class: ByteBufferExtendedCell
      Returns Position in the ByteBuffer where row bytes start
      Specified by:
      getRowPosition in class ByteBufferExtendedCell
    • getFamilyByteBuffer

      Description copied from class: ByteBufferExtendedCell
      Returns The ByteBuffer containing the column family bytes.
      Specified by:
      getFamilyByteBuffer in class ByteBufferExtendedCell
    • getFamilyPosition

      public int getFamilyPosition()
      Description copied from class: ByteBufferExtendedCell
      Returns Position in the ByteBuffer where column family bytes start
      Specified by:
      getFamilyPosition in class ByteBufferExtendedCell
    • getFamilyPosition

      public int getFamilyPosition(int familyLengthPosition)
    • getQualifierByteBuffer

      Description copied from class: ByteBufferExtendedCell
      Returns The ByteBuffer containing the column qualifier bytes.
      Specified by:
      getQualifierByteBuffer in class ByteBufferExtendedCell
    • getQualifierPosition

      public int getQualifierPosition()
      Description copied from class: ByteBufferExtendedCell
      Returns Position in the ByteBuffer where column qualifier bytes start
      Specified by:
      getQualifierPosition in class ByteBufferExtendedCell
    • getQualifierPosition

      int getQualifierPosition(int familyPosition, int familyLength)
    • getValueByteBuffer

      Description copied from class: ByteBufferExtendedCell
      Returns The ByteBuffer containing the value bytes.
      Specified by:
      getValueByteBuffer in class ByteBufferExtendedCell
    • getValuePosition

      public int getValuePosition()
      Description copied from class: ByteBufferExtendedCell
      Returns Position in the ByteBuffer where value bytes start
      Specified by:
      getValuePosition in class ByteBufferExtendedCell
    • getTagsByteBuffer

      Description copied from class: ByteBufferExtendedCell
      Returns The ByteBuffer containing the tag bytes.
      Specified by:
      getTagsByteBuffer in class ByteBufferExtendedCell
    • getTagsPosition

      public int getTagsPosition()
      Description copied from class: ByteBufferExtendedCell
      Returns Position in the ByteBuffer where tag bytes start
      Specified by:
      getTagsPosition in class ByteBufferExtendedCell
    • heapSize

      public long heapSize()
      Description copied from interface: HeapSize
      Return the approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.
    • write

      public int write(OutputStream out, boolean withTags) throws IOException
      Description copied from interface: ExtendedCell
      Write this cell to an OutputStream in a KeyValue format.
      KeyValue format
      <4 bytes keylength> <4 bytes valuelength> <2 bytes rowlength> <row> <1 byte columnfamilylength> <columnfamily> <columnqualifier> <8 bytes timestamp> <1 byte keytype> <value> <2 bytes tagslength> <tags>
      Parameters:
      out - Stream to which cell has to be written
      withTags - Whether to write tags.
      Returns:
      how many bytes are written.
      Throws:
      IOException
    • getSerializedSize

      public int getSerializedSize(boolean withTags)
      Description copied from interface: ExtendedCell
      KeyValue format

      <4 bytes keylength> <4 bytes valuelength> <2 bytes rowlength> <row> <1 byte columnfamilylength> <columnfamily> <columnqualifier> <8 bytes timestamp> <1 byte keytype> <value> <2 bytes tagslength> <tags>

      Parameters:
      withTags - Whether to write tags.
      Returns:
      Bytes count required to serialize this Cell in a KeyValue format.
    • getSerializedSize

      public int getSerializedSize()
      Description copied from interface: ExtendedCell
      Returns Serialized size (defaults to include tag length).
    • write

      public void write(ByteBuffer buf, int offset)
      Description copied from interface: ExtendedCell
      Write this Cell into the given buf's offset in a KeyValue format.
      Parameters:
      buf - The buffer where to write the Cell.
      offset - The offset within buffer, to write the Cell.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setTimestamp

      public void setTimestamp(long ts) throws IOException
      Description copied from interface: ExtendedCell
      Sets with the given timestamp.
      Parameters:
      ts - timestamp
      Throws:
      IOException
    • getTimestampOffset

      private int getTimestampOffset()
    • setTimestamp

      public void setTimestamp(byte[] ts) throws IOException
      Description copied from interface: ExtendedCell
      Sets with the given timestamp.
      Parameters:
      ts - buffer containing the timestamp value
      Throws:
      IOException
    • deepClone

      Description copied from interface: ExtendedCell
      Does a deep copy of the contents to a new memory area and returns it as a new cell.
      Returns:
      The deep cloned cell
    • equals

      public boolean equals(Object other)
      Needed doing 'contains' on List. Only compares the key portion, not the value.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      In line with equals(Object), only uses the key portion, not the value.
      Overrides:
      hashCode in class Object
    • calculateHashForKey