org.apache.hadoop.hbase.client
Class Put

java.lang.Object
  extended by org.apache.hadoop.hbase.client.Put
All Implemented Interfaces:
Comparable<Put>, HeapSize, org.apache.hadoop.io.Writable

public class Put
extends Object
implements HeapSize, org.apache.hadoop.io.Writable, Comparable<Put>

Used to perform Put operations for a single row.

To perform a Put, instantiate a Put object with the row to insert to and for each column to be inserted, execute add or add if setting the timestamp.


Constructor Summary
Put()
          Constructor for Writable.
Put(byte[] row)
          Create a Put operation for the specified row.
Put(byte[] row, RowLock rowLock)
          Create a Put operation for the specified row, using an existing row lock.
Put(Put putToCopy)
          Copy constructor.
 
Method Summary
 Put add(byte[] family, byte[] qualifier, byte[] value)
          Add the specified column and value to this Put operation.
 Put add(byte[] family, byte[] qualifier, long ts, byte[] value)
          Add the specified column and value, with the specified timestamp as its version to this Put operation.
 Put add(byte[] column, long ts, byte[] value)
          Add the specified column and value, with the specified timestamp as its version to this Put operation.
 Put add(KeyValue kv)
          Add the specified KeyValue to this Put operation.
 int compareTo(Put p)
           
 Map<byte[],List<KeyValue>> getFamilyMap()
          Method for retrieving the put's familyMap
 long getLockId()
          Method for retrieving the put's lockId
 byte[] getRow()
          Method for retrieving the put's row
 RowLock getRowLock()
          Method for retrieving the put's RowLock
 long getTimeStamp()
           
 boolean getWriteToWAL()
           
 long heapSize()
           
 boolean isEmpty()
          Method to check if the familyMap is empty
 int numFamilies()
           
 void readFields(DataInput in)
           
 Put setTimeStamp(long timestamp)
          Method for setting the timestamp
 void setWriteToWAL(boolean write)
          Set whether this Put should be written to the WAL or not.
 int size()
           
 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

Put

public Put()
Constructor for Writable. DO NOT USE


Put

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

Parameters:
row - row key

Put

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

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

Put

public Put(Put putToCopy)
Copy constructor. Creates a Put operation cloned from the specified Put.

Parameters:
putToCopy - put to copy
Method Detail

add

public Put add(byte[] family,
               byte[] qualifier,
               byte[] value)
Add the specified column and value to this Put operation.

Parameters:
family - family name
qualifier - column qualifier
value - column value

add

public Put add(byte[] column,
               long ts,
               byte[] value)
Add the specified column and value, with the specified timestamp as its version to this Put operation.

Parameters:
column - Old style column name with family and qualifier put together with a colon.
ts - version timestamp
value - column value

add

public Put add(byte[] family,
               byte[] qualifier,
               long ts,
               byte[] value)
Add the specified column and value, with the specified timestamp as its version to this Put operation.

Parameters:
family - family name
qualifier - column qualifier
ts - version timestamp
value - column value

add

public Put add(KeyValue kv)
        throws IOException
Add the specified KeyValue to this Put operation. Operation assumes that the passed KeyValue is immutable and its backing array will not be modified for the duration of this Put.

Parameters:
kv -
Throws:
IOException

getFamilyMap

public Map<byte[],List<KeyValue>> getFamilyMap()
Method for retrieving the put's familyMap

Returns:
familyMap

getRow

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

Returns:
row

getRowLock

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

Returns:
RowLock

getLockId

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

Returns:
lockId

isEmpty

public boolean isEmpty()
Method to check if the familyMap is empty

Returns:
true if empty, false otherwise

getTimeStamp

public long getTimeStamp()
Returns:
Timestamp

setTimeStamp

public Put setTimeStamp(long timestamp)
Method for setting the timestamp

Parameters:
timestamp -

numFamilies

public int numFamilies()
Returns:
the number of different families included in this put

size

public int size()
Returns:
the total number of KeyValues that will be added with this put

getWriteToWAL

public boolean getWriteToWAL()
Returns:
true if edits should be applied to WAL, false if not

setWriteToWAL

public void setWriteToWAL(boolean write)
Set whether this Put should be written to the WAL or not. Not writing the WAL means you may lose edits on server crash.

Parameters:
write - true if edits should be written to WAL, false if not

toString

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

compareTo

public int compareTo(Put p)
Specified by:
compareTo in interface Comparable<Put>

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.

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 © 2009 The Apache Software Foundation