Create a gist now

Instantly share code, notes, and snippets.

Test deleting a single HBase cell, while avoiding masking of earlier versions.
package org.kiji.examples.importers;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configured;
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.Put;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
public class DeleteTest extends Configured implements Tool {
public int run(String[] args) throws Exception {
/* Open the HBase table */
HTable htable = new HTable(getConf(), "del_test");
List<Put> puts = new ArrayList<Put>();
for (int i = 1; i <= 5; i++) {
Put put = new Put(Bytes.toBytes("key"));
put.add(Bytes.toBytes("f1"), Bytes.toBytes("c1"), i, Bytes.toBytes("value" + i));
Delete del = new Delete(Bytes.toBytes("key"));
del.deleteColumn(Bytes.toBytes("f1"), Bytes.toBytes("c1"), 3);
return 0;
public static void main(String args[]) throws Exception {
System.exit( DeleteTest(), args));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment