org.apache.hadoop.hbase.client
Class Increment

java.lang.Object
  extended by org.apache.hadoop.hbase.client.Increment
All Implemented Interfaces:
org.apache.hadoop.io.Writable

public class Increment
extends Object
implements org.apache.hadoop.io.Writable

Used to perform Increment operations on a single 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 Summary
Increment()
          Constructor for Writable.
Increment(byte[] row)
          Create a Increment operation for the specified row.
Increment(byte[] row, RowLock rowLock)
          Create a Increment operation for the specified row, using an existing row lock.
 
Method Summary
 Increment addColumn(byte[] family, byte[] qualifier, long amount)
          Increment the column from the specific family with the specified qualifier by the specified amount.
 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()
          Method for retrieving the increment's lockId
 byte[] getRow()
          Method for retrieving the increment's row
 RowLock getRowLock()
          Method for retrieving the increment's RowLock
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Increment

public Increment()
Constructor for Writable. DO NOT USE


Increment

public Increment(byte[] row)
Create a Increment operation for the specified row.

At least one column must be incremented.

Parameters:
row - row key

Increment

public Increment(byte[] row,
                 RowLock rowLock)
Create a Increment operation for the specified row, using an existing row lock.

At least one column must be incremented.

Parameters:
row - row key
rowLock - previously acquired row lock, or null
Method Detail

addColumn

public Increment addColumn(byte[] family,
                           byte[] qualifier,
                           long amount)
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 name
qualifier - column qualifier
amount - amount to increment by
Returns:
the Increment object

getRow

public byte[] getRow()
Method for retrieving the increment's row

Returns:
row

getRowLock

public RowLock getRowLock()
Method for retrieving the increment's RowLock

Returns:
RowLock

getLockId

public long getLockId()
Method for retrieving the increment's lockId

Returns:
lockId

getWriteToWAL

public boolean getWriteToWAL()
Method for retrieving whether WAL will be written to or not

Returns:
true if WAL should be used, false if not

setWriteToWAL

public Increment setWriteToWAL(boolean writeToWAL)
Sets whether this operation should write to the WAL or not.

Parameters:
writeToWAL - true if WAL should be used, false if not
Returns:
this increment operation

getTimeRange

public TimeRange getTimeRange()
Gets the TimeRange used for this increment.

Returns:
TimeRange

setTimeRange

public Increment setTimeRange(long minStamp,
                              long maxStamp)
                       throws IOException
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.

This range is used as [minStamp, maxStamp).

Parameters:
minStamp - minimum timestamp value, inclusive
maxStamp - maximum timestamp value, exclusive
Returns:
this
Throws:
IOException - if invalid time range

familySet

public Set<byte[]> familySet()
Method for retrieving the keys in the familyMap

Returns:
keys in the current familyMap

numFamilies

public int numFamilies()
Method for retrieving the number of families to increment from

Returns:
number of families

numColumns

public int numColumns()
Method for retrieving the number of columns to increment

Returns:
number of columns across all families

hasFamilies

public boolean hasFamilies()
Method for checking if any families have been inserted into this Increment

Returns:
true if familyMap is non empty false otherwise

getFamilyMap

public Map<byte[],NavigableMap<byte[],Long>> getFamilyMap()
Method for retrieving the increment's familyMap

Returns:
familyMap

toString

public String toString()
Overrides:
toString in class Object
Returns:
String

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.