Class Mutation

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

@Public public abstract class Mutation extends OperationWithAttributes implements Row, ExtendedCellScannable, HeapSize
  • 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

      For client users: You should only use the return value as a CellScanner, ExtendedCellScanner is marked as IA.Private which means there is no guarantee about its API stability.
      Specified by:
      cellScanner in interface CellScannable
      Specified by:
      cellScanner in interface ExtendedCellScannable
    • getCellList

      List<ExtendedCell> 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

    • setDurability

      Set the durability for this mutation
    • getDurability

      Get the current durability
    • getFamilyCellMap

      Method for retrieving the put'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
    • 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.shaded.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.shaded.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)
    • checkTimestamp

      protected final void checkTimestamp(long ts)
    • add

      Mutation add(Cell cell) throws IOException
      Throws:
      IOException
    • getCellBuilder

      public abstract CellBuilder getCellBuilder(CellBuilderType cellBuilderType)
      get a CellBuilder instance that already has relevant Type and Row set.
      Parameters:
      cellBuilderType - e.g CellBuilderType.SHALLOW_COPY
      Returns:
      CellBuilder which already has relevant Type and Row set.
    • getCellBuilder

      get a CellBuilder instance that already has relevant Type and Row set. the default CellBuilderType is CellBuilderType.SHALLOW_COPY
      Returns:
      CellBuilder which already has relevant Type and Row set.
    • getCellBuilder

      protected final CellBuilder getCellBuilder(CellBuilderType cellBuilderType, Cell.Type cellType)
      get a CellBuilder instance that already has relevant Type and Row set.
      Parameters:
      cellBuilderType - e.g CellBuilderType.SHALLOW_COPY
      cellType - e.g Cell.Type.Put
      Returns:
      CellBuilder which already has relevant Type and Row set.