org.apache.hadoop.hbase.io
Class BatchUpdate

java.lang.Object
  extended by org.apache.hadoop.hbase.io.BatchUpdate
All Implemented Interfaces:
Comparable<BatchUpdate>, Iterable<BatchOperation>, HeapSize, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<BatchUpdate>

public class BatchUpdate
extends Object
implements org.apache.hadoop.io.WritableComparable<BatchUpdate>, Iterable<BatchOperation>, HeapSize

A Writable object that contains a series of BatchOperations There is one BatchUpdate object per server, so a series of batch operations can result in multiple BatchUpdate objects if the batch contains rows that are served by multiple region servers.


Field Summary
static int ESTIMATED_HEAP_TAX
          Estimated 'shallow size' of this object not counting payload.
 
Constructor Summary
BatchUpdate()
          Default constructor used serializing.
BatchUpdate(BatchUpdate buToCopy)
          Recopy constructor
BatchUpdate(byte[] row)
          Initialize a BatchUpdate operation on a row.
BatchUpdate(byte[] row, long timestamp)
          Initialize a BatchUpdate operation on a row with a specific timestamp.
BatchUpdate(RowResult rr)
          Create a batch operation.
BatchUpdate(String row)
          Initialize a BatchUpdate operation on a row.
BatchUpdate(String row, long timestamp)
          Initialize a BatchUpdate operation on a row with a specific timestamp.
 
Method Summary
 int compareTo(BatchUpdate o)
           
 void delete(byte[] column)
          Delete the value for a column Deletes the cell whose row/column/commit-timestamp match those of the delete.
 void delete(String column)
          Delete the value for a column Deletes the cell whose row/column/commit-timestamp match those of the delete.
 byte[] get(byte[] column)
          Get the current value of the specified column
 byte[] get(String column)
          Get the current value of the specified column
 byte[][] getColumns()
          Get the current columns
 byte[] getRow()
           
 long getRowLock()
          Get the row lock associated with this update
 long getTimestamp()
           
 boolean hasColumn(byte[] column)
          Check if the specified column is currently assigned a value
 boolean hasColumn(String column)
          Check if the specified column is currently assigned a value
 long heapSize()
           
 Iterator<BatchOperation> iterator()
           
static void main(String[] args)
          Code to test sizes of BatchUpdate arrays.
 void put(byte[] column, byte[] val)
          Change a value for the specified column
 void put(String column, byte[] val)
          Change a value for the specified column
 void readFields(DataInput in)
           
 void setRowLock(long rowLock)
          Set the lock to be used for this update
 void setTimestamp(long timestamp)
          Set this BatchUpdate's timestamp.
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ESTIMATED_HEAP_TAX

public static final int ESTIMATED_HEAP_TAX
Estimated 'shallow size' of this object not counting payload.

See Also:
Constant Field Values
Constructor Detail

BatchUpdate

public BatchUpdate()
Default constructor used serializing. Do not use directly.


BatchUpdate

public BatchUpdate(String row)
Initialize a BatchUpdate operation on a row. Timestamp is assumed to be now.

Parameters:
row -

BatchUpdate

public BatchUpdate(byte[] row)
Initialize a BatchUpdate operation on a row. Timestamp is assumed to be now.

Parameters:
row -

BatchUpdate

public BatchUpdate(String row,
                   long timestamp)
Initialize a BatchUpdate operation on a row with a specific timestamp.

Parameters:
row -
timestamp -

BatchUpdate

public BatchUpdate(BatchUpdate buToCopy)
Recopy constructor

Parameters:
buToCopy - BatchUpdate to copy

BatchUpdate

public BatchUpdate(byte[] row,
                   long timestamp)
Initialize a BatchUpdate operation on a row with a specific timestamp.

Parameters:
row -
timestamp -

BatchUpdate

public BatchUpdate(RowResult rr)
Create a batch operation.

Parameters:
rr - the RowResult
Method Detail

getRowLock

public long getRowLock()
Get the row lock associated with this update

Returns:
the row lock

setRowLock

public void setRowLock(long rowLock)
Set the lock to be used for this update

Parameters:
rowLock - the row lock

getRow

public byte[] getRow()
Returns:
the row

getTimestamp

public long getTimestamp()
Returns:
the timestamp this BatchUpdate will be committed with.

setTimestamp

public void setTimestamp(long timestamp)
Set this BatchUpdate's timestamp.

Parameters:
timestamp -

get

public byte[] get(String column)
Get the current value of the specified column

Parameters:
column - column name
Returns:
byte[] the cell value, returns null if the column does not exist.

get

public byte[] get(byte[] column)
Get the current value of the specified column

Parameters:
column - column name
Returns:
byte[] the cell value, returns null if the column does not exist.

getColumns

public byte[][] getColumns()
Get the current columns

Returns:
byte[][] an array of byte[] columns

hasColumn

public boolean hasColumn(String column)
Check if the specified column is currently assigned a value

Parameters:
column - column to check for
Returns:
boolean true if the given column exists

hasColumn

public boolean hasColumn(byte[] column)
Check if the specified column is currently assigned a value

Parameters:
column - column to check for
Returns:
boolean true if the given column exists

put

public void put(String column,
                byte[] val)
Change a value for the specified column

Parameters:
column - column whose value is being set
val - new value for column. Cannot be null (can be empty).

put

public void put(byte[] column,
                byte[] val)
Change a value for the specified column

Parameters:
column - column whose value is being set
val - new value for column. Cannot be null (can be empty).

delete

public void delete(String column)
Delete the value for a column Deletes the cell whose row/column/commit-timestamp match those of the delete.

Parameters:
column - name of column whose value is to be deleted

delete

public void delete(byte[] column)
Delete the value for a column Deletes the cell whose row/column/commit-timestamp match those of the delete.

Parameters:
column - name of column whose value is to be deleted

iterator

public Iterator<BatchOperation> iterator()
Specified by:
iterator in interface Iterable<BatchOperation>
Returns:
Iterator

toString

public String toString()
Overrides:
toString in class Object

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

compareTo

public int compareTo(BatchUpdate o)
Specified by:
compareTo in interface Comparable<BatchUpdate>

heapSize

public long heapSize()
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.

main

public static void main(String[] args)
                 throws InterruptedException
Code to test sizes of BatchUpdate arrays.

Parameters:
args -
Throws:
InterruptedException


Copyright © 2008 The Apache Software Foundation