@InterfaceAudience.Private @InterfaceStability.Stable public class HTable extends Object implements HTableInterface, RegionLocator
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 NOT thread safe for reads nor writes. In the case of writes (Put, Delete), the underlying write buffer can be corrupted if multiple threads contend over a single HTable instance. In the case of reads, some fields used by a Scan are shared among all threads.
HTable is no longer a client API. Use Table
instead. It is marked
InterfaceAudience.Private as of hbase-1.0.0 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 the class can
change or go away without deprecation.
Near all methods of this * class made it out to the new Table
Interface or were * instantiations of methods defined in HTableInterface
.
A few did not. Namely, the getStartEndKeys()
, getEndKeys()
,
and getStartKeys()
methods. These three methods are available
in RegionLocator
as of 1.0.0 but were NOT marked as
deprecated when we released 1.0.0. In spite of this oversight on our
part, these methods will be removed in 2.0.0.
Table
,
Admin
,
Connection
,
ConnectionFactory
Modifier and Type | Field and Description |
---|---|
private boolean |
autoFlush |
private boolean |
cleanupConnectionOnClose |
private boolean |
cleanupPoolOnClose |
private boolean |
closed |
private org.apache.hadoop.conf.Configuration |
configuration |
private ConnectionConfiguration |
connConfiguration |
protected ClusterConnection |
connection |
private Consistency |
defaultConsistency |
private HRegionLocator |
locator |
private static org.apache.commons.logging.Log |
LOG |
protected AsyncProcess |
multiAp
The Async process for batch
|
protected BufferedMutatorImpl |
mutator |
private int |
operationTimeout |
private ExecutorService |
pool |
private RpcRetryingCallerFactory |
rpcCallerFactory |
private RpcControllerFactory |
rpcControllerFactory |
private int |
rpcTimeout |
protected int |
scannerCaching |
protected long |
scannerMaxResultSize |
private TableName |
tableName |
Modifier | Constructor and Description |
---|---|
|
HTable(byte[] tableName,
Connection connection,
ExecutorService pool)
Deprecated.
Do not use, internal ctor.
|
protected |
HTable(ClusterConnection conn,
BufferedMutatorParams params)
For internal testing.
|
|
HTable(org.apache.hadoop.conf.Configuration conf,
byte[] tableName)
Deprecated.
Constructing HTable objects manually has been deprecated. Please use
Connection to instantiate a Table instead. |
|
HTable(org.apache.hadoop.conf.Configuration conf,
byte[] tableName,
ExecutorService pool)
Deprecated.
Constructing HTable objects manually has been deprecated. Please use
Connection to instantiate a Table instead. |
|
HTable(org.apache.hadoop.conf.Configuration conf,
String tableName)
Deprecated.
Constructing HTable objects manually has been deprecated. Please use
Connection to instantiate a Table instead. |
|
HTable(org.apache.hadoop.conf.Configuration conf,
TableName tableName)
Deprecated.
Constructing HTable objects manually has been deprecated. Please use
Connection to instantiate a Table instead. |
|
HTable(org.apache.hadoop.conf.Configuration conf,
TableName tableName,
ExecutorService pool)
Deprecated.
Constructing HTable objects manually has been deprecated. Please use
Connection to instantiate a Table instead. |
|
HTable(TableName tableName,
ClusterConnection connection,
ConnectionConfiguration tableConfig,
RpcRetryingCallerFactory rpcCallerFactory,
RpcControllerFactory rpcControllerFactory,
ExecutorService pool)
Creates an object to access a HBase table.
|
|
HTable(TableName tableName,
Connection connection)
Deprecated.
Do not use.
|
|
HTable(TableName tableName,
Connection connection,
ExecutorService pool)
Deprecated.
Do not use, internal ctor.
|
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
Table.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 rm)
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 |
clearRegionCache()
Explicitly clears the region cache to fetch the latest value from META.
|
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[] |
exists(List<Get> gets)
Deprecated.
|
boolean[] |
existsAll(List<Get> gets)
Test for the existence of columns in the table, as specified by the Gets.
|
private void |
finishSetup()
setup this HTable's parameter based on the passed configuration
|
void |
flushCommits()
Executes all the buffered
Put operations. |
Result |
get(Get get)
Extracts certain cells from a given row.
|
private Result |
get(Get get,
boolean checkExistenceOnly) |
Result[] |
get(List<Get> gets)
Extracts certain cells from the given rows, in batch.
|
List<HRegionLocation> |
getAllRegionLocations()
Deprecated.
Use
RegionLocator.getAllRegionLocations() instead; |
(package private) BufferedMutator |
getBufferedMutator() |
org.apache.hadoop.conf.Configuration |
getConfiguration()
Returns the
Configuration object used by this instance. |
HConnection |
getConnection()
Deprecated.
This method will be changed from public to package protected.
|
static ThreadPoolExecutor |
getDefaultExecutor(org.apache.hadoop.conf.Configuration conf) |
byte[][] |
getEndKeys()
Deprecated.
Since 1.1.0. Use
RegionLocator.getEndKeys() instead; |
private Pair<List<byte[]>,List<HRegionLocation>> |
getKeysAndRegionsInRange(byte[] startKey,
byte[] endKey,
boolean includeEndKey)
Deprecated.
This is no longer a public API
|
private Pair<List<byte[]>,List<HRegionLocation>> |
getKeysAndRegionsInRange(byte[] startKey,
byte[] endKey,
boolean includeEndKey,
boolean reload)
Deprecated.
This is no longer a public API
|
static int |
getMaxKeyValueSize(org.apache.hadoop.conf.Configuration conf) |
TableName |
getName()
Gets the fully qualified table name instance of this table.
|
int |
getOperationTimeout() |
(package private) ExecutorService |
getPool()
The pool is used for mutli requests for this HTable
|
static boolean |
getRegionCachePrefetch(byte[] tableName)
Deprecated.
always return false since 0.99
|
static boolean |
getRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf,
byte[] tableName)
Deprecated.
always return false since 0.99
|
static boolean |
getRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf,
TableName tableName)
Deprecated.
always return false since 0.99
|
static boolean |
getRegionCachePrefetch(TableName tableName)
Deprecated.
always return false since 0.99
|
HRegionLocation |
getRegionLocation(byte[] row)
Deprecated.
Use
RegionLocator.getRegionLocation(byte[]) instead. |
HRegionLocation |
getRegionLocation(byte[] row,
boolean reload)
Deprecated.
Use
RegionLocator.getRegionLocation(byte[], boolean) instead. |
HRegionLocation |
getRegionLocation(String row)
Deprecated.
|
NavigableMap<HRegionInfo,ServerName> |
getRegionLocations()
Deprecated.
This is no longer a public API. Use
getAllRegionLocations() instead. |
RegionLocator |
getRegionLocator() |
List<HRegionLocation> |
getRegionsInRange(byte[] startKey,
byte[] endKey)
Deprecated.
This is no longer a public API
|
List<HRegionLocation> |
getRegionsInRange(byte[] startKey,
byte[] endKey,
boolean reload)
Deprecated.
This is no longer a public API
|
Result |
getRowOrBefore(byte[] row,
byte[] family)
Deprecated.
Use reversed scan instead.
|
int |
getRpcTimeout() |
ResultScanner |
getScanner(byte[] family)
The underlying
HTable must not be closed. |
ResultScanner |
getScanner(byte[] family,
byte[] qualifier)
The underlying
HTable must not be closed. |
ResultScanner |
getScanner(Scan scan)
The underlying
HTable must not be closed. |
int |
getScannerCaching()
Deprecated.
|
Pair<byte[][],byte[][]> |
getStartEndKeys()
Deprecated.
Since 1.1.0. Use
RegionLocator.getStartEndKeys() instead; |
byte[][] |
getStartKeys()
Deprecated.
Since 1.1.0. Use
RegionLocator.getStartEndKeys() instead |
private List<byte[]> |
getStartKeysInRange(byte[] start,
byte[] end) |
HTableDescriptor |
getTableDescriptor()
Gets the
table descriptor for this table. |
byte[] |
getTableName()
Gets the name of this table.
|
List<Row> |
getWriteBuffer()
Deprecated.
since 0.96. This is an internal buffer that should not be read nor write.
|
long |
getWriteBufferSize()
Returns the maximum size in bytes of the write buffer for this HTable.
|
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,
boolean writeToWAL)
Deprecated.
As of release 0.96
(HBASE-9508).
This will be removed in HBase 2.0.0.
Use
incrementColumnValue(byte[], byte[], byte[], long, Durability) . |
long |
incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount,
Durability durability)
Atomically increments a column value.
|
boolean |
isAutoFlush()
Tells whether or not 'auto-flush' is turned on.
|
static boolean |
isTableEnabled(byte[] tableName)
Deprecated.
|
static boolean |
isTableEnabled(org.apache.hadoop.conf.Configuration conf,
byte[] tableName)
Deprecated.
|
static boolean |
isTableEnabled(org.apache.hadoop.conf.Configuration conf,
String tableName)
Deprecated.
|
static boolean |
isTableEnabled(org.apache.hadoop.conf.Configuration conf,
TableName tableName)
|
static boolean |
isTableEnabled(String tableName)
Deprecated.
|
static boolean |
isTableEnabled(TableName tableName)
Deprecated.
|
void |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row.
|
void |
processBatch(List<? extends Row> list,
Object[] results)
Parameterized batch processing, allowing varying return types for different
Row implementations. |
<R> void |
processBatchCallback(List<? extends Row> list,
Object[] results,
Batch.Callback<R> callback)
Process a mixed batch of Get, Put and Delete actions.
|
void |
put(List<Put> puts)
Puts some data in the table, in batch.
|
void |
put(Put put)
Puts some data in the table.
|
void |
setAutoFlush(boolean autoFlush)
Deprecated.
|
void |
setAutoFlush(boolean autoFlush,
boolean clearBufferOnFail)
Turns 'auto-flush' on or off.
|
void |
setAutoFlushTo(boolean autoFlush)
Set the autoFlush behavior, without changing the value of
clearBufferOnFail . |
void |
setOperationTimeout(int operationTimeout) |
static void |
setRegionCachePrefetch(byte[] tableName,
boolean enable)
Deprecated.
does nothing since 0.99
|
static void |
setRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf,
byte[] tableName,
boolean enable)
Deprecated.
does nothing since 0.99
|
static void |
setRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf,
TableName tableName,
boolean enable)
Deprecated.
does nothing since 0.99
|
static void |
setRegionCachePrefetch(TableName tableName,
boolean enable)
Deprecated.
does nothing since 0.99
|
void |
setRpcTimeout(int rpcTimeout) |
void |
setScannerCaching(int scannerCaching)
Deprecated.
|
void |
setWriteBufferSize(long writeBufferSize)
Sets the size of the buffer in bytes.
|
String |
toString() |
void |
validatePut(Put put) |
static void |
validatePut(Put put,
int maxKeyValueSize) |
private static final org.apache.commons.logging.Log LOG
protected ClusterConnection connection
private final TableName tableName
private volatile org.apache.hadoop.conf.Configuration configuration
private ConnectionConfiguration connConfiguration
protected BufferedMutatorImpl mutator
private boolean autoFlush
private boolean closed
protected int scannerCaching
protected long scannerMaxResultSize
private ExecutorService pool
private int operationTimeout
private int rpcTimeout
private final boolean cleanupPoolOnClose
private final boolean cleanupConnectionOnClose
private Consistency defaultConsistency
private HRegionLocator locator
protected AsyncProcess multiAp
private RpcRetryingCallerFactory rpcCallerFactory
private RpcControllerFactory rpcControllerFactory
@Deprecated public HTable(org.apache.hadoop.conf.Configuration conf, String tableName) throws IOException
Connection
to instantiate a Table
instead.conf
- Configuration object to use.tableName
- Name of the table.IOException
- if a remote or network exception occurs@Deprecated public HTable(org.apache.hadoop.conf.Configuration conf, byte[] tableName) throws IOException
Connection
to instantiate a Table
instead.conf
- Configuration object to use.tableName
- Name of the table.IOException
- if a remote or network exception occurs@Deprecated public HTable(org.apache.hadoop.conf.Configuration conf, TableName tableName) throws IOException
Connection
to instantiate a Table
instead.conf
- Configuration object to use.tableName
- table name pojoIOException
- if a remote or network exception occurs@Deprecated public HTable(TableName tableName, Connection connection) throws IOException
tableName
- Name of the table.connection
- HConnection to be used.IOException
- if a remote or network exception occurs@Deprecated public HTable(org.apache.hadoop.conf.Configuration conf, byte[] tableName, ExecutorService pool) throws IOException
Connection
to instantiate a Table
instead.conf
- Configuration object to use.tableName
- Name of the table.pool
- ExecutorService to be used.IOException
- if a remote or network exception occurs@Deprecated public HTable(org.apache.hadoop.conf.Configuration conf, TableName tableName, ExecutorService pool) throws IOException
Connection
to instantiate a Table
instead.conf
- Configuration object to use.tableName
- Name of the table.pool
- ExecutorService to be used.IOException
- if a remote or network exception occurs@Deprecated public HTable(byte[] tableName, Connection connection, ExecutorService pool) throws IOException
tableName
- Name of the table.connection
- HConnection to be used.pool
- ExecutorService to be used.IOException
- if a remote or network exception occurs.@Deprecated public HTable(TableName tableName, Connection connection, ExecutorService pool) throws IOException
IOException
@InterfaceAudience.Private public HTable(TableName tableName, ClusterConnection connection, ConnectionConfiguration tableConfig, RpcRetryingCallerFactory rpcCallerFactory, RpcControllerFactory rpcControllerFactory, ExecutorService pool) throws IOException
ConnectionFactory
class comment for how to
get a Table
instance (use Table
instead of HTable
).tableName
- Name of the table.connection
- HConnection to be used.pool
- ExecutorService to be used.IOException
- if a remote or network exception occursprotected HTable(ClusterConnection conn, BufferedMutatorParams params) throws IOException
params
.IOException
@InterfaceAudience.Private public static ThreadPoolExecutor getDefaultExecutor(org.apache.hadoop.conf.Configuration conf)
public static int getMaxKeyValueSize(org.apache.hadoop.conf.Configuration conf)
private void finishSetup() throws IOException
IOException
public 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.
getConfiguration
in interface Table
@Deprecated public static boolean isTableEnabled(String tableName) throws IOException
HBaseAdmin.isTableEnabled(byte[])
tableName
- Name of table to check.true
if table is online.IOException
- if a remote or network exception occurs@Deprecated public static boolean isTableEnabled(byte[] tableName) throws IOException
HBaseAdmin.isTableEnabled(byte[])
tableName
- Name of table to check.true
if table is online.IOException
- if a remote or network exception occurs@Deprecated public static boolean isTableEnabled(TableName tableName) throws IOException
HBaseAdmin.isTableEnabled(byte[])
tableName
- Name of table to check.true
if table is online.IOException
- if a remote or network exception occurs@Deprecated public static boolean isTableEnabled(org.apache.hadoop.conf.Configuration conf, String tableName) throws IOException
HBaseAdmin.isTableEnabled(byte[])
conf
- The Configuration object to use.tableName
- Name of table to check.true
if table is online.IOException
- if a remote or network exception occurs@Deprecated public static boolean isTableEnabled(org.apache.hadoop.conf.Configuration conf, byte[] tableName) throws IOException
HBaseAdmin.isTableEnabled(byte[])
conf
- The Configuration object to use.tableName
- Name of table to check.true
if table is online.IOException
- if a remote or network exception occurs@Deprecated public static boolean isTableEnabled(org.apache.hadoop.conf.Configuration conf, TableName tableName) throws IOException
conf
- The Configuration object to use.tableName
- Name of table to check.true
if table is online.IOException
- if a remote or network exception occurs@Deprecated public HRegionLocation getRegionLocation(String row) throws IOException
RegionLocator.getRegionLocation(byte[])
row
- Row to find.IOException
- if a remote or network exception occurs@Deprecated public HRegionLocation getRegionLocation(byte[] row) throws IOException
RegionLocator.getRegionLocation(byte[])
instead.RegionLocator
getRegionLocation
in interface RegionLocator
row
- Row to find.IOException
- if a remote or network exception occurs@Deprecated public HRegionLocation getRegionLocation(byte[] row, boolean reload) throws IOException
RegionLocator.getRegionLocation(byte[], boolean)
instead.RegionLocator
getRegionLocation
in interface RegionLocator
row
- Row to find.reload
- true to reload information or false to use cached informationIOException
- if a remote or network exception occurspublic byte[] getTableName()
getTableName
in interface HTableInterface
public TableName getName()
Table
getName
in interface RegionLocator
getName
in interface Table
@Deprecated public HConnection getConnection()
@Deprecated public int getScannerCaching()
The default value comes from hbase.client.scanner.caching
.
@Deprecated public List<Row> getWriteBuffer()
@Deprecated public void setScannerCaching(int scannerCaching)
Scan.setCaching(int)
This will override the value specified by
hbase.client.scanner.caching
.
Increasing this value will reduce the amount of work needed each time
next()
is called on a scanner, at the expense of memory use
(since more rows will need to be maintained in memory by the scanners).
scannerCaching
- the number of rows a scanner will fetch at once.public HTableDescriptor getTableDescriptor() throws IOException
table descriptor
for this table.getTableDescriptor
in interface Table
IOException
- if a remote or network exception occurs.@Deprecated public byte[][] getStartKeys() throws IOException
RegionLocator.getStartEndKeys()
insteadgetStartKeys
in interface RegionLocator
IOException
- if a remote or network exception occurs@Deprecated public byte[][] getEndKeys() throws IOException
RegionLocator.getEndKeys()
instead;getEndKeys
in interface RegionLocator
IOException
- if a remote or network exception occurs@Deprecated public Pair<byte[][],byte[][]> getStartEndKeys() throws IOException
RegionLocator.getStartEndKeys()
instead;getStartEndKeys
in interface RegionLocator
IOException
- if a remote or network exception occurs@Deprecated public NavigableMap<HRegionInfo,ServerName> getRegionLocations() throws IOException
getAllRegionLocations()
instead.This is mainly useful for the MapReduce integration.
IOException
- if a remote or network exception occurs@Deprecated public List<HRegionLocation> getAllRegionLocations() throws IOException
RegionLocator.getAllRegionLocations()
instead;This is mainly useful for the MapReduce integration.
getAllRegionLocations
in interface RegionLocator
IOException
- if a remote or network exception occurs@Deprecated public List<HRegionLocation> getRegionsInRange(byte[] startKey, byte[] endKey) throws IOException
startKey
- Starting row in range, inclusiveendKey
- Ending row in range, exclusiveIOException
- if a remote or network exception occurs@Deprecated public List<HRegionLocation> getRegionsInRange(byte[] startKey, byte[] endKey, boolean reload) throws IOException
startKey
- Starting row in range, inclusiveendKey
- Ending row in range, exclusivereload
- true to reload information or false to use cached informationIOException
- if a remote or network exception occurs@Deprecated private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey) throws IOException
startKey
- Starting row in range, inclusiveendKey
- Ending row in rangeincludeEndKey
- true if endRow is inclusive, false if exclusiveIOException
- if a remote or network exception occurs@Deprecated private Pair<List<byte[]>,List<HRegionLocation>> getKeysAndRegionsInRange(byte[] startKey, byte[] endKey, boolean includeEndKey, boolean reload) throws IOException
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 informationIOException
- if a remote or network exception occurs@Deprecated public Result getRowOrBefore(byte[] row, byte[] family) throws IOException
getRowOrBefore
in interface HTableInterface
row
- A row key.family
- Column family to include in the Result
.IOException
- if a remote or network exception occurs.public ResultScanner getScanner(Scan scan) throws IOException
HTable
must not be closed.
Table.getScanner(Scan)
has other usage details.getScanner
in interface Table
scan
- A configured Scan
object.IOException
- if a remote or network exception occurs.public ResultScanner getScanner(byte[] family) throws IOException
HTable
must not be closed.
Table.getScanner(byte[])
has other usage details.getScanner
in interface Table
family
- The column family to scan.IOException
- if a remote or network exception occurs.public ResultScanner getScanner(byte[] family, byte[] qualifier) throws IOException
HTable
must not be closed.
Table.getScanner(byte[], byte[])
has other usage details.getScanner
in interface Table
family
- The column family to scan.qualifier
- The column qualifier to scan.IOException
- if a remote or network exception occurs.public Result get(Get get) throws IOException
get
in interface Table
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.private Result get(Get get, boolean checkExistenceOnly) throws IOException
IOException
public Result[] get(List<Get> gets) throws IOException
get
in interface Table
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.public void batch(List<? extends Row> actions, Object[] results) throws InterruptedException, IOException
Table.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.batch
in interface Table
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 public Object[] batch(List<? extends Row> actions) throws InterruptedException, IOException
batch(List, Object[])
instead.Table.batch(List, Object[])
, but returns an array of
results instead of using a results parameter reference.batch
in interface Table
actions
- list of Get, Put, Delete, Increment, Append objectsIOException
InterruptedException
public <R> void batchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
Table.batch(List, Object[])
, but with a callback.batchCallback
in interface Table
IOException
InterruptedException
@Deprecated public <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.Table.batch(List)
, but with a callback.batchCallback
in interface Table
IOException
InterruptedException
public void delete(Delete delete) throws IOException
delete
in interface Table
delete
- The object that specifies what to delete.IOException
- if a remote or network exception occurs.public void delete(List<Delete> deletes) throws IOException
delete
in interface Table
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.public void put(Put put) throws IOException
put
in interface Table
put
- The data to put.IOException
public 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.
put
in interface Table
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
public void mutateRow(RowMutations rm) throws IOException
mutateRow
in interface Table
rm
- object that specifies the set of mutations to perform atomicallyIOException
public 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
in interface Table
append
- object that specifies the columns and values to be appendedIOException
- epublic Result 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
in interface Table
increment
- object that specifies the columns and amounts to be used
for the increment operationsIOException
- epublic long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) throws IOException
Table.incrementColumnValue(byte[], byte[], byte[], long, Durability)
The Durability
is defaulted to Durability.SYNC_WAL
.
incrementColumnValue
in interface Table
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.@Deprecated public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL) throws IOException
incrementColumnValue(byte[], byte[], byte[], long, Durability)
.incrementColumnValue
in interface HTableInterface
IOException
public 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.
incrementColumnValue
in interface Table
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.public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException
checkAndPut
in interface Table
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkvalue
- the expected valueput
- data to put if check succeedsIOException
- epublic boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException
checkAndPut
in interface Table
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- comparison operator to usevalue
- the expected valueput
- data to put if check succeedsIOException
- epublic boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, byte[] value, Delete delete) throws IOException
checkAndDelete
in interface Table
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkvalue
- the expected valuedelete
- data to delete if check succeedsIOException
- epublic boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException
checkAndDelete
in interface Table
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- comparison operator to usevalue
- the expected valuedelete
- data to delete if check succeedsIOException
- epublic boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, RowMutations rm) throws IOException
checkAndMutate
in interface Table
row
- to checkfamily
- column family to checkqualifier
- column qualifier to checkcompareOp
- the comparison operatorvalue
- the expected valuerm
- mutations to perform if check succeedsIOException
- epublic 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.
exists
in interface Table
get
- the GetIOException
- epublic boolean[] 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.
existsAll
in interface Table
gets
- the GetsIOException
- e@Deprecated public Boolean[] exists(List<Get> gets) throws IOException
exists
in interface HTableInterface
IOException
public void flushCommits() throws IOException
Put
operations.
This method gets called once automatically for every Put
or batch
of Put
s (when put(List<Put>)
is used) when
HTableInterface.isAutoFlush()
is true
.
flushCommits
in interface HTableInterface
IOException
public <R> void processBatchCallback(List<? extends Row> list, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException
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.IOException
- if there are problems talking to META. Per-item
exceptions are stored in the results array.InterruptedException
public void processBatch(List<? extends Row> list, Object[] results) throws IOException, InterruptedException
Row
implementations.IOException
InterruptedException
public void close() throws IOException
Table
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Table
IOException
- if a remote or network exception occurs.public void validatePut(Put put) throws IllegalArgumentException
IllegalArgumentException
public static void validatePut(Put put, int maxKeyValueSize) throws IllegalArgumentException
IllegalArgumentException
public boolean isAutoFlush()
isAutoFlush
in interface HTableInterface
true
if 'auto-flush' is enabled (default), meaning
Put
operations don't get buffered/delayed and are immediately
executed.@Deprecated public void setAutoFlush(boolean autoFlush)
setAutoFlush
in interface HTableInterface
autoFlush
- Whether or not to enable 'auto-flush'.public void setAutoFlushTo(boolean autoFlush)
clearBufferOnFail
.setAutoFlushTo
in interface HTableInterface
public void setAutoFlush(boolean autoFlush, boolean clearBufferOnFail)
When enabled (default), Put
operations don't get buffered/delayed
and are immediately executed. Failed operations are not retried. This is
slower but safer.
Turning off #autoFlush
means that multiple Put
s will be
accepted before any RPC is actually sent to do the write operations. If the
application dies before pending writes get flushed to HBase, data will be
lost.
When you turn #autoFlush
off, you should also consider the
#clearBufferOnFail
option. By default, asynchronous Put
requests will be retried on failure until successful. However, this can
pollute the writeBuffer and slow down batching performance. Additionally,
you may want to issue a number of Put requests and call
HTableInterface.flushCommits()
as a barrier. In both use cases, consider setting
clearBufferOnFail to true to erase the buffer after HTableInterface.flushCommits()
has been called, regardless of success.
In other words, if you call #setAutoFlush(false)
; HBase will retry N time for each
flushCommit, including the last one when closing the table. This is NOT recommended,
most of the time you want to call #setAutoFlush(false, true)
.
setAutoFlush
in interface HTableInterface
autoFlush
- Whether or not to enable 'auto-flush'.clearBufferOnFail
- Whether to keep Put failures in the writeBuffer. If autoFlush is true, then
the value of this parameter is ignored and clearBufferOnFail is set to true.
Setting clearBufferOnFail to false is deprecated since 0.96.BufferedMutator.flush()
public long getWriteBufferSize()
The default value comes from the configuration parameter
hbase.client.write.buffer
.
getWriteBufferSize
in interface HTableInterface
getWriteBufferSize
in interface Table
public void setWriteBufferSize(long writeBufferSize) throws IOException
If the new size is less than the current amount of data in the write buffer, the buffer gets flushed.
setWriteBufferSize
in interface HTableInterface
setWriteBufferSize
in interface Table
writeBufferSize
- The new write buffer size, in bytes.IOException
- if a remote or network exception occurs.ExecutorService getPool()
@Deprecated public static void setRegionCachePrefetch(byte[] tableName, boolean enable) throws IOException
tableName
- name of table to configure.enable
- Set to true to enable region cache prefetch. Or set to
false to disable it.IOException
@Deprecated public static void setRegionCachePrefetch(TableName tableName, boolean enable) throws IOException
IOException
@Deprecated public static void setRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf, byte[] tableName, boolean enable) throws IOException
conf
- The Configuration object to use.tableName
- name of table to configure.enable
- Set to true to enable region cache prefetch. Or set to
false to disable it.IOException
@Deprecated public static void setRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf, TableName tableName, boolean enable) throws IOException
IOException
@Deprecated public static boolean getRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf, byte[] tableName) throws IOException
conf
- The Configuration object to use.tableName
- name of table to checkIOException
@Deprecated public static boolean getRegionCachePrefetch(org.apache.hadoop.conf.Configuration conf, TableName tableName) throws IOException
IOException
@Deprecated public static boolean getRegionCachePrefetch(byte[] tableName) throws IOException
tableName
- name of table to checkIOException
@Deprecated public static boolean getRegionCachePrefetch(TableName tableName) throws IOException
IOException
public void clearRegionCache()
public 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);
coprocessorService
in interface Table
row
- The row key used to identify the remote region locationpublic <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.coprocessorService
in interface Table
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
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, 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.
coprocessorService
in interface Table
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
private List<byte[]> getStartKeysInRange(byte[] start, byte[] end) throws IOException
IOException
public void setOperationTimeout(int operationTimeout)
public int getOperationTimeout()
public void setRpcTimeout(int rpcTimeout)
public int getRpcTimeout()
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
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.batchCoprocessorService
in interface Table
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
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
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.
batchCoprocessorService
in interface Table
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
public RegionLocator getRegionLocator()
BufferedMutator getBufferedMutator() throws IOException
IOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.