Database Reference
In-Depth Information
Method name
Description
deleteFamily(byte[] family, long
timestamp)
This deletes all the columns of the
specified family with a timestamp
less than or equal to the specified
timestamp
deleteFamilyVersion(byte[] family,
long timestamp)
This deletes all the columns of the
specified family with a timestamp
equal to the specified timestamp
Here is a complete code example for deleting data from HBase:
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
public class SingleGetEx {
public static void main(String[] args) throws IOException {
// Get instance of Default Configuration
Configuration conf = HBaseConfiguration.create();
// Get table instance
HTable table = new HTable(conf, "tab1");
// Create Delete with rowkey
Delete delete = new Delete(Bytes.toBytes("row-1"));
// Add a column with value "Hello", in "cf1:greet", to the Put.
delete.deleteColumns(Bytes.toBytes("cf1"),Bytes.toBytes("greet"));
table.delete(delete);
table.close();
}
}
Data deletion in HBase can happen for a single row or in the form of a batch
representing multiple rows using the following method of the HTable class:
void delete(List<Delete> deletes)
Search WWH ::




Custom Search