org.apache.hadoop.hbase.io
Class BatchUpdate

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

public class BatchUpdate
extends Object
implements Writable, Iterable<BatchOperation>

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.


Constructor Summary
BatchUpdate()
          Default constructor - used by Writable.
BatchUpdate(long lockid)
          Client side constructor.
 
Method Summary
 void delete(long lid, Text column)
          Delete the value for a column Deletes the cell whose row/column/commit-timestamp match those of the delete.
 long getLockid()
           
 Text getRow()
           
 Iterator<BatchOperation> iterator()
           
 void put(long lid, Text column, byte[] val)
          Change a value for the specified column
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 long startUpdate(Text row)
          Start a batch row insertion/update.
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchUpdate

public BatchUpdate()
Default constructor - used by Writable.


BatchUpdate

public BatchUpdate(long lockid)
Client side constructor. Clients need to provide the lockid by some means such as Random.nextLong()

Parameters:
lockid -
Method Detail

getLockid

public long getLockid()
Returns:
the lock id

getRow

public Text getRow()
Returns:
the row

startUpdate

public long startUpdate(Text row)
Start a batch row insertion/update. No changes are committed until the client commits the batch operation via HClient.batchCommit(). The entire batch update can be abandoned by calling HClient.batchAbort(); Callers to this method are given a handle that corresponds to the row being changed. The handle must be supplied on subsequent put or delete calls.

Parameters:
row - Name of row to start update against.
Returns:
Row lockid.

put

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

Parameters:
lid - lock id returned from startUpdate
column - column whose value is being set
val - new value for column. Cannot be null (can be empty).

delete

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

Parameters:
lid - lock id returned from startUpdate
column - name of column whose value is to be deleted

iterator

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

readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException


Copyright © 2006 The Apache Software Foundation