Class HbaseTableUtils
- java.lang.Object
-
- com.amazonaws.athena.connectors.hbase.integ.HbaseTableUtils
-
- All Implemented Interfaces:
AutoCloseable
public class HbaseTableUtils extends Object implements AutoCloseable
This class can be used to establish a connection to a HBase instance. Once the connection is established, a new database/namespace and table can be created, and new rows can be inserted into the newly created table.
-
-
Constructor Summary
Constructors Constructor Description HbaseTableUtils(String databaseName, String tableName, String connectionStr)
The constructor establishes a connection to the HBase instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the connection to the HBase instance.void
createDbAndTable(List<String> familyColumns)
Creates the database/namespace and table in the HBase instance.void
insertRows(List<org.apache.hadoop.hbase.client.Put> rows)
Inserts rows into the newly created database table.
-
-
-
Constructor Detail
-
HbaseTableUtils
public HbaseTableUtils(String databaseName, String tableName, String connectionStr) throws IOException
The constructor establishes a connection to the HBase instance.- Parameters:
databaseName
- Name of the database or namespace.tableName
- Name of the database table.connectionStr
- Connection string used to connect to the HBase instance (e.g. ec2-000-000-000-000.compute-1.amazonaws.com:50075:2081)- Throws:
IOException
- An error was encountered while trying to connect to the HBase instance.
-
-
Method Detail
-
createDbAndTable
public void createDbAndTable(List<String> familyColumns) throws IOException
Creates the database/namespace and table in the HBase instance.- Parameters:
familyColumns
- A list of family column names.- Throws:
IOException
- An error was encountered while creating the database or table.
-
insertRows
public void insertRows(List<org.apache.hadoop.hbase.client.Put> rows) throws IOException
Inserts rows into the newly created database table.- Parameters:
rows
- A list of Put (row) objects containing details such as the family name, column name, and value.- Throws:
IOException
- An error was encountered trying to insert rows into the table.
-
close
public void close() throws IOException
Closes the connection to the HBase instance.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
-