Querying HBase Global Secondary Indexes
Function
Manage HBase global secondary indexes by calling the method in org.apache.hadoop.hbase.hindex.global.GlobalIndexAdmin. listIndices is used for querying indexes, including the definitions and status of all indexes related to the current user table.
Code Sample
The following code snippets are in the listIndices method in the GlobalSecondaryIndexSample class of the com.huawei.bigdata.hbase.examples package.
In this case, all indexes corresponding to the user table user_table are queried.
/**
* List indexes
*/
public void testListIndexes() {
LOG.info("Entering testListIndexes.");
try (GlobalIndexAdmin iAdmin = GlobalIndexClient.newIndexAdmin(conn.getAdmin())) {
for (Pair<HIndexSpecification, IndexState> indexPair : iAdmin.listIndices(tableName)) {
LOG.info("index spec:{}, index state:{}", indexPair.getFirst(), indexPair.getSecond());
}
LOG.info("List indexes successfully.");
} catch (IOException e) {
LOG.error("List indexes failed.", e);
}
LOG.info("Exiting testListIndexes.");
} What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot