Class ThriftTable
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Table
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate class
private class
A scanner to perform scan from thrift server getScannerResults is used in this scannerNested classes/interfaces inherited from interface org.apache.hadoop.hbase.client.Table
Table.CheckAndMutateBuilder, Table.CheckAndMutateWithFilterBuilder
-
Field Summary
Modifier and TypeFieldDescriptionprivate org.apache.hadoop.hbase.thrift2.generated.THBaseService.Client
private org.apache.hadoop.conf.Configuration
private int
private final int
private TableName
private ByteBuffer
private org.apache.thrift.transport.TTransport
-
Constructor Summary
ConstructorDescriptionThriftTable
(TableName tableName, org.apache.hadoop.hbase.thrift2.generated.THBaseService.Client client, org.apache.thrift.transport.TTransport tTransport, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionAppends values to one or more columns within a single row.void
Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations.<R> void
batchCallback
(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) Same asTable.batch(List, Object[])
, but with a callback.checkAndMutate
(byte[] row, byte[] family) Atomically checks if a row/family/qualifier value matches the expected value.boolean
checkAndMutate
(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, RowMutations mutation) Atomically checks if a row/family/qualifier value matches the expected value.checkAndMutate
(byte[] row, Filter filter) Atomically checks if a row matches the specified filter.checkAndMutate
(List<CheckAndMutate> checkAndMutates) Batch version of checkAndMutate.checkAndMutate
(CheckAndMutate checkAndMutate) checkAndMutate that atomically checks if a row matches the specified condition.void
close()
Releases any resources held or pending changes in internal buffers.coprocessorService
(byte[] row) Creates and returns aRpcChannel
instance connected to the table region containing the specified row.void
Batch Deletes the specified cells/rows from the table.void
Deletes the specified cells/row.boolean[]
Test for the existence of columns in the table, as specified by the Gets.boolean
Test for the existence of columns in the table, as specified by the Get.Result[]
Extracts specified cells from the given rows, as a batch.Extracts certain cells from a given row.org.apache.hadoop.conf.Configuration
Returns theConfiguration
object used by this instance.Gets thetable descriptor
for this table.getName()
Gets the fully qualified table name instance of this table.long
getOperationTimeout
(TimeUnit unit) Get timeout of each operation in Table instance.long
getReadRpcTimeout
(TimeUnit unit) Get timeout of each rpc read request in this Table instance.Gets theRegionLocator
for this table.long
getRpcTimeout
(TimeUnit unit) Get timeout of each rpc request in this Table instance.getScanner
(byte[] family) Gets a scanner on the current table for the given family.getScanner
(byte[] family, byte[] qualifier) Gets a scanner on the current table for the given family and qualifier.getScanner
(Scan scan) Returns a scanner on the current table as specified by theScan
object.long
getWriteRpcTimeout
(TimeUnit unit) Get timeout of each rpc write request in this Table instance.Increments one or more columns within a single row.Performs multiple mutations atomically on a single row.void
Batch puts the specified data into the table.void
Puts some data in the table.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.client.Table
batchCoprocessorService, batchCoprocessorService, checkAndDelete, checkAndDelete, checkAndDelete, checkAndMutate, checkAndPut, checkAndPut, checkAndPut, coprocessorService, coprocessorService, existsAll, getOperationTimeout, getReadRpcTimeout, getRequestAttributes, getRpcTimeout, getTableDescriptor, getWriteRpcTimeout, incrementColumnValue, incrementColumnValue, setOperationTimeout, setReadRpcTimeout, setRpcTimeout, setWriteRpcTimeout
-
Field Details
-
tableName
-
conf
-
tTransport
-
client
-
tableNameInBytes
-
operationTimeout
-
scannerCaching
-
-
Constructor Details
-
ThriftTable
public ThriftTable(TableName tableName, org.apache.hadoop.hbase.thrift2.generated.THBaseService.Client client, org.apache.thrift.transport.TTransport tTransport, org.apache.hadoop.conf.Configuration conf)
-
-
Method Details
-
getName
Description copied from interface:Table
Gets the fully qualified table name instance of this table. -
getConfiguration
Description copied from interface:Table
Returns theConfiguration
object used by this instance.The reference returned is not a copy, so any change made to it will affect this instance.
- Specified by:
getConfiguration
in interfaceTable
-
getDescriptor
Description copied from interface:Table
Gets thetable descriptor
for this table.- Specified by:
getDescriptor
in interfaceTable
- Throws:
IOException
- if a remote or network exception occurs.
-
exists
Description copied from interface:Table
Test for the existence of columns in the table, as specified by the Get.This will return true if the Get matches one or more keys, false if not.
This is a server-side call so it prevents any data from being transfered to the client.
- Specified by:
exists
in interfaceTable
- Parameters:
get
- the Get- Returns:
- true if the specified Get matches one or more keys, false if not
- Throws:
IOException
- e
-
exists
Description copied from interface:Table
Test for the existence of columns in the table, as specified by the Gets.This will return an array of booleans. Each value will be true if the related Get matches one or more keys, false if not.
This is a server-side call so it prevents any data from being transferred to the client.
- Specified by:
exists
in interfaceTable
- Parameters:
gets
- the Gets- Returns:
- Array of boolean. True if the specified Get matches one or more keys, false if not.
- Throws:
IOException
- e
-
batch
Description copied from interface:Table
Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations. The ordering of execution of the actions is not defined. Meaning if you do a Put and a Get in the sameTable.batch(java.util.List<? extends org.apache.hadoop.hbase.client.Row>, java.lang.Object[])
call, you will not necessarily be guaranteed that the Get returns what the Put had put.- Specified by:
batch
in interfaceTable
- Parameters:
actions
- list of Get, Put, Delete, Increment, Append, RowMutations.results
- Empty Object[], same size as actions. Provides access to partial results, in case an exception is thrown. A null in the result array means that the call for that action failed, even after retries. The order of the objects in the results array corresponds to the order of actions in the request list.- Throws:
IOException
-
batchCallback
public <R> void batchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws IOException Description copied from interface:Table
Same asTable.batch(List, Object[])
, but with a callback.- Specified by:
batchCallback
in interfaceTable
- Throws:
IOException
-
get
Description copied from interface:Table
Extracts certain cells from a given row.- Specified by:
get
in interfaceTable
- Parameters:
get
- The object that specifies what data to fetch and from which row.- Returns:
- The data coming from the specified row, if it exists. If the row specified doesn't
exist, the
Result
instance returned won't contain anyKeyValue
, as indicated byResult.isEmpty()
. - Throws:
IOException
- if a remote or network exception occurs.
-
get
Description copied from interface:Table
Extracts specified cells from the given rows, as a batch.- Specified by:
get
in interfaceTable
- Parameters:
gets
- The objects that specify what data to fetch and from which rows.- Returns:
- The data coming from the specified rows, if it exists. If the row specified doesn't
exist, the
Result
instance returned won't contain anyCell
s, as indicated byResult.isEmpty()
. If there are any failures even after retries, there will be anull
in the results' array for those Gets, AND an exception will be thrown. The ordering of the Result array corresponds to the order of the list of passed in Gets. - Throws:
IOException
- if a remote or network exception occurs.
-
getScanner
Description copied from interface:Table
Returns a scanner on the current table as specified by theScan
object. Note that the passedScan
's start row and caching properties maybe changed.- Specified by:
getScanner
in interfaceTable
- Parameters:
scan
- A configuredScan
object.- Returns:
- A scanner.
- Throws:
IOException
- if a remote or network exception occurs.
-
getScanner
Description copied from interface:Table
Gets a scanner on the current table for the given family.- Specified by:
getScanner
in interfaceTable
- Parameters:
family
- The column family to scan.- Returns:
- A scanner.
- Throws:
IOException
- if a remote or network exception occurs.
-
getScanner
Description copied from interface:Table
Gets a scanner on the current table for the given family and qualifier.- Specified by:
getScanner
in interfaceTable
- Parameters:
family
- The column family to scan.qualifier
- The column qualifier to scan.- Returns:
- A scanner.
- Throws:
IOException
- if a remote or network exception occurs.
-
put
Description copied from interface:Table
Puts some data in the table.- Specified by:
put
in interfaceTable
- Parameters:
put
- The data to put.- Throws:
IOException
- if a remote or network exception occurs.
-
put
Description copied from interface:Table
Batch puts the specified data into the table.This can be used for group commit, or for submitting user defined batches. Before sending a batch of mutations to the server, the client runs a few validations on the input list. If an error is found, for example, a mutation was supplied but was missing it's column an
IllegalArgumentException
will be thrown and no mutations will be applied. If there are any failures even after retries, aRetriesExhaustedWithDetailsException
will be thrown. RetriesExhaustedWithDetailsException contains lists of failed mutations and corresponding remote exceptions. The ordering of mutations and exceptions in the encapsulating exception corresponds to the order of the input list of Put requests.- Specified by:
put
in interfaceTable
- Parameters:
puts
- The list of mutations to apply.- Throws:
IOException
- if a remote or network exception occurs.
-
delete
Description copied from interface:Table
Deletes the specified cells/row.- Specified by:
delete
in interfaceTable
- Parameters:
delete
- The object that specifies what to delete.- Throws:
IOException
- if a remote or network exception occurs.
-
delete
Description copied from interface:Table
Batch Deletes the specified cells/rows from the table.If a specified row does not exist,
Delete
will report as though sucessful delete; no exception will be thrown. If there are any failures even after retries, aRetriesExhaustedWithDetailsException
will be thrown. RetriesExhaustedWithDetailsException contains lists of failedDelete
s and corresponding remote exceptions.- Specified by:
delete
in interfaceTable
- Parameters:
deletes
- List of things to delete. The input list gets modified by this method. All successfully appliedDelete
s in the list are removed (in particular it gets re-ordered, so the order in which the elements are inserted in the list gives no guarantee as to the order in which theDelete
s are executed).- Throws:
IOException
- if a remote or network exception occurs. In that case thedeletes
argument will contain theDelete
instances that have not be successfully applied.
-
checkAndMutate
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, RowMutations mutation) throws IOException Description copied from interface:Table
Atomically checks if a row/family/qualifier value matches the expected value. If it does, it performs the row mutations. If the passed value is null, the check is for the lack of column (ie: non-existence) The expected value argument of this call is on the left and the current value of the cell is on the right side of the comparison operator. Ie. eg. GREATER operator means expected value > existing <=> perform row mutations.- Specified by:
checkAndMutate
in interfaceTable
- Parameters:
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkop
- the comparison operatorvalue
- the expected valuemutation
- mutations to perform if check succeeds- Returns:
- true if the new put was executed, false otherwise
- Throws:
IOException
- e
-
checkAndMutate
Description copied from interface:Table
Atomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the Put/Delete/RowMutations.Use the returned
Table.CheckAndMutateBuilder
to construct your request and then execute it. This is a fluent style API, the code is like:table.checkAndMutate(row, family).qualifier(qualifier).ifNotExists().thenPut(put);
- Specified by:
checkAndMutate
in interfaceTable
-
checkAndMutate
Description copied from interface:Table
Atomically checks if a row matches the specified filter. If it does, it adds the Put/Delete/RowMutations.Use the returned
Table.CheckAndMutateWithFilterBuilder
to construct your request and then execute it. This is a fluent style API, the code is like:table.checkAndMutate(row, filter).thenPut(put);
- Specified by:
checkAndMutate
in interfaceTable
-
checkAndMutate
Description copied from interface:Table
checkAndMutate that atomically checks if a row matches the specified condition. If it does, it performs the specified action.- Specified by:
checkAndMutate
in interfaceTable
- Parameters:
checkAndMutate
- The CheckAndMutate object.- Returns:
- A CheckAndMutateResult object that represents the result for the CheckAndMutate.
-
checkAndMutate
Description copied from interface:Table
Batch version of checkAndMutate. The specified CheckAndMutates are batched only in the sense that they are sent to a RS in one RPC, but each CheckAndMutate operation is still executed atomically (and thus, each may fail independently of others).- Specified by:
checkAndMutate
in interfaceTable
- Parameters:
checkAndMutates
- The list of CheckAndMutate.- Returns:
- A list of CheckAndMutateResult objects that represents the result for each CheckAndMutate.
-
mutateRow
Description copied from interface:Table
- Specified by:
mutateRow
in interfaceTable
- Parameters:
rm
- object that specifies the set of mutations to perform atomically- Returns:
- results of Increment/Append operations
- Throws:
IOException
- if a remote or network exception occurs.
-
append
Description copied from interface:Table
Appends values to one or more columns within a single row.This operation guaranteed atomicity to readers. Appends are done under a single row lock, so write operations to a row are synchronized, and readers are guaranteed to see this operation fully completed.
- Specified by:
append
in interfaceTable
- Parameters:
append
- object that specifies the columns and values to be appended- Returns:
- values of columns after the append operation (maybe null)
- Throws:
IOException
- e
-
increment
Description copied from interface:Table
Increments one or more columns within a single row.This operation ensures atomicity to readers. Increments are done under a single row lock, so write operations to a row are synchronized, and readers are guaranteed to see this operation fully completed.
- Specified by:
increment
in interfaceTable
- Parameters:
increment
- object that specifies the columns and amounts to be used for the increment operations- Returns:
- values of columns after the increment
- Throws:
IOException
- e
-
close
Description copied from interface:Table
Releases any resources held or pending changes in internal buffers.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceTable
- Throws:
IOException
- if a remote or network exception occurs.
-
getRpcTimeout
Description copied from interface:Table
Get timeout of each rpc request in this Table instance. It will be overridden by a more specific rpc timeout config such as readRpcTimeout or writeRpcTimeout.- Specified by:
getRpcTimeout
in interfaceTable
- Parameters:
unit
- the unit of time the timeout to be represented in- Returns:
- rpc timeout in the specified time unit
- See Also:
-
getReadRpcTimeout
Description copied from interface:Table
Get timeout of each rpc read request in this Table instance.- Specified by:
getReadRpcTimeout
in interfaceTable
- Parameters:
unit
- the unit of time the timeout to be represented in- Returns:
- read rpc timeout in the specified time unit
-
getWriteRpcTimeout
Description copied from interface:Table
Get timeout of each rpc write request in this Table instance.- Specified by:
getWriteRpcTimeout
in interfaceTable
- Parameters:
unit
- the unit of time the timeout to be represented in- Returns:
- write rpc timeout in the specified time unit
-
getOperationTimeout
Description copied from interface:Table
Get timeout of each operation in Table instance.- Specified by:
getOperationTimeout
in interfaceTable
- Parameters:
unit
- the unit of time the timeout to be represented in- Returns:
- operation rpc timeout in the specified time unit
-
coprocessorService
Description copied from interface:Table
Creates and returns aRpcChannel
instance connected to the table region containing the specified row. The row given does not actually have to exist. Whichever region would contain the row based on start and end keys will be used. Note that therow
parameter is also not passed to the coprocessor handler registered for this protocol, unless therow
is separately passed as an argument in the service request. The parameter here is only used to locate the region used to handle the call.The obtained
RpcChannel
instance can be used to access a published coprocessorService
using standard protobuf service invocations:CoprocessorRpcChannel channel = myTable.coprocessorService(rowkey); MyService.BlockingInterface service = MyService.newBlockingStub(channel); MyCallRequest request = MyCallRequest.newBuilder() ... .build(); MyCallResponse response = service.myCall(null, request);
- Specified by:
coprocessorService
in interfaceTable
- Parameters:
row
- The row key used to identify the remote region location- Returns:
- A CoprocessorRpcChannel instance
-
getRegionLocator
Description copied from interface:Table
Gets theRegionLocator
for this table.- Specified by:
getRegionLocator
in interfaceTable
- Throws:
IOException
-