类 TableStorageAdaptor


  • public class TableStorageAdaptor
    extends Object
    Used to access Tablestorage service.
    • 构造器详细资料

      • TableStorageAdaptor

        public TableStorageAdaptor​(String endpoint,
                                   String instanceName,
                                   String accessKeyId,
                                   String secretAccessKey)
        Construct a TableStorage Adaptor to connect with TableStorage.
        参数:
        endpoint - TableStorage endpoint e.g. bts.bd.baidubce.com.
        instanceName - The target instance name.
        accessKeyId - User's accessKeyId.
        secretAccessKey - User's secretAccessKey.
    • 方法详细资料

      • getTable

        public org.apache.hadoop.hbase.HTableDescriptor getTable​(String tableName)
                                                          throws IOException
        Get the Table Descriptor from TableStorage.
        参数:
        tableName - The name of the table.
        返回:
        The Table Descriptor
        抛出:
        IOException - If a permission error or remote error occurs
      • listTable

        public List<String> listTable()
                               throws IOException
        List tables from TableStorage.
        返回:
        A List of table name.
        抛出:
        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.
        参数:
        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.
        抛出:
        IOException - If a permission error or remote error occurs
      • dropTable

        public void dropTable​(String tableName)
                       throws IOException
        Drop table in TableStorage
        参数:
        tableName - The name of the table.
        抛出:
        IOException - If a permission error or remote error occurs
      • isTableAvailable

        public boolean isTableAvailable​(String tableName)
                                 throws IOException
        Check if the table is available
        参数:
        tableName - The name of the table.
        返回:
        true if the table is available, or false for not.
        抛出:
        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.
        参数:
        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.
        抛出:
        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.
        参数:
        tableName - The name of the table.
        actions - List of Row operation. Only support Get, Put and Delete.
        返回:
        Result of actions.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        get - Used to specify the target data in the table.
        返回:
        Data in the table.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        gets - List of Gets.
        返回:
        Data in the table.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        put - Used to describe a single row.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        puts - List of Puts.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        delete - Used to specify the target data in the table.
        抛出:
        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
        参数:
        tableName - The name of the target table.
        deletes - List of Deletes.
        抛出:
        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.
        参数:
        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.
        返回:
        Data in the table.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        返回:
        Array of minimum key.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        返回:
        Array of maximum key.
        抛出:
        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.
        参数:
        tableName - The name of the target table.
        返回:
        Pair of minimum key and maximum key.
        抛出:
        IOException - If a permission error or remote error occurs.
      • close

        public void close()
        Close the connection with TableStorage.