Class Mutation

All Implemented Interfaces:
Comparable<Row>, CellScannable, Attributes, Row, HeapSize
Direct Known Subclasses:
Append, Delete, Increment, Put

@Public public abstract class Mutation extends OperationWithAttributes implements Row, CellScannable, HeapSize
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    The attribute for storing the list of clusters that have consumed the change.
    protected Durability
     
    protected NavigableMap<byte[],List<Cell>>
     
    static final long
     
    private static final String
    The attribute for storing TTL for the result of the mutation.
    private static final String
     
    protected byte[]
     
    protected long
     

    Fields inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes

    ID_ATRIBUTE

    Fields inherited from interface org.apache.hadoop.hbase.client.Row

    COMPARATOR
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    empty construction.
    protected
    Mutation(byte[] row, long ts, NavigableMap<byte[],List<Cell>> familyMap)
    Construct the mutation with user defined data.
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) Mutation
    add(Cell cell)
     
    Returns A CellScanner over the contained Cells
    private static Map<String,Object>
     
    (package private) static byte[]
    checkRow(byte[] row)
     
    (package private) static byte[]
    checkRow(byte[] row, int offset, int length)
     
    (package private) static void
     
    int
    Deprecated.
    As of release 2.0.0, this will be removed in HBase 3.0.0.
    (package private) KeyValue
    createPutKeyValue(byte[] family, byte[] qualifier, long ts, byte[] value)
    Create a KeyValue with this objects row key and the Put identifier.
    (package private) KeyValue
    createPutKeyValue(byte[] family, byte[] qualifier, long ts, byte[] value, Tag[] tags)
    Create a KeyValue with this objects row key and the Put identifier.
    (package private) KeyValue
    createPutKeyValue(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value, Tag[] tags)
    Create a KeyValue with this objects row key and the Put identifier.
    protected long
    Subclasses should override this method to add the heap size of their own fields.
    get(byte[] family, byte[] qualifier)
    Returns a list of all KeyValue objects with matching column family and qualifier.
    byte[]
    Returns The serialized ACL for this operation, or null if none
    (package private) List<Cell>
    getCellList(byte[] family)
    Creates an empty list if one doesn't exist for the given column family or else it returns the associated list of Cell objects.
    Returns CellVisibility associated with cells in this Mutation.
    Returns the set of clusterIds that have consumed the mutation
    Get the current durability
    Method for retrieving the put's familyMap
    Compile the column family (i.e.
    byte[]
    Method for retrieving the delete's row
    long
    Method for retrieving the timestamp.
    long
    Deprecated.
    As of release 2.0.0, this will be removed in HBase 3.0.0.
    long
    Return the TTL requested for the result of the mutation, in milliseconds.
    boolean
    has(byte[] family, byte[] qualifier)
    A convenience method to determine if this object's familyMap contains a value assigned to the given family & qualifier.
    boolean
    has(byte[] family, byte[] qualifier, byte[] value)
    A convenience method to determine if this object's familyMap contains a value assigned to the given family, qualifier and timestamp.
    boolean
    has(byte[] family, byte[] qualifier, long ts)
    A convenience method to determine if this object's familyMap contains a value assigned to the given family, qualifier and timestamp.
    boolean
    has(byte[] family, byte[] qualifier, long ts, byte[] value)
    A convenience method to determine if this object's familyMap contains the given value assigned to the given family, qualifier and timestamp.
    protected boolean
    has(byte[] family, byte[] qualifier, long ts, byte[] value, boolean ignoreTS, boolean ignoreValue)
    Private method to determine if this object's familyMap contains the given value assigned to the given family, qualifier and timestamp, respecting the 2 boolean arguments.
    long
    Returns Calculate what Mutation adds to class heap size.
    boolean
    Method to check if the familyMap is empty
    protected boolean
    Returns current value for returnResults
    int
    Returns the number of different families
    setACL(String user, Permission perms)
    Set the ACL for this operation.
    Set the ACL for this operation.
    Sets the visibility expression associated with cells in this Mutation.
    setClusterIds(List<UUID> clusterIds)
    Marks that the clusters with the given clusterIds have consumed the mutation
    Set the durability for this mutation
    Deprecated.
    As of release 2.0.0, this will be removed in HBase 3.0.0.
    protected Mutation
    setReturnResults(boolean returnResults)
     
    setTimestamp(long timestamp)
    Set the timestamp of the delete.
    setTTL(long ttl)
    Set the TTL desired for the result of the mutation, in milliseconds.
    int
    Number of KeyValues carried by this Mutation.
    private static CellVisibility
    toCellVisibility(byte[] protoBytes)
    Convert a protocol buffer CellVisibility bytes to a client CellVisibility
    private static CellVisibility
    toCellVisibility(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CellVisibility proto)
    Convert a protocol buffer CellVisibility to a client CellVisibility
    (package private) static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CellVisibility
    Create a protocol buffer CellVisibility based on a client CellVisibility.
    toMap(int maxCols)
    Compile the details beyond the scope of getFingerprint (row, columns, timestamps, etc.) into a Map along with the fingerprinted information.

    Methods inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes

    getAttribute, getAttributeSize, getAttributesMap, getId, getPriority, setAttribute, setId, setPriority

    Methods inherited from class org.apache.hadoop.hbase.client.Operation

    toJSON, toJSON, toMap, toString, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Mutation

      protected Mutation()
      empty construction. We need this empty construction to keep binary compatibility.
    • Mutation

      protected Mutation(Mutation clone)
    • Mutation

      protected Mutation(byte[] row, long ts, NavigableMap<byte[],List<Cell>> familyMap)
      Construct the mutation with user defined data.
      Parameters:
      row - row. CAN'T be null
      ts - timestamp
      familyMap - the map to collect all cells internally. CAN'T be null
  • Method Details

    • cellScanner

      Description copied from interface: CellScannable
      Returns A CellScanner over the contained Cells
      Specified by:
      cellScanner in interface CellScannable
    • getCellList

      List<Cell> getCellList(byte[] family)
      Creates an empty list if one doesn't exist for the given column family or else it returns the associated list of Cell objects.
      Parameters:
      family - column family
      Returns:
      a list of Cell objects, returns an empty list if one doesn't exist.
    • createPutKeyValue

      KeyValue createPutKeyValue(byte[] family, byte[] qualifier, long ts, byte[] value)
      Create a KeyValue with this objects row key and the Put identifier.
      Returns:
      a KeyValue with this objects row key and the Put identifier.
    • createPutKeyValue

      KeyValue createPutKeyValue(byte[] family, byte[] qualifier, long ts, byte[] value, Tag[] tags)
      Create a KeyValue with this objects row key and the Put identifier.
      Returns:
      a KeyValue with this objects row key and the Put identifier.
    • createPutKeyValue

      KeyValue createPutKeyValue(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value, Tag[] tags)
      Create a KeyValue with this objects row key and the Put identifier.
      Returns:
      a KeyValue with this objects row key and the Put identifier.
    • getFingerprint

      Compile the column family (i.e. schema) information into a Map. Useful for parsing and aggregation by debugging, logging, and administration tools.
      Specified by:
      getFingerprint in class Operation
      Returns:
      a map containing fingerprint information (i.e. column families)
    • toMap

      public Map<String,Object> toMap(int maxCols)
      Compile the details beyond the scope of getFingerprint (row, columns, timestamps, etc.) into a Map along with the fingerprinted information. Useful for debugging, logging, and administration tools.
      Specified by:
      toMap in class Operation
      Parameters:
      maxCols - a limit on the number of columns output prior to truncation
      Returns:
      a map containing parameters of a query (i.e. rows, columns...)
    • cellToStringMap

      private static Map<String,Object> cellToStringMap(Cell c)
    • setDurability

      Set the durability for this mutation
    • getDurability

      Get the current durability
    • getFamilyCellMap

      Method for retrieving the put's familyMap
    • setFamilyCellMap

      Deprecated.
      As of release 2.0.0, this will be removed in HBase 3.0.0. Use Mutation(byte[], long, NavigableMap) instead
      Method for setting the mutation's familyMap
    • isEmpty

      public boolean isEmpty()
      Method to check if the familyMap is empty
      Returns:
      true if empty, false otherwise
    • getRow

      public byte[] getRow()
      Method for retrieving the delete's row
      Specified by:
      getRow in interface Row
    • compareTo

      @Deprecated public int compareTo(Row d)
      Deprecated.
      As of release 2.0.0, this will be removed in HBase 3.0.0. Use Row.COMPARATOR instead
      Description copied from interface: Row
      Compare this row to another row.
      Specified by:
      compareTo in interface Comparable<Row>
      Specified by:
      compareTo in interface Row
    • getTimeStamp

      @Deprecated public long getTimeStamp()
      Deprecated.
      As of release 2.0.0, this will be removed in HBase 3.0.0. Use getTimestamp() instead
      Method for retrieving the timestamp
    • getTimestamp

      public long getTimestamp()
      Method for retrieving the timestamp.
    • setClusterIds

      public Mutation setClusterIds(List<UUID> clusterIds)
      Marks that the clusters with the given clusterIds have consumed the mutation
      Parameters:
      clusterIds - of the clusters that have consumed the mutation
    • getClusterIds

      public List<UUID> getClusterIds()
      Returns the set of clusterIds that have consumed the mutation
    • setCellVisibility

      Sets the visibility expression associated with cells in this Mutation.
    • getCellVisibility

      Returns CellVisibility associated with cells in this Mutation. n
      Throws:
      DeserializationException
    • toCellVisibility

      static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CellVisibility toCellVisibility(CellVisibility cellVisibility)
      Create a protocol buffer CellVisibility based on a client CellVisibility.
      Returns:
      a protocol buffer CellVisibility
    • toCellVisibility

      private static CellVisibility toCellVisibility(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CellVisibility proto)
      Convert a protocol buffer CellVisibility to a client CellVisibility
      Returns:
      the converted client CellVisibility
    • toCellVisibility

      private static CellVisibility toCellVisibility(byte[] protoBytes) throws DeserializationException
      Convert a protocol buffer CellVisibility bytes to a client CellVisibility
      Returns:
      the converted client CellVisibility
      Throws:
      DeserializationException
    • size

      public int size()
      Number of KeyValues carried by this Mutation.
      Returns:
      the total number of KeyValues
    • numFamilies

      public int numFamilies()
      Returns the number of different families
    • heapSize

      public long heapSize()
      Returns Calculate what Mutation adds to class heap size.
      Specified by:
      heapSize in interface HeapSize
    • getACL

      public byte[] getACL()
      Returns The serialized ACL for this operation, or null if none
    • setACL

      public Mutation setACL(String user, Permission perms)
      Set the ACL for this operation.
      Parameters:
      user - User short name
      perms - Permissions for the user
    • setACL

      public Mutation setACL(Map<String,Permission> perms)
      Set the ACL for this operation.
      Parameters:
      perms - A map of permissions for a user or users
    • getTTL

      public long getTTL()
      Return the TTL requested for the result of the mutation, in milliseconds.
      Returns:
      the TTL requested for the result of the mutation, in milliseconds, or Long.MAX_VALUE if unset
    • setTTL

      public Mutation setTTL(long ttl)
      Set the TTL desired for the result of the mutation, in milliseconds.
      Parameters:
      ttl - the TTL desired for the result of the mutation, in milliseconds
    • isReturnResults

      @Private protected boolean isReturnResults()
      Returns current value for returnResults
    • setReturnResults

      @Private protected Mutation setReturnResults(boolean returnResults)
    • extraHeapSize

      protected long extraHeapSize()
      Subclasses should override this method to add the heap size of their own fields.
      Returns:
      the heap size to add (will be aligned).
    • setTimestamp

      public Mutation setTimestamp(long timestamp)
      Set the timestamp of the delete.
    • has

      public boolean has(byte[] family, byte[] qualifier)
      A convenience method to determine if this object's familyMap contains a value assigned to the given family & qualifier. Both given arguments must match the KeyValue object to return true.
      Parameters:
      family - column family
      qualifier - column qualifier
      Returns:
      returns true if the given family and qualifier already has an existing KeyValue object in the family map.
    • has

      public boolean has(byte[] family, byte[] qualifier, long ts)
      A convenience method to determine if this object's familyMap contains a value assigned to the given family, qualifier and timestamp. All 3 given arguments must match the KeyValue object to return true.
      Parameters:
      family - column family
      qualifier - column qualifier
      ts - timestamp
      Returns:
      returns true if the given family, qualifier and timestamp already has an existing KeyValue object in the family map.
    • has

      public boolean has(byte[] family, byte[] qualifier, byte[] value)
      A convenience method to determine if this object's familyMap contains a value assigned to the given family, qualifier and timestamp. All 3 given arguments must match the KeyValue object to return true.
      Parameters:
      family - column family
      qualifier - column qualifier
      value - value to check
      Returns:
      returns true if the given family, qualifier and value already has an existing KeyValue object in the family map.
    • has

      public boolean has(byte[] family, byte[] qualifier, long ts, byte[] value)
      A convenience method to determine if this object's familyMap contains the given value assigned to the given family, qualifier and timestamp. All 4 given arguments must match the KeyValue object to return true.
      Parameters:
      family - column family
      qualifier - column qualifier
      ts - timestamp
      value - value to check
      Returns:
      returns true if the given family, qualifier timestamp and value already has an existing KeyValue object in the family map.
    • get

      public List<Cell> get(byte[] family, byte[] qualifier)
      Returns a list of all KeyValue objects with matching column family and qualifier.
      Parameters:
      family - column family
      qualifier - column qualifier
      Returns:
      a list of KeyValue objects with the matching family and qualifier, returns an empty list if one doesn't exist for the given family.
    • has

      protected boolean has(byte[] family, byte[] qualifier, long ts, byte[] value, boolean ignoreTS, boolean ignoreValue)
      Private method to determine if this object's familyMap contains the given value assigned to the given family, qualifier and timestamp, respecting the 2 boolean arguments.
    • checkRow

      static byte[] checkRow(byte[] row)
      Parameters:
      row - Row to check
      Returns:
      row
      Throws:
      IllegalArgumentException - Thrown if row is empty or null or > HConstants.MAX_ROW_LENGTH
    • checkRow

      static byte[] checkRow(byte[] row, int offset, int length)
      Parameters:
      row - Row to check
      Returns:
      row
      Throws:
      IllegalArgumentException - Thrown if row is empty or null or > HConstants.MAX_ROW_LENGTH
    • checkRow

      static void checkRow(ByteBuffer row)
    • add

      Mutation add(Cell cell) throws IOException
      Throws:
      IOException