Class Increment
- All Implemented Interfaces:
CellScannable
,Attributes
,Row
,ExtendedCellScannable
,HeapSize
This operation ensures atomicity to readers. Increments are done under a single row lock, so write operations to a row are synchronized, and readers are guaranteed to see this operation fully completed.
To increment columns of a row, instantiate an Increment object with the row to increment. At
least one column to increment must be specified using the
addColumn(byte[], byte[], long)
method.
-
Field Summary
Fields inherited from class org.apache.hadoop.hbase.client.Mutation
durability, familyMap, MUTATION_OVERHEAD, row, ts
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
ConstructorDescriptionIncrement
(byte[] row) Create a Increment operation for the specified row.Increment
(byte[] row, int offset, int length) Create a Increment operation for the specified row.Increment
(byte[] row, long ts, NavigableMap<byte[], List<Cell>> familyMap) Construct the Increment with user defined data.Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionAdd the specified KeyValue to this operation.addColumn
(byte[] family, byte[] qualifier, long amount) Increment the column from the specific family with the specified qualifier by the specified amount.protected long
Subclasses should override this method to add the heap size of their own fields.get a CellBuilder instance that already has relevant Type and Row set.Map<byte[],
NavigableMap<byte[], Long>> Before 0.95, when you called Increment#getFamilyMap(), you got back a map of families to a list of Longs.Gets the TimeRange used for this increment.boolean
Method for checking if any families have been inserted into this Incrementboolean
Returns current setting for returnResultsint
Method for retrieving the number of families to increment fromsetACL
(String user, Permission perms) Set the ACL for this operation.setACL
(Map<String, Permission> perms) Set the ACL for this operation.setAttribute
(String name, byte[] value) Sets an attribute.setCellVisibility
(CellVisibility expression) 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 mutationSet the durability for this mutationThis method allows you to set an identifier on an operation.setPriority
(int priority) setReturnResults
(boolean returnResults) setTimeRange
(long minStamp, long maxStamp) Sets the TimeRange to be used on the Get for this increment.setTimestamp
(long timestamp) Set the timestamp of the delete.setTTL
(long ttl) Set the TTL desired for the result of the mutation, in milliseconds.toString()
Produces a string representation of this Operation.Methods inherited from class org.apache.hadoop.hbase.client.Mutation
cellScanner, checkRow, checkRow, checkRow, checkTimestamp, createPutKeyValue, createPutKeyValue, createPutKeyValue, get, getACL, getCellBuilder, getCellBuilder, getCellList, getCellVisibility, getClusterIds, getDurability, getFamilyCellMap, getFingerprint, getRow, getTimestamp, getTTL, has, has, has, has, has, heapSize, isEmpty, size, toCellVisibility, toMap
Methods inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes
getAttribute, getAttributeSize, getAttributesMap, getId, getPriority
-
Field Details
-
HEAP_OVERHEAD
-
tr
-
-
Constructor Details
-
Increment
Create a Increment operation for the specified row.At least one column must be incremented.
- Parameters:
row
- row key (we will make a copy of this).
-
Increment
Create a Increment operation for the specified row.At least one column must be incremented.
- Parameters:
row
- row key (we will make a copy of this).
-
Increment
Copy constructor- Parameters:
incrementToCopy
- increment to copy
-
-
Method Details
-
add
Add the specified KeyValue to this operation.- Overrides:
add
in classMutation
- Parameters:
cell
- individual Cell- Throws:
IOException
- e
-
addColumn
Increment the column from the specific family with the specified qualifier by the specified amount.Overrides previous calls to addColumn for this family and qualifier.
- Parameters:
family
- family namequalifier
- column qualifieramount
- amount to increment by- Returns:
- the Increment object
-
getTimeRange
Gets the TimeRange used for this increment. -
setTimeRange
Sets the TimeRange to be used on the Get for this increment.This is useful for when you have counters that only last for specific periods of time (ie. counters that are partitioned by time). By setting the range of valid times for this increment, you can potentially gain some performance with a more optimal Get operation. Be careful adding the time range to this class as you will update the old cell if the time range doesn't include the latest cells.
This range is used as [minStamp, maxStamp).
- Parameters:
minStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusive- Throws:
IOException
- if invalid time range
-
setTimestamp
Description copied from class:Mutation
Set the timestamp of the delete.- Overrides:
setTimestamp
in classMutation
-
setReturnResults
- Overrides:
setReturnResults
in classMutation
- Parameters:
returnResults
- True (default) if the increment operation should return the results. A client that is not interested in the result can save network bandwidth setting this to false.
-
isReturnResults
Returns current setting for returnResults- Overrides:
isReturnResults
in classMutation
-
numFamilies
Method for retrieving the number of families to increment from- Overrides:
numFamilies
in classMutation
- Returns:
- number of families
-
hasFamilies
Method for checking if any families have been inserted into this Increment- Returns:
- true if familyMap is non empty false otherwise
-
getFamilyMapOfLongs
Before 0.95, when you called Increment#getFamilyMap(), you got back a map of families to a list of Longs. Now,Mutation.getFamilyCellMap()
returns families by list of Cells. This method has been added so you can have the old behavior.- Returns:
- Map of families to a Map of qualifiers and their Long increments.
- Since:
- 0.95.0
-
toString
Description copied from class:Operation
Produces a string representation of this Operation. It defaults to a JSON representation, but falls back to a string representation of the fingerprint and details in the case of a JSON encoding failure. -
extraHeapSize
Description copied from class:Mutation
Subclasses should override this method to add the heap size of their own fields.- Overrides:
extraHeapSize
in classMutation
- Returns:
- the heap size to add (will be aligned).
-
setAttribute
Description copied from interface:Attributes
Sets an attribute. In case value = null attribute is removed from the attributes map. Attribute names starting with _ indicate system attributes.- Specified by:
setAttribute
in interfaceAttributes
- Overrides:
setAttribute
in classOperationWithAttributes
- Parameters:
name
- attribute namevalue
- attribute value
-
setId
Description copied from class:OperationWithAttributes
This method allows you to set an identifier on an operation. The original motivation for this was to allow the identifier to be used in slow query logging, but this could obviously be useful in other places. One use of this could be to put a class.method identifier in here to see where the slow query is coming from. id to set for the scan- Overrides:
setId
in classOperationWithAttributes
-
setDurability
Description copied from class:Mutation
Set the durability for this mutation- Overrides:
setDurability
in classMutation
-
setClusterIds
Description copied from class:Mutation
Marks that the clusters with the given clusterIds have consumed the mutation- Overrides:
setClusterIds
in classMutation
- Parameters:
clusterIds
- of the clusters that have consumed the mutation
-
setCellVisibility
Description copied from class:Mutation
Sets the visibility expression associated with cells in this Mutation.- Overrides:
setCellVisibility
in classMutation
-
setACL
Description copied from class:Mutation
Set the ACL for this operation. -
setACL
Description copied from class:Mutation
Set the ACL for this operation. -
setTTL
Description copied from class:Mutation
Set the TTL desired for the result of the mutation, in milliseconds. -
setPriority
- Overrides:
setPriority
in classOperationWithAttributes
-
getCellBuilder
Description copied from class:Mutation
get a CellBuilder instance that already has relevant Type and Row set.- Specified by:
getCellBuilder
in classMutation
- Parameters:
type
- e.g CellBuilderType.SHALLOW_COPY- Returns:
- CellBuilder which already has relevant Type and Row set.
-