Implementation:Heibaiying BigData Notes HBaseUtils Delete Operations
Appearance
| Knowledge Sources | |
|---|---|
| Domains | NoSQL, Big_Data |
| Last Updated | 2026-02-10 10:00 GMT |
Overview
Concrete tool for deleting rows, cells, and tables from HBase provided by the HBaseUtils utility class.
Description
The HBaseUtils class provides three deletion methods covering the full range of HBase delete operations:
- deleteRow -- Deletes an entire row by placing tombstone markers for all cells in the row.
- deleteColumn -- Deletes a specific cell identified by row key, column family, and qualifier.
- deleteTable -- Performs the two-step administrative operation of disabling and then deleting a table.
The deleteRow and deleteColumn methods use the Delete class from the HBase client API, while deleteTable uses the Admin interface for administrative operations.
Usage
- Use
deleteRowto remove an entire entity from a table. - Use
deleteColumnto remove a specific attribute while preserving the rest of the row. - Use
deleteTableto permanently remove a table and all its data during cleanup or decommissioning.
Code Reference
Source Location
code/Hbase/hbase-java-api-2.x/src/main/java/com/heibaiying/HBaseUtils.java (Lines 232-266)
Signature
// Delete an entire row
public static boolean deleteRow(String tableName, String rowKey) throws IOException
// Delete a specific cell
public static boolean deleteColumn(String tableName, String rowKey,
String familyName, String qualifier) throws IOException
// Delete an entire table (disables then deletes)
public static boolean deleteTable(String tableName) throws IOException
Import
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.util.Bytes;
I/O Contract
Inputs (deleteRow)
| Name | Type | Required | Description |
|---|---|---|---|
| tableName | String | Yes | The name of the HBase table containing the row to delete. |
| rowKey | String | Yes | The row key identifying the row to delete. |
Inputs (deleteColumn)
| Name | Type | Required | Description |
|---|---|---|---|
| tableName | String | Yes | The name of the HBase table containing the cell to delete. |
| rowKey | String | Yes | The row key of the row containing the cell. |
| familyName | String | Yes | The column family of the cell to delete. |
| qualifier | String | Yes | The column qualifier of the cell to delete. |
Inputs (deleteTable)
| Name | Type | Required | Description |
|---|---|---|---|
| tableName | String | Yes | The name of the HBase table to delete. The table will be disabled first if it is currently enabled. |
Outputs
| Name | Type | Description |
|---|---|---|
| result (deleteRow) | boolean | Returns true upon successful row deletion.
|
| result (deleteColumn) | boolean | Returns true upon successful cell deletion.
|
| result (deleteTable) | boolean | Returns true upon successful table deletion.
|
Usage Examples
// 1. Delete an entire row
boolean rowDeleted = HBaseUtils.deleteRow("users", "row1");
System.out.println("Row deleted: " + rowDeleted);
// 2. Delete a specific cell (column)
boolean cellDeleted = HBaseUtils.deleteColumn("users", "row2", "info", "email");
System.out.println("Cell deleted: " + cellDeleted);
// 3. Delete an entire table (disables then deletes)
boolean tableDeleted = HBaseUtils.deleteTable("old_users");
System.out.println("Table deleted: " + tableDeleted);
The internal implementation for each method:
// deleteRow - internal logic (simplified)
Table table = connection.getTable(TableName.valueOf(tableName));
Delete delete = new Delete(Bytes.toBytes(rowKey));
table.delete(delete);
table.close();
return true;
// deleteColumn - internal logic (simplified)
Table table = connection.getTable(TableName.valueOf(tableName));
Delete delete = new Delete(Bytes.toBytes(rowKey));
delete.addColumn(Bytes.toBytes(familyName), Bytes.toBytes(qualifier));
table.delete(delete);
table.close();
return true;
// deleteTable - internal logic (simplified)
Admin admin = connection.getAdmin();
TableName tn = TableName.valueOf(tableName);
admin.disableTable(tn); // Step 1: disable
admin.deleteTable(tn); // Step 2: delete
admin.close();
return true;
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment