org.apache.hadoop.hbase.thrift2
Class ThriftHBaseServiceHandler

java.lang.Object
  extended by org.apache.hadoop.hbase.thrift2.ThriftHBaseServiceHandler
All Implemented Interfaces:
THBaseService.Iface

public class ThriftHBaseServiceHandler
extends Object
implements THBaseService.Iface

This class is a glue object that connects Thrift RPC calls to the HBase client API primarily defined in the HTableInterface.


Method Summary
 boolean checkAndDelete(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TDelete deleteSingle)
          Atomically checks if a row/family/qualifier value matches the expected value.
 boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family, ByteBuffer qualifier, ByteBuffer value, TPut put)
          Atomically checks if a row/family/qualifier value matches the expected value.
 void closeScanner(int scannerId)
          Closes the scanner.
 List<TDelete> deleteMultiple(ByteBuffer table, List<TDelete> deletes)
          Bulk commit a List of TDeletes to the table.
 void deleteSingle(ByteBuffer table, TDelete deleteSingle)
          Deletes as specified by the TDelete.
 boolean exists(ByteBuffer table, TGet get)
          Test for the existence of columns in the table, as specified in the TGet.
 TResult get(ByteBuffer table, TGet get)
          Method for getting data from a row.
 List<TResult> getMultiple(ByteBuffer table, List<TGet> gets)
          Method for getting multiple rows.
 List<TResult> getScannerResults(ByteBuffer table, TScan scan, int numRows)
          Get results for the provided TScan object.
 List<TResult> getScannerRows(int scannerId, int numRows)
          Grabs multiple rows from a Scanner.
 TResult increment(ByteBuffer table, TIncrement increment)
           
 void mutateRow(ByteBuffer table, TRowMutations rowMutations)
          mutateRow performs multiple mutations atomically on a single row.
static THBaseService.Iface newInstance(org.apache.hadoop.conf.Configuration conf, ThriftMetrics metrics)
           
 int openScanner(ByteBuffer table, TScan scan)
          Get a Scanner for the provided TScan object.
 void put(ByteBuffer table, TPut put)
          Commit a TPut to a table.
 void putMultiple(ByteBuffer table, List<TPut> puts)
          Commit a List of Puts to the table.
protected  ResultScanner removeScanner(int id)
          Removes the scanner associated with the specified ID from the internal HashMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static THBaseService.Iface newInstance(org.apache.hadoop.conf.Configuration conf,
                                              ThriftMetrics metrics)

removeScanner

protected ResultScanner removeScanner(int id)
Removes the scanner associated with the specified ID from the internal HashMap.

Parameters:
id - of the Scanner to remove
Returns:
the removed Scanner, or null if the Id is invalid

exists

public boolean exists(ByteBuffer table,
                      TGet get)
               throws TIOError,
                      org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Test for the existence of columns in the table, as specified in the TGet.

Specified by:
exists in interface THBaseService.Iface
Parameters:
table - the table to check on
get - the TGet to check for
Returns:
true if the specified TGet matches one or more keys, false if not
Throws:
TIOError
org.apache.thrift.TException

get

public TResult get(ByteBuffer table,
                   TGet get)
            throws TIOError,
                   org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Method for getting data from a row. If the row cannot be found an empty Result is returned. This can be checked by the empty field of the TResult

Specified by:
get in interface THBaseService.Iface
Parameters:
table - the table to get from
get - the TGet to fetch
Returns:
the result
Throws:
TIOError
org.apache.thrift.TException

getMultiple

public List<TResult> getMultiple(ByteBuffer table,
                                 List<TGet> gets)
                          throws TIOError,
                                 org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Method for getting multiple rows. If a row cannot be found there will be a null value in the result list for that TGet at the same position. So the Results are in the same order as the TGets.

Specified by:
getMultiple in interface THBaseService.Iface
Parameters:
table - the table to get from
gets - a list of TGets to fetch, the Result list will have the Results at corresponding positions or null if there was an error
Throws:
TIOError
org.apache.thrift.TException

put

public void put(ByteBuffer table,
                TPut put)
         throws TIOError,
                org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Commit a TPut to a table.

Specified by:
put in interface THBaseService.Iface
Parameters:
table - the table to put data in
put - the TPut to put
Throws:
TIOError
org.apache.thrift.TException

checkAndPut

public boolean checkAndPut(ByteBuffer table,
                           ByteBuffer row,
                           ByteBuffer family,
                           ByteBuffer qualifier,
                           ByteBuffer value,
                           TPut put)
                    throws TIOError,
                           org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Atomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the TPut.

Specified by:
checkAndPut in interface THBaseService.Iface
Parameters:
table - to check in and put to
row - row to check
family - column family to check
qualifier - column qualifier to check
value - the expected value, if not provided the check is for the non-existence of the column in question
put - the TPut to put if the check succeeds
Returns:
true if the new put was executed, false otherwise
Throws:
TIOError
org.apache.thrift.TException

putMultiple

public void putMultiple(ByteBuffer table,
                        List<TPut> puts)
                 throws TIOError,
                        org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Commit a List of Puts to the table.

Specified by:
putMultiple in interface THBaseService.Iface
Parameters:
table - the table to put data in
puts - a list of TPuts to commit
Throws:
TIOError
org.apache.thrift.TException

deleteSingle

public void deleteSingle(ByteBuffer table,
                         TDelete deleteSingle)
                  throws TIOError,
                         org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Deletes as specified by the TDelete. Note: "delete" is a reserved keyword and cannot be used in Thrift thus the inconsistent naming scheme from the other functions.

Specified by:
deleteSingle in interface THBaseService.Iface
Parameters:
table - the table to delete from
deleteSingle - the TDelete to delete
Throws:
TIOError
org.apache.thrift.TException

deleteMultiple

public List<TDelete> deleteMultiple(ByteBuffer table,
                                    List<TDelete> deletes)
                             throws TIOError,
                                    org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Bulk commit a List of TDeletes to the table. This returns a list of TDeletes that were not executed. So if everything succeeds you'll receive an empty list.

Specified by:
deleteMultiple in interface THBaseService.Iface
Parameters:
table - the table to delete from
deletes - list of TDeletes to delete
Throws:
TIOError
org.apache.thrift.TException

checkAndDelete

public boolean checkAndDelete(ByteBuffer table,
                              ByteBuffer row,
                              ByteBuffer family,
                              ByteBuffer qualifier,
                              ByteBuffer value,
                              TDelete deleteSingle)
                       throws TIOError,
                              org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Atomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the delete.

Specified by:
checkAndDelete in interface THBaseService.Iface
Parameters:
table - to check in and delete from
row - row to check
family - column family to check
qualifier - column qualifier to check
value - the expected value, if not provided the check is for the non-existence of the column in question
deleteSingle - the TDelete to execute if the check succeeds
Returns:
true if the new delete was executed, false otherwise
Throws:
TIOError
org.apache.thrift.TException

increment

public TResult increment(ByteBuffer table,
                         TIncrement increment)
                  throws TIOError,
                         org.apache.thrift.TException
Specified by:
increment in interface THBaseService.Iface
Throws:
TIOError
org.apache.thrift.TException

openScanner

public int openScanner(ByteBuffer table,
                       TScan scan)
                throws TIOError,
                       org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Get a Scanner for the provided TScan object.

Specified by:
openScanner in interface THBaseService.Iface
Parameters:
table - the table to get the Scanner for
scan - the scan object to get a Scanner for
Returns:
Scanner Id to be used with other scanner procedures
Throws:
TIOError
org.apache.thrift.TException

getScannerRows

public List<TResult> getScannerRows(int scannerId,
                                    int numRows)
                             throws TIOError,
                                    TIllegalArgument,
                                    org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Grabs multiple rows from a Scanner.

Specified by:
getScannerRows in interface THBaseService.Iface
Parameters:
scannerId - the Id of the Scanner to return rows from. This is an Id returned from the openScanner function.
numRows - number of rows to return
Returns:
Between zero and numRows TResults
Throws:
TIOError
TIllegalArgument
org.apache.thrift.TException

closeScanner

public void closeScanner(int scannerId)
                  throws TIOError,
                         TIllegalArgument,
                         org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Closes the scanner. Should be called to free server side resources timely. Typically close once the scanner is not needed anymore, i.e. after looping over it to get all the required rows.

Specified by:
closeScanner in interface THBaseService.Iface
Parameters:
scannerId - the Id of the Scanner to close *
Throws:
TIOError
TIllegalArgument
org.apache.thrift.TException

getScannerResults

public List<TResult> getScannerResults(ByteBuffer table,
                                       TScan scan,
                                       int numRows)
                                throws TIOError,
                                       org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
Get results for the provided TScan object. This helper function opens a scanner, get the results and close the scanner.

Specified by:
getScannerResults in interface THBaseService.Iface
Parameters:
table - the table to get the Scanner for
scan - the scan object to get a Scanner for
numRows - number of rows to return
Returns:
between zero and numRows TResults
Throws:
TIOError
org.apache.thrift.TException

mutateRow

public void mutateRow(ByteBuffer table,
                      TRowMutations rowMutations)
               throws TIOError,
                      org.apache.thrift.TException
Description copied from interface: THBaseService.Iface
mutateRow performs multiple mutations atomically on a single row.

Specified by:
mutateRow in interface THBaseService.Iface
Parameters:
table - table to apply the mutations
rowMutations - mutations to apply
Throws:
TIOError
org.apache.thrift.TException


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