Class HTable
- All Implemented Interfaces:
Closeable,AutoCloseable,Table
Table. Used to communicate with a single HBase table. Lightweight.
Get as needed and just close when done. Instances of this class SHOULD NOT be constructed
directly. Obtain an instance via Connection. See ConnectionFactory class comment
for an example of how.
This class is thread safe since 2.0.0 if not invoking any of the setter methods. All setters are
moved into TableBuilder and reserved here only for keeping backward compatibility, and
TODO will be removed soon.
HTable is no longer a client API. Use Table instead. It is marked
InterfaceAudience.Private indicating that this is an HBase-internal class as defined in Hadoop
Interface Classification There are no guarantees for backwards source / binary compatibility
and methods or class can change or go away without deprecation.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classNested classes/interfaces inherited from interface org.apache.hadoop.hbase.client.Table
Table.CheckAndMutateBuilder, Table.CheckAndMutateWithFilterBuilder -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate booleanprivate final org.apache.hadoop.conf.Configurationprivate final ConnectionConfigurationprivate final ClusterConnectionprivate static final Consistencyprivate final HRegionLocatorprivate static final org.slf4j.Logger(package private) AsyncProcessThe Async process for batchprivate intprivate final ExecutorServiceprivate intprivate final RpcRetryingCallerFactoryprivate final RpcControllerFactoryprivate final intprivate final intprivate final longprivate final intprivate final intprivate final TableNameprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHTable(ConnectionImplementation connection, TableBuilderBase builder, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcControllerFactory, ExecutorService pool, Map<String, byte[]> requestAttributes) Creates an object to access a HBase table. -
Method Summary
Modifier and TypeMethodDescriptionAppends values to one or more columns within a single row.voidMethod that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations.void<R> voidbatchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) Same asTable.batch(List, Object[]), but with a callback.<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) Creates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (inclusive), all the invocations to the same region server will be batched into one call.<R extends com.google.protobuf.Message>
voidbatchCoprocessorService(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 givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (inclusive), all the invocations to the same region server will be batched into one call.booleancheckAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete) Deprecated.booleancheckAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Delete delete) Deprecated.booleancheckAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) Deprecated.checkAndMutate(byte[] row, byte[] family) Deprecated.booleancheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, RowMutations rm) Deprecated.booleancheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, RowMutations rm) Deprecated.checkAndMutate(byte[] row, Filter filter) Deprecated.checkAndMutate(List<CheckAndMutate> checkAndMutates) Batch version of checkAndMutate.checkAndMutate(CheckAndMutate checkAndMutate) checkAndMutate that atomically checks if a row matches the specified condition.booleancheckAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) Deprecated.booleancheckAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Put put) Deprecated.booleancheckAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put) Deprecated.voidExplicitly clears the region cache to fetch the latest value from META.voidclose()Releases any resources held or pending changes in internal buffers.coprocessorService(byte[] row) Creates and returns aRpcChannelinstance connected to the table region containing the specified row.<T extends com.google.protobuf.Service,R>
Map<byte[],R> coprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T, R> callable) Creates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (inclusive), and invokes the passedBatch.Call.call(T)method with eachServiceinstance.<T extends com.google.protobuf.Service,R>
voidcoprocessorService(Class<T> service, byte[] startKey, byte[] endKey, Batch.Call<T, R> callable, Batch.Callback<R> callback) Creates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (inclusive), and invokes the passedBatch.Call.call(T)method with eachServiceinstance.voidBatch Deletes the specified cells/rows from the table.voidDeletes the specified cells/row.static <R> voiddoBatchWithCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback, ClusterConnection connection, ExecutorService pool, TableName tableName, Map<String, byte[]> requestAttributes) private CheckAndMutateResultdoCheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Filter filter, TimeRange timeRange, Mutation mutation) private CheckAndMutateResultdoCheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Filter filter, TimeRange timeRange, RowMutations rm) boolean[]Test for the existence of columns in the table, as specified by the Gets.booleanTest 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.private Resultorg.apache.hadoop.conf.ConfigurationReturns theConfigurationobject used by this instance.protected ConnectionINTERNAL Used by unit tests and tools to do low-level manipulations.static ThreadPoolExecutorgetDefaultExecutor(org.apache.hadoop.conf.Configuration conf) Gets thetable descriptorfor this table.private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey) Get the corresponding start keys and regions for an arbitrary range of keys.private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey, boolean reload) Get the corresponding start keys and regions for an arbitrary range of keys.static intgetMaxKeyValueSize(org.apache.hadoop.conf.Configuration conf) Returns maxKeyValueSize from configuration.getName()Gets the fully qualified table name instance of this table.private longgetNonce()private longintDeprecated.longgetOperationTimeout(TimeUnit unit) Get timeout of each operation in Table instance.(package private) ExecutorServicegetPool()The pool is used for mutli requests for this HTableintDeprecated.longgetReadRpcTimeout(TimeUnit unit) Get timeout of each rpc read request in this Table instance.Gets theRegionLocatorfor this table.Get the attributes to be submitted with requestsintDeprecated.longgetRpcTimeout(TimeUnit unit) Get timeout of each rpc request in this Table instance.getScanner(byte[] family) The underlyingHTablemust not be closed.getScanner(byte[] family, byte[] qualifier) The underlyingHTablemust not be closed.getScanner(Scan scan) The underlyingHTablemust not be closed.private ResultScannergetScannerInternal(Scan scan, Scan scanForMetrics) private List<byte[]>getStartKeysInRange(byte[] start, byte[] end) Deprecated.intDeprecated.longgetWriteRpcTimeout(TimeUnit unit) Get timeout of each rpc write request in this Table instance.Increments one or more columns within a single row.longincrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) longincrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability) Atomically increments a column value.Performs multiple mutations atomically on a single row.<R> voidprocessBatchCallback(List<? extends Row> list, Object[] results, Batch.Callback<R> callback) Process a mixed batch of Get, Put and Delete actions.voidBatch puts the specified data into the table.voidPuts some data in the table.voidsetOperationTimeout(int operationTimeout) Deprecated.voidsetReadRpcTimeout(int readRpcTimeout) Deprecated.voidsetRpcTimeout(int rpcTimeout) Deprecated.voidsetWriteRpcTimeout(int writeRpcTimeout) Deprecated.private CompareOperatortoCompareOperator(CompareFilter.CompareOp compareOp) toString()private voidvalidatePut(Put put)
-
Field Details
-
LOG
-
DEFAULT_CONSISTENCY
-
connection
-
tableName
-
configuration
-
connConfiguration
-
closed
-
scannerCaching
-
scannerMaxResultSize
-
pool
-
operationTimeoutMs
-
rpcTimeoutMs
-
readRpcTimeoutMs
-
writeRpcTimeoutMs
-
scanReadRpcTimeout
-
scanTimeout
-
cleanupPoolOnClose
-
locator
-
multiAp
The Async process for batch -
rpcCallerFactory
-
rpcControllerFactory
-
requestAttributes
-
-
Constructor Details
-
HTable
@Private protected HTable(ConnectionImplementation connection, TableBuilderBase builder, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcControllerFactory, ExecutorService pool, Map<String, byte[]> requestAttributes) Creates an object to access a HBase table. Used by HBase internally. DO NOT USE. SeeConnectionFactoryclass comment for how to get aTableinstance (useTableinstead ofHTable).- Parameters:
connection- Connection to be used.builder- The table builderrpcCallerFactory- The RPC caller factoryrpcControllerFactory- The RPC controller factorypool- ExecutorService to be used.
-
-
Method Details
-
getDefaultExecutor
@Private public static ThreadPoolExecutor getDefaultExecutor(org.apache.hadoop.conf.Configuration conf) -
getMaxKeyValueSize
Returns maxKeyValueSize from configuration. -
getConfiguration
Description copied from interface:TableReturns theConfigurationobject used by this instance.The reference returned is not a copy, so any change made to it will affect this instance.
- Specified by:
getConfigurationin interfaceTable
-
getName
Description copied from interface:TableGets the fully qualified table name instance of this table. -
getConnection
INTERNAL Used by unit tests and tools to do low-level manipulations.- Returns:
- A Connection instance.
-
getTableDescriptor
Deprecated.Description copied from interface:TableGets thetable descriptorfor this table.- Specified by:
getTableDescriptorin interfaceTable- Throws:
IOException- if a remote or network exception occurs.
-
getDescriptor
Description copied from interface:TableGets thetable descriptorfor this table.- Specified by:
getDescriptorin interfaceTable- Throws:
IOException- if a remote or network exception occurs.
-
getKeysAndRegionsInRange
private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey) throws IOException Get the corresponding start keys and regions for an arbitrary range of keys.- Parameters:
startKey- Starting row in range, inclusiveendKey- Ending row in rangeincludeEndKey- true if endRow is inclusive, false if exclusive- Returns:
- A pair of list of start keys and list of HRegionLocations that contain the specified range
- Throws:
IOException- if a remote or network exception occurs
-
getKeysAndRegionsInRange
private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey, boolean reload) throws IOException Get the corresponding start keys and regions for an arbitrary range of keys.- Parameters:
startKey- Starting row in range, inclusiveendKey- Ending row in rangeincludeEndKey- true if endRow is inclusive, false if exclusivereload- true to reload information or false to use cached information- Returns:
- A pair of list of start keys and list of HRegionLocations that contain the specified range
- Throws:
IOException- if a remote or network exception occurs
-
getScanner
The underlyingHTablemust not be closed.Table.getScanner(Scan)has other usage details.- Specified by:
getScannerin interfaceTable- Parameters:
scan- A configuredScanobject.- Returns:
- A scanner.
- Throws:
IOException- if a remote or network exception occurs.
-
getScannerInternal
- Throws:
IOException
-
getScanner
The underlyingHTablemust not be closed.Table.getScanner(byte[])has other usage details.- Specified by:
getScannerin interfaceTable- Parameters:
family- The column family to scan.- Returns:
- A scanner.
- Throws:
IOException- if a remote or network exception occurs.
-
getScanner
The underlyingHTablemust not be closed.Table.getScanner(byte[], byte[])has other usage details.- Specified by:
getScannerin 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.
-
get
Description copied from interface:TableExtracts certain cells from a given row.- Specified by:
getin 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
Resultinstance returned won't contain anyKeyValue, as indicated byResult.isEmpty(). - Throws:
IOException- if a remote or network exception occurs.
-
get
- Throws:
IOException
-
get
Description copied from interface:TableExtracts specified cells from the given rows, as a batch.- Specified by:
getin 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
Resultinstance returned won't contain anyCells, as indicated byResult.isEmpty(). If there are any failures even after retries, there will be anullin 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.
-
batch
public void batch(List<? extends Row> actions, Object[] results) throws InterruptedException, IOException Description copied from interface:TableMethod 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:
batchin 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:
InterruptedExceptionIOException
-
batch
public void batch(List<? extends Row> actions, Object[] results, int rpcTimeout) throws InterruptedException, IOException - Throws:
InterruptedExceptionIOException
-
batchCallback
public <R> void batchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException Description copied from interface:TableSame asTable.batch(List, Object[]), but with a callback.- Specified by:
batchCallbackin interfaceTable- Throws:
IOExceptionInterruptedException
-
doBatchWithCallback
public static <R> void doBatchWithCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback, ClusterConnection connection, ExecutorService pool, TableName tableName, Map<String, byte[]> requestAttributes) throws InterruptedIOException, RetriesExhaustedWithDetailsException -
delete
Description copied from interface:TableDeletes the specified cells/row.- Specified by:
deletein interfaceTable- Parameters:
delete- The object that specifies what to delete.- Throws:
IOException- if a remote or network exception occurs.
-
delete
Description copied from interface:TableBatch Deletes the specified cells/rows from the table.If a specified row does not exist,
Deletewill report as though sucessful delete; no exception will be thrown. If there are any failures even after retries, aRetriesExhaustedWithDetailsExceptionwill be thrown. RetriesExhaustedWithDetailsException contains lists of failedDeletes and corresponding remote exceptions.- Specified by:
deletein interfaceTable- Parameters:
deletes- List of things to delete. The input list gets modified by this method. All successfully appliedDeletes 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 theDeletes are executed).- Throws:
IOException- if a remote or network exception occurs. In that case thedeletesargument will contain theDeleteinstances that have not be successfully applied.
-
put
Description copied from interface:TablePuts some data in the table.- Specified by:
putin interfaceTable- Parameters:
put- The data to put.- Throws:
IOException- if a remote or network exception occurs.
-
put
Description copied from interface:TableBatch 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
IllegalArgumentExceptionwill be thrown and no mutations will be applied. If there are any failures even after retries, aRetriesExhaustedWithDetailsExceptionwill 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:
putin interfaceTable- Parameters:
puts- The list of mutations to apply.- Throws:
IOException- if a remote or network exception occurs.
-
mutateRow
Description copied from interface:Table- Specified by:
mutateRowin 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.
-
getNonceGroup
-
getNonce
-
append
Description copied from interface:TableAppends 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:
appendin 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:TableIncrements 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:
incrementin 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
-
incrementColumnValue
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) throws IOException Description copied from interface:TableSeeTable.incrementColumnValue(byte[], byte[], byte[], long, Durability)The
Durabilityis defaulted toDurability.SYNC_WAL.- Specified by:
incrementColumnValuein interfaceTable- Parameters:
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).- Returns:
- The new value, post increment.
- Throws:
IOException- if a remote or network exception occurs.
-
incrementColumnValue
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability) throws IOException Description copied from interface:TableAtomically increments a column value. If the column value already exists and is not a big-endian long, this could throw an exception. If the column value does not yet exist it is initialized toamountand written to the specified column.Setting durability to
Durability.SKIP_WALmeans that in a fail scenario you will lose any increments that have not been flushed.- Specified by:
incrementColumnValuein interfaceTable- Parameters:
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.- Returns:
- The new value, post increment.
- Throws:
IOException- if a remote or network exception occurs.
-
checkAndPut
@Deprecated public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the put. If the passed value is null, the check is for the lack of column (ie: non-existance)- Specified by:
checkAndPutin interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkvalue- the expected valueput- data to put if check succeeds- Returns:
- true if the new put was executed, false otherwise
- Throws:
IOException- e
-
checkAndPut
@Deprecated public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the put. 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 <=> add the put.- Specified by:
checkAndPutin interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkcompareOp- comparison operator to usevalue- the expected valueput- data to put if check succeeds- Returns:
- true if the new put was executed, false otherwise
- Throws:
IOException- e
-
checkAndPut
@Deprecated public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Put put) throws IOException Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the put. 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 <=> add the put.- Specified by:
checkAndPutin interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkop- comparison operator to usevalue- the expected valueput- data to put if check succeeds- Returns:
- true if the new put was executed, false otherwise
- Throws:
IOException- e
-
checkAndDelete
@Deprecated public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete) throws IOException Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the delete. If the passed value is null, the check is for the lack of column (ie: non-existance)- Specified by:
checkAndDeletein interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkvalue- the expected valuedelete- data to delete if check succeeds- Returns:
- true if the new delete was executed, false otherwise
- Throws:
IOException- e
-
checkAndDelete
@Deprecated public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the delete. 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 <=> add the delete.- Specified by:
checkAndDeletein interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkcompareOp- comparison operator to usevalue- the expected valuedelete- data to delete if check succeeds- Returns:
- true if the new delete was executed, false otherwise
- Throws:
IOException- e
-
checkAndDelete
@Deprecated public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Delete delete) throws IOException Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the delete. 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 <=> add the delete.- Specified by:
checkAndDeletein interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkop- comparison operator to usevalue- the expected valuedelete- data to delete if check succeeds- Returns:
- true if the new delete was executed, false otherwise
- Throws:
IOException- e
-
checkAndMutate
Deprecated.Description copied from interface:TableAtomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the Put/Delete/RowMutations.Use the returned
Table.CheckAndMutateBuilderto 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:
checkAndMutatein interfaceTable
-
checkAndMutate
Deprecated.Description copied from interface:TableAtomically checks if a row matches the specified filter. If it does, it adds the Put/Delete/RowMutations.Use the returned
Table.CheckAndMutateWithFilterBuilderto 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:
checkAndMutatein interfaceTable
-
doCheckAndMutate
private CheckAndMutateResult doCheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Filter filter, TimeRange timeRange, RowMutations rm) throws IOException - Throws:
IOException
-
checkAndMutate
@Deprecated public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, RowMutations rm) throws IOException Deprecated.Description copied from interface:TableAtomically 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:
checkAndMutatein interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkcompareOp- the comparison operatorvalue- the expected valuerm- mutations to perform if check succeeds- Returns:
- true if the new put was executed, false otherwise
- Throws:
IOException- e
-
checkAndMutate
@Deprecated public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, RowMutations rm) throws IOException Deprecated.Description copied from interface:TableAtomically 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:
checkAndMutatein interfaceTable- Parameters:
row- to checkfamily- column family to checkqualifier- column qualifier to checkop- the comparison operatorvalue- the expected valuerm- mutations to perform if check succeeds- Returns:
- true if the new put was executed, false otherwise
- Throws:
IOException- e
-
checkAndMutate
Description copied from interface:TablecheckAndMutate that atomically checks if a row matches the specified condition. If it does, it performs the specified action.- Specified by:
checkAndMutatein interfaceTable- Parameters:
checkAndMutate- The CheckAndMutate object.- Returns:
- A CheckAndMutateResult object that represents the result for the CheckAndMutate.
- Throws:
IOException- if a remote or network exception occurs.
-
doCheckAndMutate
private CheckAndMutateResult doCheckAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Filter filter, TimeRange timeRange, Mutation mutation) throws IOException - Throws:
IOException
-
checkAndMutate
public List<CheckAndMutateResult> checkAndMutate(List<CheckAndMutate> checkAndMutates) throws IOException Description copied from interface:TableBatch 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:
checkAndMutatein interfaceTable- Parameters:
checkAndMutates- The list of CheckAndMutate.- Returns:
- A list of CheckAndMutateResult objects that represents the result for each CheckAndMutate.
- Throws:
IOException- if a remote or network exception occurs.
-
toCompareOperator
-
exists
Description copied from interface:TableTest 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:
existsin 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:TableTest 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:
existsin 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
-
processBatchCallback
public <R> void processBatchCallback(List<? extends Row> list, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException Process a mixed batch of Get, Put and Delete actions. All actions for a RegionServer are forwarded in one RPC call. Queries are executed in parallel.- Parameters:
list- The collection of actions.results- An empty array, same size as list. If an exception is thrown, you can test here for partial results, and to determine which actions processed successfully.- Throws:
IOException- if there are problems talking to META. Per-item exceptions are stored in the results array.InterruptedException
-
close
Description copied from interface:TableReleases any resources held or pending changes in internal buffers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTable- Throws:
IOException- if a remote or network exception occurs.
-
validatePut
- Throws:
IllegalArgumentException
-
getPool
The pool is used for mutli requests for this HTable- Returns:
- the pool used for mutli
-
clearRegionCache
Explicitly clears the region cache to fetch the latest value from META. This is a power user function: avoid unless you know the ramifications. -
coprocessorService
Description copied from interface:TableCreates and returns aRpcChannelinstance 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 therowparameter is also not passed to the coprocessor handler registered for this protocol, unless therowis 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
RpcChannelinstance can be used to access a published coprocessorServiceusing 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:
coprocessorServicein interfaceTable- Parameters:
row- The row key used to identify the remote region location- Returns:
- A CoprocessorRpcChannel instance
-
coprocessorService
public <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, ThrowableDescription copied from interface:TableCreates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (inclusive), and invokes the passedBatch.Call.call(T)method with eachServiceinstance.- Specified by:
coprocessorServicein interfaceTable- Type Parameters:
T- theServicesubclass to connect toR- Return type for thecallableparameter'sBatch.Call.call(T)method- Parameters:
service- the protocol bufferServiceimplementation to callstartKey- start region selection with region containing this row. Ifnull, the selection will start with the first table region.endKey- select regions up to and including the region containing this row. Ifnull, selection will continue through the last table region.callable- this instance'sBatch.Call.call(T)method will be invoked once per table region, using theServiceinstance connected to that region.- Returns:
- a map of result values keyed by region name
- Throws:
com.google.protobuf.ServiceExceptionThrowable
-
coprocessorService
public <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, ThrowableDescription copied from interface:TableCreates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (inclusive), and invokes the passedBatch.Call.call(T)method with eachServiceinstance.The given
Batch.Callback.update(byte[],byte[],Object)method will be called with the return value from each region'sBatch.Call.call(T)invocation.- Specified by:
coprocessorServicein interfaceTable- Type Parameters:
T- theServicesubclass to connect toR- Return type for thecallableparameter'sBatch.Call.call(T)method- Parameters:
service- the protocol bufferServiceimplementation to callstartKey- start region selection with region containing this row. Ifnull, the selection will start with the first table region.endKey- select regions up to and including the region containing this row. Ifnull, selection will continue through the last table region.callable- this instance'sBatch.Call.call(T)method will be invoked once per table region, using theServiceinstance connected to that region.- Throws:
com.google.protobuf.ServiceExceptionThrowable
-
getStartKeysInRange
- Throws:
IOException
-
getRpcTimeout
Description copied from interface:TableGet 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:
getRpcTimeoutin interfaceTable- Parameters:
unit- the unit of time the timeout to be represented in- Returns:
- rpc timeout in the specified time unit
- See Also:
-
getRpcTimeout
Deprecated.Description copied from interface:TableGet timeout (millisecond) of each rpc request in this Table instance.- Specified by:
getRpcTimeoutin interfaceTable- Returns:
- Currently configured read timeout
-
setRpcTimeout
Deprecated.Description copied from interface:TableSet timeout (millisecond) of each rpc request in operations of this Table instance, will override the value of hbase.rpc.timeout in configuration. If a rpc request waiting too long, it will stop waiting and send a new request to retry until retries exhausted or operation timeout reached.NOTE: This will set both the read and write timeout settings to the provided value.
- Specified by:
setRpcTimeoutin interfaceTable- Parameters:
rpcTimeout- the timeout of each rpc request in millisecond.
-
getReadRpcTimeout
Description copied from interface:TableGet timeout of each rpc read request in this Table instance.- Specified by:
getReadRpcTimeoutin interfaceTable- Parameters:
unit- the unit of time the timeout to be represented in- Returns:
- read rpc timeout in the specified time unit
-
getReadRpcTimeout
Deprecated.Description copied from interface:TableGet timeout (millisecond) of each rpc read request in this Table instance.- Specified by:
getReadRpcTimeoutin interfaceTable
-
setReadRpcTimeout
Deprecated.Description copied from interface:TableSet timeout (millisecond) of each rpc read request in operations of this Table instance, will override the value of hbase.rpc.read.timeout in configuration. If a rpc read request waiting too long, it will stop waiting and send a new request to retry until retries exhausted or operation timeout reached.- Specified by:
setReadRpcTimeoutin interfaceTable- Parameters:
readRpcTimeout- the timeout for read rpc request in milliseconds
-
getWriteRpcTimeout
Description copied from interface:TableGet timeout of each rpc write request in this Table instance.- Specified by:
getWriteRpcTimeoutin interfaceTable- Parameters:
unit- the unit of time the timeout to be represented in- Returns:
- write rpc timeout in the specified time unit
-
getWriteRpcTimeout
Deprecated.Description copied from interface:TableGet timeout (millisecond) of each rpc write request in this Table instance.- Specified by:
getWriteRpcTimeoutin interfaceTable
-
setWriteRpcTimeout
Deprecated.Description copied from interface:TableSet timeout (millisecond) of each rpc write request in operations of this Table instance, will override the value of hbase.rpc.write.timeout in configuration. If a rpc write request waiting too long, it will stop waiting and send a new request to retry until retries exhausted or operation timeout reached.- Specified by:
setWriteRpcTimeoutin interfaceTable- Parameters:
writeRpcTimeout- the timeout for write rpc request in milliseconds
-
getOperationTimeout
Description copied from interface:TableGet timeout of each operation in Table instance.- Specified by:
getOperationTimeoutin interfaceTable- Parameters:
unit- the unit of time the timeout to be represented in- Returns:
- operation rpc timeout in the specified time unit
-
getOperationTimeout
Deprecated.Description copied from interface:TableGet timeout (millisecond) of each operation for in Table instance.- Specified by:
getOperationTimeoutin interfaceTable
-
setOperationTimeout
Deprecated.Description copied from interface:TableSet timeout (millisecond) of each operation in this Table instance, will override the value of hbase.client.operation.timeout in configuration. Operation timeout is a top-level restriction that makes sure a blocking method will not be blocked more than this. In each operation, if rpc request fails because of timeout or other reason, it will retry until success or throw a RetriesExhaustedException. But if the total time being blocking reach the operation timeout before retries exhausted, it will break early and throw SocketTimeoutException.- Specified by:
setOperationTimeoutin interfaceTable- Parameters:
operationTimeout- the total timeout of each operation in millisecond.
-
toString
-
batchCoprocessorService
public <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 Description copied from interface:TableCreates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (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 descriptor for the protobuf service method to call. the method call parameters start region selection with region containing this row. Ifnull, the selection will start with the first table region. select regions up to and including the region containing this row. Ifnull, selection will continue through the last table region. the proto type of the response of the method in Service.- Specified by:
batchCoprocessorServicein interfaceTable- Type Parameters:
R- the response type for the coprocessor Service method- Returns:
- a map of result values keyed by region name
- Throws:
com.google.protobuf.ServiceExceptionThrowable
-
batchCoprocessorService
public <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 Description copied from interface:TableCreates an instance of the givenServicesubclass for each table region spanning the range from thestartKeyrow toendKeyrow (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.- Specified by:
batchCoprocessorServicein interfaceTable- Type Parameters:
R- the response type for the coprocessor Service method- Parameters:
methodDescriptor- the descriptor for the protobuf service method to call.request- the method call parametersstartKey- start region selection with region containing this row. Ifnull, the selection will start with the first table region.endKey- select regions up to and including the region containing this row. Ifnull, 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 region- Throws:
com.google.protobuf.ServiceExceptionThrowable
-
getRegionLocator
Description copied from interface:TableGets theRegionLocatorfor this table.- Specified by:
getRegionLocatorin interfaceTable
-
getRequestAttributes
Description copied from interface:TableGet the attributes to be submitted with requests- Specified by:
getRequestAttributesin interfaceTable- Returns:
- map of request attributes
-