Class 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 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.