Deleting an Index
Function
You can manage HBase secondary indexes using methods provided in org.apache.hadoop.hbase.hindex.client.HIndexAdmin. This class provides methods of querying and deleting an index.
Example Code
The following code snippet belongs to the dropIndex method in the HBaseSample class of the com.huawei.bigdata.hbase.examples package.
public void dropIndex() {
LOG.info("Entering dropIndex.");
String indexName = "index_name";
List<String> indexNameList = new ArrayList<String>();
indexNameList.add(indexName);
IndexAdmin iAdmin = null;
try {
// Instantiate HIndexAdmin Object
iAdmin = HIndexClient.newHIndexAdmin(conn.getAdmin());
// Delete Secondary Index
iAdmin.dropIndex(tableName, indexNameList);
LOG.info("Drop index successfully.");
} catch (IOException e) {
LOG.error("Drop index failed.");
} finally {
if (iAdmin != null) {
try {
// Close Secondary Index
iAdmin.close();
} catch (IOException e) {
LOG.error("Close admin failed.");
}
}
}
LOG.info("Exiting dropIndex.");
} Last Article: Creating a Secondary Index
Next Article: Secondary Index-based Query
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.