Correspondence between several related classes and the HBase data model
| Java class |
HBase Data Model |
| Hbaseadmin |
Databases (database) |
| Hbaseconfiguration |
| Htable |
Tables (table) |
| Htabledescriptor |
Columns family (column Family) |
| Put |
Row modifier (column Qualifier) |
| Get |
| Scanner |
First, Hbaseconfiguration
Relationship: Org.apache.hadoop.hbase.HBaseConfiguration
Role: Configuring HBase
| return value |
Function |
Describe |
| void |
AddResource (Path file) |
Add a resource by a file referred to by a given path |
| void |
Clear () |
Clears all properties that have been set |
| String |
Get (String name) |
Gets the value of the property name |
| String |
Getboolean (String name, Boolean defaultvalue) |
Gets a Boolean property value that returns the default property value if its property value type part is Boolean |
| void |
Set (string name, String value) |
To set a value by property name |
| void |
SetBoolean (String name, Boolean value) |
To set a Boolean-type property value |
Usage examples:
Hbaseconfiguration hconfig = new Hbaseconfiguration () hconfig.set ("Hbase.zookeeper.property.clientPort", "2181");
This method sets the port number of "Hbase.zookeeper.property.clientPort" to 2181. In general, Hbaseconfiguration uses constructors to initialize and then use other methods.
Second, hbaseadmin
Relationship: Org.apache.hadoop.hbase.client.HBaseAdmin
Role: Provides an interface to manage table information for HBase databases. It provides methods such as creating tables, deleting tables, listing table entries, making tables valid or invalid, and adding or removing table column family members.
| return value |
Function |
Describe |
| void |
AddColumn (String tableName, hcolumndescriptor column) |
Add to a table that already exists |
| Checkhbaseavailable (hbaseconfiguration conf) |
static function to see if HBase is in a running state |
| CreateTable (htabledescriptor desc) |
Create a table, synchronize operations |
| Deletetable (byte[] tableName) |
Delete a table that already exists |
| Enabletable (byte[] tableName) |
To make a table in a valid state |
| Disabletable (byte[] tableName) |
Leave table in an invalid state |
| Htabledescriptor[] |
Listtables () |
List all user Control table entries |
| void |
Modifytable (byte[] tableName, Htabledescriptor HTD) |
Modifying the schema of a table is an asynchronous operation that may take a certain amount of time |
| Boolean |
Tableexists (String tableName) |
Check if the table exists |
Usage examples:
Hbaseadmin admin = new hbaseadmin (config); admin.disabletable ("TableName")
Third, Htabledescriptor
Relationship: Org.apache.hadoop.hbase.HTableDescriptor
Function: The column family that contains the name of the table that is extremely corresponding to the table
| return value |
Function |
Describe |
| void |
Addfamily (Hcolumndescriptor) |
Add a family of columns |
| Hcolumndescriptor |
Removefamily (byte[] column) |
Remove a family of columns |
| Byte[] |
GetName () |
Get the name of the table |
| Byte[] |
GetValue (byte[] key) |
Gets the value of the property |
| void |
SetValue (string key, String value) |
Set the value of a property |
Usage examples:
Htabledescriptor HTD = new htabledescriptor (table), htd.addfamily (New Hcolumndescriptor ("Family"));
In the above example, a column family is added for Htabledescriptor with a Hcolumndescriptor instance: family
Iv. Hcolumndescriptor
Relationship: Org.apache.hadoop.hbase.HColumnDescriptor
Role: Maintains information about the column family, such as the version number, compression settings, and so on. It is usually used when creating a table or adding a column family to a table. Column families cannot be modified directly after they are created, only by deleting and recreating them. When a column family is deleted, the data in the column family is also deleted.
| return value |
Function |
Describe |
| Byte[] |
GetName () |
Get the name of the column family |
| Byte[] |
GetValue (byte[] key) |
Gets the value of the corresponding property |
| void |
SetValue (string key, String value) |
Set the value of the corresponding property |
Usage examples:
Htabledescriptor HTD = new Htabledescriptor (tablename); Hcolumndescriptor col = new Hcolumndescriptor ("Content:"); htd.addfamily (col);
This example adds a content column family
Wu, htable
Relationship: Org.apache.hadoop.hbase.client.HTable
Function: can be used to communicate directly with the HBase table. This method is non-thread-safe for update operations.
| return value |
Function |
Describe |
| void |
Checkadnput (byte[] row, byte[] family, byte[] qualifier, byte[] value, put put |
Automatically checks if Row/family/qualifier matches a given value |
| void |
Close () |
Releases all resources or suspends updates in the internal buffer |
| Boolean |
exists (get get) |
Checks if the value specified by the Get instance exists in the Htable column |
| Result |
Get (Get Get) |
Gets the value that corresponds to some cell of the specified row |
| Byte[][] |
Getendkeys () |
Gets the end key value for each region of the current open table |
| Resultscanner |
Getscanner (byte[] family) |
Gets the scanner instance of the current given column family |
| Htabledescriptor |
Gettabledescriptor () |
Gets the Htabledescriptor instance of the current table |
| Byte[] |
Gettablename () |
Get table name |
| Static Boolean |
Istableenabled (hbaseconfiguration conf, String tableName) |
Check if the table is valid |
| void |
Put (put put) |
Add a value to a table |
Usage examples:
htable table = new htable (conf, bytes.tobytes (tablename)); Resultscanner scanner = table.getscanner (family);
Six, Put
Relationship: Org.apache.hadoop.hbase.client.Put
Action: Used to add an action to a single row
| return value |
Function |
Describe |
| Put |
Add (byte[] family, byte[] qualifier, byte[] value) |
Adds the specified column and corresponding value to the put instance |
| Put |
Add (byte[] family, byte[] qualifier, long ts, byte[] value) |
Adds the specified column and corresponding value and timestamp to the put instance |
| Byte[] |
GetRow () |
Get the row of a put instance |
| Rowlock |
Getrowlock () |
Get the row lock for a put instance |
| Long |
Gettimestamp () |
Gets the timestamp of the put instance |
| Boolean |
IsEmpty () |
Check if Familymap is empty |
| Put |
Settimestamp (Long TimeStamp) |
Set the timestamp of a put instance |
Usage examples:
htable table = new Htable (conf,bytes.tobytes (tablename)); Put p = new put (brow);//Create a put operation for the specified line p.add (family,qualifier,value); Table.put (P);
Seven, Get
Relationship: Org.apache.hadoop.hbase.client.Get
Function: Used to get information about a single row
| return value |
Function |
Describe |
| Get |
AddColumn (byte[] family, byte[] qualifier) |
Gets the columns that correspond to the specified column family and column modifiers |
| Get |
Addfamily (byte[] family) |
Gets all columns of its corresponding column by the specified column family |
| Get |
Settimerange (Long Minstamp,long Maxstamp) |
Gets the version number of the column for the specified pickup |
| Get |
SetFilter (Filter filter) |
Set server-side filters when performing a get operation |
Usage examples:
htable table = new htable (conf, bytes.tobytes (tablename)); Get g = new Get (bytes.tobytes (row));
Viii. Result
Relationship: Org.apache.hadoop.hbase.client.Result
Function: Gets or retrieves a single row value of a table after a get or scan operation is stored. Use the methods provided by this class to get the values directly or various map structures (Key-value pairs)
| return value |
Function |
Describe |
| Boolean |
Containscolumn (byte[] family, byte[] qualifier) |
Checks whether the specified column exists |
| Navigablemap<byte[],byte[]> |
Getfamilymap (byte[] family) |
Gets the key-value pairs of the modifiers and values that are contained by the corresponding column family |
| Byte[] |
GetValue (byte[] family, byte[] qualifier) |
Get the latest value for the corresponding column |
Nine, Resultscanner
Relationship: Interface
Function: interface for client to get value
| return value |
Function |
Describe |
| void |
Close () |
Close scanner and release the resources assigned to it |
| Result |
Next () |
Gets the value of the next row
|
Transfer from http://www.cnblogs.com/NicholasLee/archive/2012/09/13/2683432.html
HBase Java API Class Introduction