📅  最后修改于: 2020-11-30 04:18:18             🧑  作者: Mango
本章介绍了用于HBase的Java客户端API,该API用于对HBase表执行CRUD操作。 HBase用Java编写,并具有Java本机API。因此,它提供对数据处理语言(DML)的编程访问。
将HBase配置文件添加到配置中。此类属于org.apache.hadoop.hbase包。
S.No. | Methods and Description |
---|---|
1 |
static org.apache.hadoop.conf.Configuration create() This method creates a Configuration with HBase resources. |
HTable是代表HBase表的HBase内部类。它是表的实现,用于与单个HBase表进行通信。该类属于org.apache.hadoop.hbase.client类。
S.No. | Constructors and Description |
---|---|
1 |
HTable() |
2 |
HTable(TableName tableName, ClusterConnection connection, ExecutorService pool) Using this constructor, you can create an object to access an HBase table. |
S.No. | Methods and Description |
---|---|
1 |
void close() Releases all the resources of the HTable. |
2 |
void delete(Delete delete) Deletes the specified cells/row. |
3 |
boolean exists(Get get) Using this method, you can test the existence of columns in the table, as specified by Get. |
4 |
Result get(Get get) Retrieves certain cells from a given row. |
5 |
org.apache.hadoop.conf.Configuration getConfiguration() Returns the Configuration object used by this instance. |
6 |
TableName getName() Returns the table name instance of this table. |
7 |
HTableDescriptor getTableDescriptor() Returns the table descriptor for this table. |
8 |
byte[] getTableName() Returns the name of this table. |
9 |
void put(Put put) Using this method, you can insert data into the table. |
此类用于对单行执行Put操作。它属于org.apache.hadoop.hbase.client软件包。
S.No. | Constructors and Description |
---|---|
1 |
Put(byte[] row) Using this constructor, you can create a Put operation for the specified row. |
2 |
Put(byte[] rowArray, int rowOffset, int rowLength) Using this constructor, you can make a copy of the passed-in row key to keep local. |
3 |
Put(byte[] rowArray, int rowOffset, int rowLength, long ts) Using this constructor, you can make a copy of the passed-in row key to keep local. |
4 |
Put(byte[] row, long ts) Using this constructor, we can create a Put operation for the specified row, using a given timestamp. |
S.No. | Methods and Description |
---|---|
1 |
Put add(byte[] family, byte[] qualifier, byte[] value) Adds the specified column and value to this Put operation. |
2 |
Put add(byte[] family, byte[] qualifier, long ts, byte[] value) Adds the specified column and value, with the specified timestamp as its version to this Put operation. |
3 |
Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) Adds the specified column and value, with the specified timestamp as its version to this Put operation. |
4 |
Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) Adds the specified column and value, with the specified timestamp as its version to this Put operation. |
此类用于在单行上执行Get操作。此类属于org.apache.hadoop.hbase.client软件包。
S.No. | Constructor and Description |
---|---|
1 |
Get(byte[] row) Using this constructor, you can create a Get operation for the specified row. |
2 | Get(Get get) |
S.No. | Methods and Description |
---|---|
1 |
Get addColumn(byte[] family, byte[] qualifier) Retrieves the column from the specific family with the specified qualifier. |
2 |
Get addFamily(byte[] family) Retrieves all columns from the specified family. |
此类用于在单行上执行Delete操作。要删除整行,请使用要删除的行实例化Delete对象。此类属于org.apache.hadoop.hbase.client软件包。
S.No. | Constructor and Description |
---|---|
1 |
Delete(byte[] row) Creates a Delete operation for the specified row. |
2 |
Delete(byte[] rowArray, int rowOffset, int rowLength) Creates a Delete operation for the specified row and timestamp. |
3 |
Delete(byte[] rowArray, int rowOffset, int rowLength, long ts) Creates a Delete operation for the specified row and timestamp. |
4 |
Delete(byte[] row, long timestamp) Creates a Delete operation for the specified row and timestamp. |
S.No. | Methods and Description |
---|---|
1 |
Delete addColumn(byte[] family, byte[] qualifier) Deletes the latest version of the specified column. |
2 |
Delete addColumns(byte[] family, byte[] qualifier, long timestamp) Deletes all versions of the specified column with a timestamp less than or equal to the specified timestamp. |
3 |
Delete addFamily(byte[] family) Deletes all versions of all columns of the specified family. |
4 |
Delete addFamily(byte[] family, long timestamp) Deletes all columns of the specified family with a timestamp less than or equal to the specified timestamp. |
此类用于获取Get或Scan查询的单行结果。
S.No. | Constructors |
---|---|
1 |
Result() Using this constructor, you can create an empty Result with no KeyValue payload; returns null if you call raw Cells(). |
S.No. | Methods and Description |
---|---|
1 |
byte[] getValue(byte[] family, byte[] qualifier) This method is used to get the latest version of the specified column. |
2 |
byte[] getRow() This method is used to retrieve the row key that corresponds to the row from which this Result was created. |