HBase中刪除一條數據的方法是通過調用Delete類的實例來實現。刪除數據的步驟如下:
Delete delete = new Delete(Bytes.toBytes("rowkey"));
delete.setTimestamp(timestamp);
delete.addColumn(Bytes.toBytes("columnFamily"), Bytes.toBytes("columnQualifier"));
delete.addFamily(Bytes.toBytes("columnFamily"));
delete.setTimeRange(minTimestamp, maxTimestamp);
Table table = connection.getTable(TableName.valueOf("table"));
table.delete(delete);
注意:在刪除數據之前,需要確保HBase表已經存在,并且已經建立連接(Connection)和表(Table)的實例。