org.hbase.async
Class PutRequest

java.lang.Object
  extended by org.hbase.async.HBaseRpc
      extended by org.hbase.async.PutRequest
All Implemented Interfaces:
HBaseRpc.HasFamily, HBaseRpc.HasKey, HBaseRpc.HasQualifier, HBaseRpc.HasQualifiers, HBaseRpc.HasTable, HBaseRpc.HasTimestamp, HBaseRpc.HasValue, HBaseRpc.HasValues

public final class PutRequest
extends HBaseRpc
implements HBaseRpc.HasTable, HBaseRpc.HasKey, HBaseRpc.HasFamily, HBaseRpc.HasQualifiers, HBaseRpc.HasValues, HBaseRpc.HasQualifier, HBaseRpc.HasValue

Puts some data into HBase.

A note on passing byte arrays in argument

None of the method that receive a byte[] in argument will copy it. For more info, please refer to the documentation of HBaseRpc.

A note on passing Strings in argument

All strings are assumed to use the platform's default charset.

A note on passing timestamps in argument

HBase orders all the writes based on timestamps from PutRequest irrespective of the actual order in which they're received or stored by a RegionServer. In other words, if you send a first PutRequest with timestamp T, and then later send another one for the same table, key, family and qualifier, but with timestamp T - 1, then the second write will look like it was applied before the first one when you read this cell back from HBase. When manually setting timestamps, it is thus strongly recommended to use real UNIX timestamps in milliseconds, e.g. from System.currentTimeMillis().

If you want to let HBase set the timestamp on a write at the time it's applied within the RegionServer, then use KeyValue.TIMESTAMP_NOW as a timestamp. The timestamp is set right before being written to the WAL (Write Ahead Log). Note however that this has a subtle consequence: if a write succeeds from the server's point of view, but fails from the client's point of view (maybe because the client got disconnected from the server before the server could acknowledge the write), then if the client retries the write it will create another version of the cell with a different timestamp.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.hbase.async.HBaseRpc
HBaseRpc.HasFamily, HBaseRpc.HasKey, HBaseRpc.HasQualifier, HBaseRpc.HasQualifiers, HBaseRpc.HasTable, HBaseRpc.HasTimestamp, HBaseRpc.HasValue, HBaseRpc.HasValues
 
Constructor Summary
PutRequest(byte[] table, byte[] key, byte[] family, byte[][] qualifiers, byte[][] values)
          Constructor for multiple columns using current time.
PutRequest(byte[] table, byte[] key, byte[] family, byte[][] qualifiers, byte[][] values, long timestamp)
          Constructor for multiple columns with a specific timestamp.
PutRequest(byte[] table, byte[] key, byte[] family, byte[][] qualifiers, byte[][] values, long timestamp, RowLock lock)
          Constructor for multiple columns with current time and explicit row lock.
PutRequest(byte[] table, byte[] key, byte[] family, byte[] qualifier, byte[] value)
          Constructor using current time.
PutRequest(byte[] table, byte[] key, byte[] family, byte[] qualifier, byte[] value, long timestamp)
          Constructor for a specific timestamp.
PutRequest(byte[] table, byte[] key, byte[] family, byte[] qualifier, byte[] value, long timestamp, RowLock lock)
          Constructor using current time and an explicit row lock.
PutRequest(byte[] table, byte[] key, byte[] family, byte[] qualifier, byte[] value, RowLock lock)
          Constructor using an explicit row lock.
PutRequest(byte[] table, KeyValue kv)
          Constructor from a KeyValue.
PutRequest(byte[] table, KeyValue kv, RowLock lock)
          Constructor from a KeyValue with an explicit row lock.
PutRequest(String table, String key, String family, String qualifier, String value)
          Convenience constructor from strings (higher overhead).
PutRequest(String table, String key, String family, String qualifier, String value, RowLock lock)
          Convenience constructor with explicit row lock (higher overhead).
 
Method Summary
 byte[] family()
          Returns the family this RPC is for.
 byte[] key()
          Returns the row key this RPC is for.
 byte[] qualifier()
          Returns the first qualifier of the set of edits in this RPC.
 byte[][] qualifiers()
          Returns the column qualifiers this RPC is for.
 void setBufferable(boolean bufferable)
          Sets whether or not this RPC is can be buffered on the client side.
 void setDurable(boolean durable)
          Changes the durability setting of this edit.
 byte[] table()
          Returns the name of the table this RPC is for.
 long timestamp()
          Returns the strictly positive timestamp contained in this RPC.
 String toString()
           
 byte[] value()
          Returns the first value of the set of edits in this RPC.
 byte[][] values()
          Returns the values contained in this RPC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.hbase.async.HBaseRpc.HasFamily
family
 

Constructor Detail

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[] qualifier,
                  byte[] value)
Constructor using current time. These byte arrays will NOT be copied.

Note: If you want to set your own timestamp, use PutRequest(byte[], byte[], byte[], byte[], byte[], long) instead. This constructor will let the RegionServer assign the timestamp to this write at the time using System.currentTimeMillis() right before the write is persisted to the WAL.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifier - The column qualifier to edit in that family.
value - The value to store.

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[][] qualifiers,
                  byte[][] values)
Constructor for multiple columns using current time. These byte arrays will NOT be copied.

Note: If you want to set your own timestamp, use PutRequest(byte[], byte[], byte[], byte[][], byte[][], long) instead. This constructor will let the RegionServer assign the timestamp to this write at the time using System.currentTimeMillis() right before the write is persisted to the WAL.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifiers - The column qualifiers to edit in that family.
values - The corresponding values to store.
Throws:
IllegalArgumentException - if qualifiers.length == 0 or if qualifiers.length != values.length
Since:
1.3

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[] qualifier,
                  byte[] value,
                  long timestamp)
Constructor for a specific timestamp. These byte arrays will NOT be copied.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifier - The column qualifier to edit in that family.
value - The value to store.
timestamp - The timestamp to set on this edit.
Since:
1.2

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[][] qualifiers,
                  byte[][] values,
                  long timestamp)
Constructor for multiple columns with a specific timestamp. These byte arrays will NOT be copied.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifiers - The column qualifiers to edit in that family.
values - The corresponding values to store.
timestamp - The timestamp to set on this edit.
Throws:
IllegalArgumentException - if qualifiers.length == 0 or if qualifiers.length != values.length
Since:
1.3

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[] qualifier,
                  byte[] value,
                  RowLock lock)
Constructor using an explicit row lock. These byte arrays will NOT be copied.

Note: If you want to set your own timestamp, use PutRequest(byte[], byte[], byte[], byte[], byte[], long, RowLock) instead. This constructor will let the RegionServer assign the timestamp to this write at the time using System.currentTimeMillis() right before the write is persisted to the WAL.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifier - The column qualifier to edit in that family.
value - The value to store.
lock - An explicit row lock to use with this request.

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[] qualifier,
                  byte[] value,
                  long timestamp,
                  RowLock lock)
Constructor using current time and an explicit row lock. These byte arrays will NOT be copied.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifier - The column qualifier to edit in that family.
value - The value to store.
timestamp - The timestamp to set on this edit.
lock - An explicit row lock to use with this request.
Since:
1.2

PutRequest

public PutRequest(byte[] table,
                  byte[] key,
                  byte[] family,
                  byte[][] qualifiers,
                  byte[][] values,
                  long timestamp,
                  RowLock lock)
Constructor for multiple columns with current time and explicit row lock. These byte arrays will NOT be copied.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifiers - The column qualifiers to edit in that family.
values - The corresponding values to store.
timestamp - The timestamp to set on this edit.
lock - An explicit row lock to use with this request.
Throws:
IllegalArgumentException - if qualifiers.length == 0 or if qualifiers.length != values.length
Since:
1.3

PutRequest

public PutRequest(String table,
                  String key,
                  String family,
                  String qualifier,
                  String value)
Convenience constructor from strings (higher overhead).

Note: If you want to set your own timestamp, use PutRequest(byte[], byte[], byte[], byte[], byte[], long) instead. This constructor will let the RegionServer assign the timestamp to this write at the time using System.currentTimeMillis() right before the write is persisted to the WAL.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifier - The column qualifier to edit in that family.
value - The value to store.

PutRequest

public PutRequest(String table,
                  String key,
                  String family,
                  String qualifier,
                  String value,
                  RowLock lock)
Convenience constructor with explicit row lock (higher overhead).

Note: If you want to set your own timestamp, use PutRequest(byte[], byte[], byte[], byte[], byte[], long, RowLock) instead. This constructor will let the RegionServer assign the timestamp to this write at the time using System.currentTimeMillis() right before the write is persisted to the WAL.

Parameters:
table - The table to edit.
key - The key of the row to edit in that table.
family - The column family to edit in that table.
qualifier - The column qualifier to edit in that family.
value - The value to store.
lock - An explicit row lock to use with this request.

PutRequest

public PutRequest(byte[] table,
                  KeyValue kv)
Constructor from a KeyValue.

Parameters:
table - The table to edit.
kv - The KeyValue to store.
Since:
1.1

PutRequest

public PutRequest(byte[] table,
                  KeyValue kv,
                  RowLock lock)
Constructor from a KeyValue with an explicit row lock.

Parameters:
table - The table to edit.
kv - The KeyValue to store.
lock - An explicit row lock to use with this request.
Since:
1.1
Method Detail

table

public byte[] table()
Description copied from interface: HBaseRpc.HasTable
Returns the name of the table this RPC is for.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
table in interface HBaseRpc.HasTable

key

public byte[] key()
Description copied from interface: HBaseRpc.HasKey
Returns the row key this RPC is for.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
key in interface HBaseRpc.HasKey

qualifier

public byte[] qualifier()
Returns the first qualifier of the set of edits in this RPC. Returns the column qualifier this RPC is for.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
qualifier in interface HBaseRpc.HasQualifier

qualifiers

public byte[][] qualifiers()
Returns the column qualifiers this RPC is for.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
qualifiers in interface HBaseRpc.HasQualifiers
Since:
1.3

value

public byte[] value()
Returns the first value of the set of edits in this RPC. Returns the value contained in this RPC.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
value in interface HBaseRpc.HasValue

values

public byte[][] values()
Returns the values contained in this RPC.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
values in interface HBaseRpc.HasValues
Since:
1.3

toString

public String toString()
Overrides:
toString in class HBaseRpc

setBufferable

public final void setBufferable(boolean bufferable)
Sets whether or not this RPC is can be buffered on the client side. The default is true.

Setting this to false bypasses the client-side buffering, which is used to send RPCs in batches for greater throughput, and causes this RPC to be sent directly to the server.

Parameters:
bufferable - Whether or not this RPC can be buffered (i.e. delayed) before being sent out to HBase.
See Also:
HBaseClient.setFlushInterval(short)

setDurable

public final void setDurable(boolean durable)
Changes the durability setting of this edit. The default is true. Make sure you've read and understood the data durability section before setting this to false.

Parameters:
durable - Whether or not this edit should be stored with data durability guarantee.

family

public final byte[] family()
Description copied from interface: HBaseRpc.HasFamily
Returns the family this RPC is for.

DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED.

Specified by:
family in interface HBaseRpc.HasFamily

timestamp

public final long timestamp()
Description copied from interface: HBaseRpc.HasTimestamp
Returns the strictly positive timestamp contained in this RPC.

Specified by:
timestamp in interface HBaseRpc.HasTimestamp