Disabling HBase Global Secondary Indexes
Function
The index status of the global secondary index determines whether the index is valid. By modifying the index status, you can disable, enable, or discard the index (no index data is generated). You can modify the index status by calling the method in org.apache.hadoop.hbase.hindex.global.GlobalIndexAdmin.
Code Sample
The following code snippets are in the GlobalSecondaryIndexSample class of the com.huawei.bigdata.hbase.examples package.
In this case, the idx_id_age index is disabled. That is, the index is not used during query, but index data is generated.
/**
* alter index to UNUSABLE state.
*/
public void testAlterIndex() {
LOG.info("Entering testAlterIndex.");
List<String> indexNameList = Lists.newArrayList("idx_id_age");
// Instantiate HIndexAdmin Object
try (GlobalIndexAdmin iAdmin = GlobalIndexClient.newIndexAdmin(conn.getAdmin())) {
iAdmin.alterGlobalIndicesUnusable(tableName, indexNameList);
LOG.info("Alter indices to UNUSABLE successfully.");
} catch (IOException e) {
LOG.error("Alter indices to UNUSABLE failed.", e);
}
LOG.info("Exiting testAlterIndex.");
} 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