@InterfaceAudience.Public public class Increment extends Mutation
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.
Modifier and Type | Field and Description |
---|---|
private static int |
HEAP_OVERHEAD |
private TimeRange |
tr |
durability, familyMap, MUTATION_OVERHEAD, row, ts
ID_ATRIBUTE
COMPARATOR
Constructor and Description |
---|
Increment(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.
|
Increment(Increment incrementToCopy)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
Increment |
add(Cell cell)
Add the specified KeyValue to this operation.
|
Increment |
addColumn(byte[] family,
byte[] qualifier,
long amount)
Increment the column from the specific family with the specified qualifier
by the specified amount.
|
boolean |
equals(Object obj)
Deprecated.
As of release 2.0.0, this will be removed in HBase 3.0.0.
Use
Row.COMPARATOR instead |
protected long |
extraHeapSize()
Subclasses should override this method to add the heap size of their own fields.
|
Map<byte[],NavigableMap<byte[],Long>> |
getFamilyMapOfLongs()
Before 0.95, when you called Increment#getFamilyMap(), you got back
a map of families to a list of Longs.
|
TimeRange |
getTimeRange()
Gets the TimeRange used for this increment.
|
boolean |
hasFamilies()
Method for checking if any families have been inserted into this Increment
|
int |
hashCode()
Deprecated.
As of release 2.0.0, this will be removed in HBase 3.0.0.
No replacement.
|
boolean |
isReturnResults() |
int |
numFamilies()
Method for retrieving the number of families to increment from
|
Increment |
setACL(Map<String,Permission> perms) |
Increment |
setACL(String user,
Permission perms) |
Increment |
setAttribute(String name,
byte[] value)
Sets an attribute.
|
Increment |
setCellVisibility(CellVisibility expression)
Sets the visibility expression associated with cells in this Mutation.
|
Increment |
setClusterIds(List<UUID> clusterIds)
Marks that the clusters with the given clusterIds have consumed the mutation
|
Increment |
setDurability(Durability d)
Set the durability for this mutation
|
Increment |
setFamilyCellMap(NavigableMap<byte[],List<Cell>> map)
Deprecated.
As of release 2.0.0, this will be removed in HBase 3.0.0.
Use
Increment(byte[], long, NavigableMap) instead |
Increment |
setId(String id)
This method allows you to set an identifier on an operation.
|
Increment |
setPriority(int priority) |
Increment |
setReturnResults(boolean returnResults) |
Increment |
setTimeRange(long minStamp,
long maxStamp)
Sets the TimeRange to be used on the Get for this increment.
|
Increment |
setTimestamp(long timestamp)
Set the timestamp of the delete.
|
Increment |
setTTL(long ttl)
Set the TTL desired for the result of the mutation, in milliseconds.
|
String |
toString()
Produces a string representation of this Operation.
|
cellScanner, checkRow, checkRow, checkRow, compareTo, createPutKeyValue, createPutKeyValue, createPutKeyValue, get, getACL, getCellList, getCellVisibility, getClusterIds, getDurability, getFamilyCellMap, getFingerprint, getRow, getTimestamp, getTimeStamp, getTTL, has, has, has, has, has, heapSize, isEmpty, size, toCellVisibility, toMap
getAttribute, getAttributeSize, getAttributesMap, getId, getPriority
private static final int HEAP_OVERHEAD
public Increment(byte[] row)
At least one column must be incremented.
row
- row key (we will make a copy of this).public Increment(byte[] row, int offset, int length)
At least one column must be incremented.
row
- row key (we will make a copy of this).public Increment(Increment incrementToCopy)
incrementToCopy
- increment to copypublic Increment(byte[] row, long ts, NavigableMap<byte[],List<Cell>> familyMap)
row
- row. CAN'T be nullts
- timestampfamilyMap
- the map to collect all cells internally. CAN'T be nullpublic Increment add(Cell cell) throws IOException
add
in class Mutation
cell
- individual CellIOException
- epublic Increment addColumn(byte[] family, byte[] qualifier, long amount)
Overrides previous calls to addColumn for this family and qualifier.
family
- family namequalifier
- column qualifieramount
- amount to increment bypublic TimeRange getTimeRange()
public Increment setTimeRange(long minStamp, long maxStamp) throws IOException
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).
minStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusiveIOException
- if invalid time rangepublic Increment setTimestamp(long timestamp)
Mutation
setTimestamp
in class Mutation
public Increment setReturnResults(boolean returnResults)
setReturnResults
in class Mutation
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.public boolean isReturnResults()
isReturnResults
in class Mutation
public int numFamilies()
numFamilies
in class Mutation
public boolean hasFamilies()
public Map<byte[],NavigableMap<byte[],Long>> getFamilyMapOfLongs()
Mutation.getFamilyCellMap()
returns
families by list of Cells. This method has been added so you can have the
old behavior.public String toString()
Operation
@Deprecated public int hashCode()
@Deprecated public boolean equals(Object obj)
Row.COMPARATOR
insteadprotected long extraHeapSize()
Mutation
extraHeapSize
in class Mutation
public Increment setAttribute(String name, byte[] value)
Attributes
setAttribute
in interface Attributes
setAttribute
in class OperationWithAttributes
name
- attribute namevalue
- attribute valuepublic Increment setId(String id)
OperationWithAttributes
setId
in class OperationWithAttributes
id
- id to set for the scanpublic Increment setDurability(Durability d)
Mutation
setDurability
in class Mutation
@Deprecated public Increment setFamilyCellMap(NavigableMap<byte[],List<Cell>> map)
Increment(byte[], long, NavigableMap)
insteadsetFamilyCellMap
in class Mutation
public Increment setClusterIds(List<UUID> clusterIds)
Mutation
setClusterIds
in class Mutation
clusterIds
- of the clusters that have consumed the mutationpublic Increment setCellVisibility(CellVisibility expression)
Mutation
setCellVisibility
in class Mutation
public Increment setACL(String user, Permission perms)
public Increment setACL(Map<String,Permission> perms)
public Increment setTTL(long ttl)
Mutation
public Increment setPriority(int priority)
setPriority
in class OperationWithAttributes
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.