com.baidubce.services.tablestoragehbaseclient.adaptor
Class TableStorageAdaptor

java.lang.Object
  extended by com.baidubce.services.tablestoragehbaseclient.adaptor.TableStorageAdaptor

public class TableStorageAdaptor
extends Object

Used to access Tablestorage service.


Constructor Summary
TableStorageAdaptor(String endpoint, String instanceName, String accessKeyId, String secretAccessKey)
          Construct a TableStorage Adaptor to connect with TableStorage.
 
Method Summary
 Object[] batch(String tableName, List<? extends org.apache.hadoop.hbase.client.Row> actions)
          Perform Row operations in batch.
 void batchDeleteRow(String tableName, List<org.apache.hadoop.hbase.client.Delete> deletes)
          Batch delete rows in the table
 org.apache.hadoop.hbase.client.Result[] batchGetRow(String tableName, List<org.apache.hadoop.hbase.client.Get> gets)
          Batch get rows in the table.
 void batchPutRow(String tableName, List<org.apache.hadoop.hbase.client.Put> puts)
          Batch put rows to the table.
 void close()
          Close the connection with TableStorage.
 void createTable(String tableName, CompressType compressType, int maxVersions, int ttl)
          Create table in TableStorage.
 void deleteRow(String tableName, org.apache.hadoop.hbase.client.Delete delete)
          Delete a row in the table.
 void dropTable(String tableName)
          Drop table in TableStorage
 byte[][] getEndKeys(String tableName)
          Get the maximum key for every region in the table.
 org.apache.hadoop.hbase.client.Result getRow(String tableName, org.apache.hadoop.hbase.client.Get get)
          Get a row in the table.
 org.apache.hadoop.hbase.util.Pair<byte[][],byte[][]> getStartEndKeys(String tableName)
          Get the minimum key and the maximum key for every region in the table.
 byte[][] getStartKeys(String tableName)
          Get the minimum key for every region in the table.
 org.apache.hadoop.hbase.HTableDescriptor getTable(String tableName)
          Get the Table Descriptor from TableStorage.
 boolean isTableAvailable(String tableName)
          Check if the table is available
 List<String> listTable()
          List tables from TableStorage.
 void putRow(String tableName, org.apache.hadoop.hbase.client.Put put)
          Put a row to the table.
 List<org.apache.hadoop.hbase.client.Result> scan(String tableName, org.apache.hadoop.hbase.client.Scan scan, String startRowkey, ByteArrayOutputStream nextStartRowkeyStream)
          Scan data in the table.
 void updateTable(String tableName, CompressType compressType, int maxVersions, int ttl)
          Update table in TableStorage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableStorageAdaptor

public TableStorageAdaptor(String endpoint,
                           String instanceName,
                           String accessKeyId,
                           String secretAccessKey)
Construct a TableStorage Adaptor to connect with TableStorage.

Parameters:
endpoint - TableStorage endpoint e.g. bts.bd.baidubce.com.
instanceName - The target instance name.
accessKeyId - User's accessKeyId.
secretAccessKey - User's secretAccessKey.
Method Detail

getTable

public org.apache.hadoop.hbase.HTableDescriptor getTable(String tableName)
                                                  throws IOException
Get the Table Descriptor from TableStorage.

Parameters:
tableName - The name of the table.
Returns:
The Table Descriptor
Throws:
IOException - If a permission error or remote error occurs

listTable

public List<String> listTable()
                       throws IOException
List tables from TableStorage.

Returns:
A List of table name.
Throws:
IOException - If a permission error or remote error occurs

createTable

public void createTable(String tableName,
                        CompressType compressType,
                        int maxVersions,
                        int ttl)
                 throws IOException
Create table in TableStorage.

Parameters:
tableName - The name of the table.
compressType - The compression type of the table.
maxVersions - The max versions of the table.
ttl - TimeToLive of the table, in seconds.
Throws:
IOException - If a permission error or remote error occurs

dropTable

public void dropTable(String tableName)
               throws IOException
Drop table in TableStorage

Parameters:
tableName - The name of the table.
Throws:
IOException - If a permission error or remote error occurs

isTableAvailable

public boolean isTableAvailable(String tableName)
                         throws IOException
Check if the table is available

Parameters:
tableName - The name of the table.
Returns:
true if the table is available, or false for not.
Throws:
IOException - If a permission error or remote error occurs.

updateTable

public void updateTable(String tableName,
                        CompressType compressType,
                        int maxVersions,
                        int ttl)
                 throws IOException
Update table in TableStorage.

Parameters:
tableName - The name of the table.
compressType - The compression type of the table.
maxVersions - The max versions of the table.
ttl - TimeToLive of the table, in seconds.
Throws:
IOException - If a permission error or remote error occurs.

batch

public Object[] batch(String tableName,
                      List<? extends org.apache.hadoop.hbase.client.Row> actions)
               throws IOException
Perform Row operations in batch. The order of executions is the same as the order of actions.

Parameters:
tableName - The name of the table.
actions - List of Row operation. Only support Get, Put and Delete.
Returns:
Result of actions.
Throws:
IOException - If a permission error or remote error occurs.

getRow

public org.apache.hadoop.hbase.client.Result getRow(String tableName,
                                                    org.apache.hadoop.hbase.client.Get get)
                                             throws IOException
Get a row in the table.

Parameters:
tableName - The name of the target table.
get - Used to specify the target data in the table.
Returns:
Data in the table.
Throws:
IOException - If a permission error or remote error occurs.

batchGetRow

public org.apache.hadoop.hbase.client.Result[] batchGetRow(String tableName,
                                                           List<org.apache.hadoop.hbase.client.Get> gets)
                                                    throws IOException
Batch get rows in the table.

Parameters:
tableName - The name of the target table.
gets - List of Gets.
Returns:
Data in the table.
Throws:
IOException - If a permission error or remote error occurs.

putRow

public void putRow(String tableName,
                   org.apache.hadoop.hbase.client.Put put)
            throws IOException
Put a row to the table.

Parameters:
tableName - The name of the target table.
put - Used to describe a single row.
Throws:
IOException - If a permission error or remote error occurs.

batchPutRow

public void batchPutRow(String tableName,
                        List<org.apache.hadoop.hbase.client.Put> puts)
                 throws IOException
Batch put rows to the table.

Parameters:
tableName - The name of the target table.
puts - List of Puts.
Throws:
IOException - If a permission error or remote error occurs.

deleteRow

public void deleteRow(String tableName,
                      org.apache.hadoop.hbase.client.Delete delete)
               throws IOException
Delete a row in the table.

Parameters:
tableName - The name of the target table.
delete - Used to specify the target data in the table.
Throws:
IOException - If a permission error or remote error occurs.

batchDeleteRow

public void batchDeleteRow(String tableName,
                           List<org.apache.hadoop.hbase.client.Delete> deletes)
                    throws IOException
Batch delete rows in the table

Parameters:
tableName - The name of the target table.
deletes - List of Deletes.
Throws:
IOException - If a permission error or remote error occurs.

scan

public List<org.apache.hadoop.hbase.client.Result> scan(String tableName,
                                                        org.apache.hadoop.hbase.client.Scan scan,
                                                        String startRowkey,
                                                        ByteArrayOutputStream nextStartRowkeyStream)
                                                 throws IOException
Scan data in the table.

Parameters:
tableName - The name of the target table.
scan - Used to specify the target data in the table.
startRowkey - This scan will start with the maximum of scan.getStartRow() and startRowkey.
nextStartRowkeyStream - Next scan should start with it.
Returns:
Data in the table.
Throws:
IOException - If a permission error or remote error occurs.

getStartKeys

public byte[][] getStartKeys(String tableName)
                      throws IOException
Get the minimum key for every region in the table.

Parameters:
tableName - The name of the target table.
Returns:
Array of minimum key.
Throws:
IOException - If a permission error or remote error occurs.

getEndKeys

public byte[][] getEndKeys(String tableName)
                    throws IOException
Get the maximum key for every region in the table.

Parameters:
tableName - The name of the target table.
Returns:
Array of maximum key.
Throws:
IOException - If a permission error or remote error occurs.

getStartEndKeys

public org.apache.hadoop.hbase.util.Pair<byte[][],byte[][]> getStartEndKeys(String tableName)
                                                                     throws IOException
Get the minimum key and the maximum key for every region in the table.

Parameters:
tableName - The name of the target table.
Returns:
Pair of minimum key and maximum key.
Throws:
IOException - If a permission error or remote error occurs.

close

public void close()
Close the connection with TableStorage.



Copyright © 2020. All rights reserved.