hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zhenyu Zhong <zhongresea...@gmail.com>
Subject about Delete and Put in TableOutputFormat
Date Thu, 21 Jan 2010 19:36:21 GMT
I tried to use Put to update a record for the same rowkey and the same
version. However, I found that it resulted in multiple values in the same

For example:  I can use hbase shell to fetch the values in the same
row    ts    value
row_a 20100101  10
row_a 20100101   11
row_a 20100101   12

Now I tried to override the TableOutputFormat class such that in the
function, basically I want to do a delete before put.

 public void write(KEY key, Writable value)

    throws IOException {

      if (value instanceof Put) {

       Put put = new Put((Put)value);

       // I tried to add the delete before put

       byte[] row = put.getRow();

       long ts = put.getTimeStamp();

       Delete delete = new Delete(row, ts, null);

       // add end


       this.table.put(new Put((Put)value));


      else if (value instanceof Delete) this.table.delete(new

      else throw new IOException("Pass a Delete or a Put");


However, after I rerun the data upload, I found that I couldn't use the
rowkey to fetch the record, but the strange thing is I can scan the table to
see all the rows.

May I ask what is a good way to do a delete before put for the same row key
and same timestamp?



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message