Skip to content

@jnatkins /DeleteTest.java
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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 {
@Override
public int run(String[] args) throws Exception {
setConf(HBaseConfiguration.addHbaseResources(getConf()));
/* 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));
puts.add(put);
}
htable.put(puts);
Delete del = new Delete(Bytes.toBytes("key"));
del.deleteColumn(Bytes.toBytes("f1"), Bytes.toBytes("c1"), 3);
htable.delete(del);
return 0;
}
public static void main(String args[]) throws Exception {
System.exit(ToolRunner.run(new DeleteTest(), args));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.