@InterfaceAudience.Public @InterfaceStability.Evolving public interface Table extends Closeable
Connection
and call close()
afterwards.
Table can be used to get, put, delete or scan data from a table.
ConnectionFactory
,
Connection
,
Admin
,
RegionLocator
Modifier and Type | Method and Description |
---|---|
Result |
append(Append append)
Appends values to one or more columns within a single row.
|
Object[] |
batch(List<? extends Row> actions)
Deprecated.
If any exception is thrown by one of the actions, there is no way to
retrieve the partially executed results. Use
batch(List, Object[]) instead. |
void |
batch(List<? extends Row> actions,
Object[] results)
Method that does a batch call on Deletes, Gets, Puts, Increments and Appends.
|
<R> Object[] |
batchCallback(List<? extends Row> actions,
Batch.Callback<R> callback)
Deprecated.
If any exception is thrown by one of the actions, there is no way to retrieve the
partially executed results. Use
batchCallback(List, Object[],
org.apache.hadoop.hbase.client.coprocessor.Batch.Callback) instead. |
<R> void |
batchCallback(List<? extends Row> actions,
Object[] results,
Batch.Callback<R> callback)
Same as
batch(List, Object[]) , but with a callback. |
<R extends com.google.protobuf.Message> |
batchCoprocessorService(com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor,
com.google.protobuf.Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype)
Creates an instance of the given
Service subclass for each table
region spanning the range from the startKey row to endKey row (inclusive), all
the invocations to the same region server will be batched into one call. |
<R extends com.google.protobuf.Message> |
batchCoprocessorService(com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor,
com.google.protobuf.Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype,
Batch.Callback<R> callback)
Creates an instance of the given
Service subclass for each table
region spanning the range from the startKey row to endKey row (inclusive), all
the invocations to the same region server will be batched into one call. |
boolean |
checkAndDelete(byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Delete delete)
Atomically checks if a row/family/qualifier value matches the expected
value.
|
boolean |
checkAndDelete(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
Delete delete)
Atomically checks if a row/family/qualifier value matches the expected
value.
|
boolean |
checkAndMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
RowMutations mutation)
Atomically checks if a row/family/qualifier value matches the expected value.
|
boolean |
checkAndPut(byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Put put)
Atomically checks if a row/family/qualifier value matches the expected
value.
|
boolean |
checkAndPut(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
Put put)
Atomically checks if a row/family/qualifier value matches the expected
value.
|
void |
close()
Releases any resources held or pending changes in internal buffers.
|
CoprocessorRpcChannel |
coprocessorService(byte[] row)
Creates and returns a
RpcChannel instance connected to the
table region containing the specified row. |
<T extends com.google.protobuf.Service,R> |
coprocessorService(Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable)
Creates an instance of the given
Service subclass for each table
region spanning the range from the startKey row to endKey row (inclusive), and
invokes the passed Batch.Call.call(T) method
with each Service instance. |
<T extends com.google.protobuf.Service,R> |
coprocessorService(Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable,
Batch.Callback<R> callback)
Creates an instance of the given
Service subclass for each table
region spanning the range from the startKey row to endKey row (inclusive), and
invokes the passed Batch.Call.call(T) method
with each Service instance. |
void |
delete(Delete delete)
Deletes the specified cells/row.
|
void |
delete(List<Delete> deletes)
Deletes the specified cells/rows in bulk.
|
boolean |
exists(Get get)
Test for the existence of columns in the table, as specified by the Get.
|
boolean[] |
existsAll(List<Get> gets)
Test for the existence of columns in the table, as specified by the Gets.
|
Result |
get(Get get)
Extracts certain cells from a given row.
|
Result[] |
get(List<Get> gets)
Extracts certain cells from the given rows, in batch.
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Returns the
Configuration object used by this instance. |
TableName |
getName()
Gets the fully qualified table name instance of this table.
|
ResultScanner |
getScanner(byte[] family)
Gets a scanner on the current table for the given family.
|
ResultScanner |
getScanner(byte[] family,
byte[] qualifier)
Gets a scanner on the current table for the given family and qualifier.
|
ResultScanner |
getScanner(Scan scan)
Returns a scanner on the current table as specified by the
Scan
object. |
HTableDescriptor |
getTableDescriptor()
Gets the
table descriptor for this table. |
long |
getWriteBufferSize()
Deprecated.
as of 1.0.1 (should not have been in 1.0.0). Replaced by
BufferedMutator.getWriteBufferSize() |
Result |
increment(Increment increment)
Increments one or more columns within a single row.
|
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount)
|
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount,
Durability durability)
Atomically increments a column value.
|
void |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row.
|
void |
put(List<Put> puts)
Puts some data in the table, in batch.
|
void |
put(Put put)
Puts some data in the table.
|
void |
setWriteBufferSize(long writeBufferSize)
Deprecated.
as of 1.0.1 (should not have been in 1.0.0). Replaced by
BufferedMutator and
BufferedMutatorParams.writeBufferSize(long) |
TableName getName()
org.apache.hadoop.conf.Configuration getConfiguration()
Configuration
object used by this instance.
The reference returned is not a copy, so any change made to it will affect this instance.
HTableDescriptor getTableDescriptor() throws IOException
table descriptor
for this table.IOException
- if a remote or network exception occurs.boolean exists(Get get) throws IOException
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.
get
- the GetIOException
- eboolean[] existsAll(List<Get> gets) throws IOException
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.
gets
- the GetsIOException
- evoid batch(List<? extends Row> actions, Object[] results) throws IOException, InterruptedException
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.actions
- list of Get, Put, Delete, Increment, Append objectsresults
- 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 retriesIOException
InterruptedException
@Deprecated Object[] batch(List<? extends Row> actions) throws IOException, InterruptedException
batch(List, Object[])
instead.batch(List, Object[])
, but returns an array of
results instead of using a results parameter reference.actions
- list of Get, Put, Delete, Increment, Append objectsIOException
InterruptedException
<R> void batchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
batch(List, Object[])
, but with a callback.IOException
InterruptedException
@Deprecated <R> Object[] batchCallback(List<? extends Row> actions, Batch.Callback<R> callback) throws IOException, InterruptedException
batchCallback(List, Object[],
org.apache.hadoop.hbase.client.coprocessor.Batch.Callback)
instead.batch(List)
, but with a callback.IOException
InterruptedException
Result get(Get get) throws IOException
get
- The object that specifies what data to fetch and from which row.Result
instance returned won't
contain any KeyValue
, as indicated by Result.isEmpty()
.IOException
- if a remote or network exception occurs.Result[] get(List<Get> gets) throws IOException
gets
- The objects that specify what data to fetch and from which rows.Result
instance returned won't contain any KeyValue
, as indicated by Result.isEmpty()
. If there are any
failures even after retries, there will be a null in the results array for those Gets, AND an
exception will be thrown.IOException
- if a remote or network exception occurs.ResultScanner getScanner(Scan scan) throws IOException
Scan
object.
Note that the passed Scan
's start row and caching properties
maybe changed.scan
- A configured Scan
object.IOException
- if a remote or network exception occurs.ResultScanner getScanner(byte[] family) throws IOException
family
- The column family to scan.IOException
- if a remote or network exception occurs.ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException
family
- The column family to scan.qualifier
- The column qualifier to scan.IOException
- if a remote or network exception occurs.void put(Put put) throws IOException
put
- The data to put.IOException
- if a remote or network exception occurs.void put(List<Put> puts) throws IOException
This can be used for group commit, or for submitting user defined batches. The writeBuffer will be periodically inspected while the List is processed, so depending on the List size the writeBuffer may flush not at all, or more than once.
puts
- The list of mutations to apply. The batch put is done by
aggregating the iteration of the Puts over the write buffer
at the client-side for a single RPC call.IOException
- if a remote or network exception occurs.boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkvalue
- the expected valueput
- data to put if check succeedsIOException
- eboolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- comparison operator to usevalue
- the expected valueput
- data to put if check succeedsIOException
- evoid delete(Delete delete) throws IOException
delete
- The object that specifies what to delete.IOException
- if a remote or network exception occurs.void delete(List<Delete> deletes) throws IOException
deletes
- List of things to delete. List gets modified by this
method (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 the
Delete
s are executed).IOException
- if a remote or network exception occurs. In that case
the deletes
argument will contain the Delete
instances
that have not be successfully applied.boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete) throws IOException
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkvalue
- the expected valuedelete
- data to delete if check succeedsIOException
- eboolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- comparison operator to usevalue
- the expected valuedelete
- data to delete if check succeedsIOException
- evoid mutateRow(RowMutations rm) throws IOException
rm
- object that specifies the set of mutations to perform atomicallyIOException
Result append(Append append) throws IOException
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.
append
- object that specifies the columns and values to be appendedIOException
- eResult increment(Increment increment) throws IOException
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.
increment
- object that specifies the columns and amounts to be used
for the increment operationsIOException
- elong incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) throws IOException
incrementColumnValue(byte[], byte[], byte[], long, Durability)
The Durability
is defaulted to Durability.SYNC_WAL
.
row
- The row that contains the cell to increment.family
- The column family of the cell to increment.qualifier
- The column qualifier of the cell to increment.amount
- The amount to increment the cell with (or decrement, if the
amount is negative).IOException
- if a remote or network exception occurs.long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability) throws IOException
amount
and
written to the specified column.
Setting durability to Durability.SKIP_WAL
means that in a fail
scenario you will lose any increments that have not been flushed.
row
- The row that contains the cell to increment.family
- The column family of the cell to increment.qualifier
- The column qualifier of the cell to increment.amount
- The amount to increment the cell with (or decrement, if the
amount is negative).durability
- The persistence guarantee for this increment.IOException
- if a remote or network exception occurs.void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
- if a remote or network exception occurs.CoprocessorRpcChannel coprocessorService(byte[] row)
RpcChannel
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 the row
parameter is also not passed to the
coprocessor handler registered for this protocol, unless the row
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
coprocessor Service
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);
row
- The row key used to identify the remote region location<T extends com.google.protobuf.Service,R> Map<byte[],R> coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable) throws com.google.protobuf.ServiceException, Throwable
Service
subclass for each table
region spanning the range from the startKey
row to endKey
row (inclusive), and
invokes the passed Batch.Call.call(T)
method
with each Service
instance.T
- the Service
subclass to connect toR
- Return type for the callable
parameter's Batch.Call.call(T)
methodservice
- the protocol buffer Service
implementation to callstartKey
- start region selection with region containing this row. If null
, the
selection will start with the first table region.endKey
- select regions up to and including the region containing this row. If null
, selection will continue through the last table region.callable
- this instance's .Call#call
method will be invoked once per table region, using the Service
instance connected to that region.com.google.protobuf.ServiceException
Throwable
<T extends com.google.protobuf.Service,R> void coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T,R> callable, Batch.Callback<R> callback) throws com.google.protobuf.ServiceException, Throwable
Service
subclass for each table
region spanning the range from the startKey
row to endKey
row (inclusive), and
invokes the passed Batch.Call.call(T)
method
with each Service
instance.
The given Batch.Callback.update(byte[],
byte[], Object)
method will be called with the return value from each region's Batch.Call.call(T)
invocation.
T
- the Service
subclass to connect toR
- Return type for the callable
parameter's Batch.Call.call(T)
methodservice
- the protocol buffer Service
implementation to callstartKey
- start region selection with region containing this row. If null
, the
selection will start with the first table region.endKey
- select regions up to and including the region containing this row. If null
, selection will continue through the last table region.callable
- this instance's .Call#call
method will be invoked once per table region, using the Service
instance connected to
that region.callback
- com.google.protobuf.ServiceException
Throwable
@Deprecated long getWriteBufferSize()
BufferedMutator.getWriteBufferSize()
The default value comes from the configuration parameter
hbase.client.write.buffer
.
@Deprecated void setWriteBufferSize(long writeBufferSize) throws IOException
BufferedMutator
and
BufferedMutatorParams.writeBufferSize(long)
If the new size is less than the current amount of data in the write buffer, the buffer gets flushed.
writeBufferSize
- The new write buffer size, in bytes.IOException
- if a remote or network exception occurs.<R extends com.google.protobuf.Message> Map<byte[],R> batchCoprocessorService(com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor, com.google.protobuf.Message request, byte[] startKey, byte[] endKey, R responsePrototype) throws com.google.protobuf.ServiceException, Throwable
Service
subclass for each table
region spanning the range from the startKey
row to endKey
row (inclusive), all
the invocations to the same region server will be batched into one call. The coprocessor
service is invoked according to the service instance, method name and parameters.R
- the response type for the coprocessor Service methodmethodDescriptor
- the descriptor for the protobuf service method to call.request
- the method call parametersstartKey
- start region selection with region containing this row. If null
, the
selection will start with the first table region.endKey
- select regions up to and including the region containing this row. If null
,
selection will continue through the last table region.responsePrototype
- the proto type of the response of the method in Service.com.google.protobuf.ServiceException
Throwable
<R extends com.google.protobuf.Message> void batchCoprocessorService(com.google.protobuf.Descriptors.MethodDescriptor methodDescriptor, com.google.protobuf.Message request, byte[] startKey, byte[] endKey, R responsePrototype, Batch.Callback<R> callback) throws com.google.protobuf.ServiceException, Throwable
Service
subclass for each table
region spanning the range from the startKey
row to endKey
row (inclusive), all
the invocations to the same region server will be batched into one call. The coprocessor
service is invoked according to the service instance, method name and parameters.
The given
Batch.Callback.update(byte[],byte[],Object)
method will be called with the return value from each region's invocation.
R
- the response type for the coprocessor Service methodmethodDescriptor
- the descriptor for the protobuf service method to call.request
- the method call parametersstartKey
- start region selection with region containing this row. If null
, the
selection will start with the first table region.endKey
- select regions up to and including the region containing this row. If null
,
selection will continue through the last table region.responsePrototype
- the proto type of the response of the method in Service.callback
- callback to invoke with the response for each regioncom.google.protobuf.ServiceException
Throwable
boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, RowMutations mutation) throws IOException
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- the comparison operatorvalue
- the expected valuemutation
- mutations to perform if check succeedsIOException
- eCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.