@InterfaceAudience.Public @InterfaceStability.Stable public class RemoteHTable extends java.lang.Object implements Table
| Constructor and Description |
|---|
RemoteHTable(Client client,
Configuration conf,
byte[] name)
Constructor
|
RemoteHTable(Client client,
Configuration conf,
java.lang.String name)
Constructor
|
RemoteHTable(Client client,
java.lang.String name)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
Result |
append(Append append)
Appends values to one or more columns within a single row.
|
java.lang.Object[] |
batch(java.util.List<? extends Row> actions)
Same as
Table.batch(List, Object[]), but returns an array of
results instead of using a results parameter reference. |
void |
batch(java.util.List<? extends Row> actions,
java.lang.Object[] results)
Method that does a batch call on Deletes, Gets, Puts, Increments and Appends.
|
<R> java.lang.Object[] |
batchCallback(java.util.List<? extends Row> actions,
Batch.Callback<R> callback)
Same as
Table.batch(List), but with a callback. |
<R> void |
batchCallback(java.util.List<? extends Row> actions,
java.lang.Object[] results,
Batch.Callback<R> callback)
Same as
Table.batch(List, Object[]), but with a callback. |
<R extends Message> |
batchCoprocessorService(Descriptors.MethodDescriptor method,
Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype)
Creates an instance of the given
com.google.protobuf.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 Message> |
batchCoprocessorService(Descriptors.MethodDescriptor method,
Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype,
Batch.Callback<R> callback)
Creates an instance of the given
com.google.protobuf.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. |
protected CellSetModel |
buildModelFromPut(Put put) |
protected java.lang.String |
buildMultiRowSpec(byte[][] rows,
int maxVersions) |
protected Result[] |
buildResultFromModel(CellSetModel model) |
protected java.lang.String |
buildRowSpec(byte[] row,
java.util.Map familyMap,
long startTime,
long endTime,
int maxVersions) |
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 |
close()
Releases any resources held or pending changes in internal buffers.
|
CoprocessorRpcChannel |
coprocessorService(byte[] row)
Creates and returns a
com.google.protobuf.RpcChannel instance connected to the
table region containing the specified row. |
<T extends Service,R> |
coprocessorService(java.lang.Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable)
Creates an instance of the given
com.google.protobuf.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 com.google.protobuf.Service instance. |
<T extends Service,R> |
coprocessorService(java.lang.Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable,
Batch.Callback<R> callback)
Creates an instance of the given
com.google.protobuf.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(java.util.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.
|
java.lang.Boolean[] |
exists(java.util.List<Get> gets)
Deprecated.
|
boolean[] |
existsAll(java.util.List<Get> gets)
exists(List) is really a list of get() calls.
|
void |
flushCommits() |
Result |
get(Get get)
Extracts certain cells from a given row.
|
Result[] |
get(java.util.List<Get> gets)
Extracts certain cells from the given rows, in batch.
|
Configuration |
getConfiguration()
Returns the
org.apache.hadoop.conf.Configuration object used by this instance. |
TableName |
getName()
Gets the fully qualified table name instance of this table.
|
Result |
getRowOrBefore(byte[] row,
byte[] family) |
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. |
byte[] |
getTableName() |
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,
Durability durability)
Atomically increments a column value.
|
boolean |
isAutoFlush() |
void |
mutateRow(RowMutations rm)
Performs multiple mutations atomically on a single row.
|
void |
put(java.util.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)
Sets the size of the buffer in bytes.
|
public RemoteHTable(Client client, java.lang.String name)
client - name - public RemoteHTable(Client client, Configuration conf, java.lang.String name)
client - conf - name - public RemoteHTable(Client client, Configuration conf, byte[] name)
client - conf - name - protected java.lang.String buildRowSpec(byte[] row,
java.util.Map familyMap,
long startTime,
long endTime,
int maxVersions)
protected java.lang.String buildMultiRowSpec(byte[][] rows,
int maxVersions)
protected Result[] buildResultFromModel(CellSetModel model)
protected CellSetModel buildModelFromPut(Put put)
public byte[] getTableName()
public TableName getName()
Tablepublic Configuration getConfiguration()
Tableorg.apache.hadoop.conf.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 Tablepublic HTableDescriptor getTableDescriptor() throws java.io.IOException
Tabletable descriptor for this table.getTableDescriptor in interface Tablejava.io.IOException - if a remote or network exception occurs.public void close()
throws java.io.IOException
Tablepublic Result get(Get get) throws java.io.IOException
Tableget in interface Tableget - 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().java.io.IOException - if a remote or network exception occurs.public Result[] get(java.util.List<Get> gets) throws java.io.IOException
Tableget in interface Tablegets - 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.java.io.IOException - if a remote or network exception occurs.public boolean exists(Get get) throws java.io.IOException
TableThis 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.
public boolean[] existsAll(java.util.List<Get> gets) throws java.io.IOException
@Deprecated public java.lang.Boolean[] exists(java.util.List<Get> gets) throws java.io.IOException
java.io.IOExceptionpublic void put(Put put) throws java.io.IOException
Tablepublic void put(java.util.List<Put> puts) throws java.io.IOException
TableThis 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.
public void delete(Delete delete) throws java.io.IOException
Tablepublic void delete(java.util.List<Delete> deletes) throws java.io.IOException
Tabledelete in interface Tabledeletes - 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
Deletes are executed).java.io.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 flushCommits()
throws java.io.IOException
java.io.IOExceptionpublic ResultScanner getScanner(Scan scan) throws java.io.IOException
TableScan
object.
Note that the passed Scan's start row and caching properties
maybe changed.getScanner in interface Tablescan - A configured Scan object.java.io.IOException - if a remote or network exception occurs.public ResultScanner getScanner(byte[] family) throws java.io.IOException
TablegetScanner in interface Tablefamily - The column family to scan.java.io.IOException - if a remote or network exception occurs.public ResultScanner getScanner(byte[] family, byte[] qualifier) throws java.io.IOException
TablegetScanner in interface Tablefamily - The column family to scan.qualifier - The column qualifier to scan.java.io.IOException - if a remote or network exception occurs.public boolean isAutoFlush()
public Result getRowOrBefore(byte[] row, byte[] family) throws java.io.IOException
java.io.IOExceptionpublic boolean checkAndPut(byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Put put)
throws java.io.IOException
TablecheckAndPut in interface Tablerow - to checkfamily - column family to checkqualifier - column qualifier to checkvalue - the expected valueput - data to put if check succeedsjava.io.IOException - epublic boolean checkAndPut(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
Put put)
throws java.io.IOException
TablecheckAndPut in interface Tablerow - to checkfamily - column family to checkqualifier - column qualifier to checkcompareOp - comparison operator to usevalue - the expected valueput - data to put if check succeedsjava.io.IOException - epublic boolean checkAndDelete(byte[] row,
byte[] family,
byte[] qualifier,
byte[] value,
Delete delete)
throws java.io.IOException
TablecheckAndDelete in interface Tablerow - to checkfamily - column family to checkqualifier - column qualifier to checkvalue - the expected valuedelete - data to delete if check succeedsjava.io.IOException - epublic boolean checkAndDelete(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
Delete delete)
throws java.io.IOException
TablecheckAndDelete in interface Tablerow - to checkfamily - column family to checkqualifier - column qualifier to checkcompareOp - comparison operator to usevalue - the expected valuedelete - data to delete if check succeedsjava.io.IOException - epublic Result increment(Increment increment) throws java.io.IOException
TableThis operation does not appear atomic to readers. Increments are done under a single row lock, so write operations to a row are synchronized, but readers do not take row locks so get and scan operations can see this operation partially completed.
public Result append(Append append) throws java.io.IOException
TableThis operation does not appear atomic to readers. Appends are done under a single row lock, so write operations to a row are synchronized, but readers do not take row locks so get and scan operations can see this operation partially completed.
public long incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount)
throws java.io.IOException
TableTable.incrementColumnValue(byte[], byte[], byte[], long, Durability)
The Durability is defaulted to Durability.SYNC_WAL.
incrementColumnValue in interface Tablerow - 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).java.io.IOException - if a remote or network exception occurs.public long incrementColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long amount,
Durability durability)
throws java.io.IOException
Tableamount 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 Tablerow - 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.java.io.IOException - if a remote or network exception occurs.public void batch(java.util.List<? extends Row> actions, java.lang.Object[] results) throws java.io.IOException
TableTable.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 Tableactions - 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 retriesjava.io.IOExceptionpublic java.lang.Object[] batch(java.util.List<? extends Row> actions) throws java.io.IOException
TableTable.batch(List, Object[]), but returns an array of
results instead of using a results parameter reference.public <R> void batchCallback(java.util.List<? extends Row> actions, java.lang.Object[] results, Batch.Callback<R> callback) throws java.io.IOException, java.lang.InterruptedException
TableTable.batch(List, Object[]), but with a callback.batchCallback in interface Tablejava.io.IOExceptionjava.lang.InterruptedExceptionpublic <R> java.lang.Object[] batchCallback(java.util.List<? extends Row> actions, Batch.Callback<R> callback) throws java.io.IOException, java.lang.InterruptedException
TableTable.batch(List), but with a callback.batchCallback in interface Tablejava.io.IOExceptionjava.lang.InterruptedExceptionpublic CoprocessorRpcChannel coprocessorService(byte[] row)
Tablecom.google.protobuf.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 com.google.protobuf.RpcChannel instance can be used to access a published
coprocessor com.google.protobuf.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 Tablerow - The row key used to identify the remote region locationpublic <T extends Service,R> java.util.Map<byte[],R> coprocessorService(java.lang.Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable)
throws ServiceException,
java.lang.Throwable
Tablecom.google.protobuf.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 com.google.protobuf.Service instance.coprocessorService in interface TableT - the com.google.protobuf.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 com.google.protobuf.Service
instance connected to that region.ServiceExceptionjava.lang.Throwablepublic <T extends Service,R> void coprocessorService(java.lang.Class<T> service,
byte[] startKey,
byte[] endKey,
Batch.Call<T,R> callable,
Batch.Callback<R> callback)
throws ServiceException,
java.lang.Throwable
Tablecom.google.protobuf.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 TableT - 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.ServiceExceptionjava.lang.Throwablepublic void mutateRow(RowMutations rm) throws java.io.IOException
Tablepublic long getWriteBufferSize()
Table
The default value comes from the configuration parameter
hbase.client.write.buffer.
getWriteBufferSize in interface Tablepublic void setWriteBufferSize(long writeBufferSize)
throws java.io.IOException
TableIf the new size is less than the current amount of data in the write buffer, the buffer gets flushed.
setWriteBufferSize in interface TablewriteBufferSize - The new write buffer size, in bytes.java.io.IOException - if a remote or network exception occurs.public <R extends Message> java.util.Map<byte[],R> batchCoprocessorService(Descriptors.MethodDescriptor method,
Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype)
throws ServiceException,
java.lang.Throwable
Tablecom.google.protobuf.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 TableR - the response type for the coprocessor Service methodmethod - 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.ServiceExceptionjava.lang.Throwablepublic <R extends Message> void batchCoprocessorService(Descriptors.MethodDescriptor method,
Message request,
byte[] startKey,
byte[] endKey,
R responsePrototype,
Batch.Callback<R> callback)
throws ServiceException,
java.lang.Throwable
Tablecom.google.protobuf.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 TableR - the response type for the coprocessor Service methodmethod - 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 regionServiceExceptionjava.lang.Throwablepublic boolean checkAndMutate(byte[] row,
byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value,
RowMutations rm)
throws java.io.IOException
TablecheckAndMutate in interface Tablerow - to checkfamily - column family to checkqualifier - column qualifier to checkcompareOp - the comparison operatorvalue - the expected valuerm - mutations to perform if check succeedsjava.io.IOException - e