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."); }
Feedback
Was this page helpful?
Provide feedbackThank 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