public class Increment extends Object implements Row
This operation does not appear atomic to readers. Increments are done under a single row lock, so write operations to a row are synchronized, but readers do not take row locks so get and scan operations can see this operation partially 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.
Constructor and Description |
---|
Increment()
Constructor for Writable.
|
Increment(byte[] row)
Create a Increment operation for the specified row.
|
Increment(byte[] row,
RowLock rowLock)
Deprecated.
RowLock and associated operations are deprecated,
use Increment(byte[]) |
Modifier and Type | Method and Description |
---|---|
Increment |
addColumn(byte[] family,
byte[] qualifier,
long amount)
Increment the column from the specific family with the specified qualifier
by the specified amount.
|
int |
compareTo(Row i) |
Set<byte[]> |
familySet()
Method for retrieving the keys in the familyMap
|
Map<byte[],NavigableMap<byte[],Long>> |
getFamilyMap()
Method for retrieving the increment's familyMap
|
long |
getLockId()
Deprecated.
RowLock and associated operations are deprecated |
byte[] |
getRow()
Method for retrieving the increment's row
|
RowLock |
getRowLock()
Deprecated.
RowLock and associated operations are deprecated |
TimeRange |
getTimeRange()
Gets the TimeRange used for this increment.
|
boolean |
getWriteToWAL()
Method for retrieving whether WAL will be written to or not
|
boolean |
hasFamilies()
Method for checking if any families have been inserted into this Increment
|
int |
numColumns()
Method for retrieving the number of columns to increment
|
int |
numFamilies()
Method for retrieving the number of families to increment from
|
void |
readFields(DataInput in) |
Increment |
setTimeRange(long minStamp,
long maxStamp)
Sets the TimeRange to be used on the Get for this increment.
|
Increment |
setWriteToWAL(boolean writeToWAL)
Sets whether this operation should write to the WAL or not.
|
String |
toString() |
void |
write(DataOutput out) |
public Increment()
public Increment(byte[] row)
At least one column must be incremented.
row
- row keypublic Increment(byte[] row, RowLock rowLock)
At least one column must be incremented.
row
- row keyrowLock
- previously acquired row lock, or nullpublic 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 byte[] getRow()
public RowLock getRowLock()
RowLock
and associated operations are deprecatedpublic long getLockId()
RowLock
and associated operations are deprecatedpublic boolean getWriteToWAL()
public Increment setWriteToWAL(boolean writeToWAL)
writeToWAL
- true if WAL should be used, false if notpublic 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.
This range is used as [minStamp, maxStamp).
minStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusiveIOException
- if invalid time rangepublic Set<byte[]> familySet()
public int numFamilies()
public int numColumns()
public boolean hasFamilies()
public Map<byte[],NavigableMap<byte[],Long>> getFamilyMap()
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public int compareTo(Row i)
compareTo
in interface Comparable<Row>
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.