3

I am using Hbase mapreduce to calculate a report. In the reducer, I try to clear the 'result' column family, and then add a new 'total' column. But I find the column family is delete, but new data is not insert. It seems the Put action doesn't work. Do you know why?

sample code in reducer class:

      Delete del = new Delete(rowkey.getBytes());
      del.addFamily(RESULT);
      context.write(new ImmutableBytesWritable(Bytes.toBytes(key.toString())), del);
      Put put = new Put(rowkey.getBytes());
      put.addColumn(RESULT, TOTAL, totalNum);
      context.write(new ImmutableBytesWritable(Bytes.toBytes(key.toString())), put);
B.H.
  • 107
  • 9

1 Answers1

3

It is hbase limitation: Deletes mask Puts

27.3.1. Deletes mask Puts Deletes mask puts, even puts that happened after the delete was entered. See HBASE-2256. Remember that a delete writes a tombstone, which only disappears after then next major compaction has run. Suppose you do a delete of everything ⇐ T. After this you do a new put with a timestamp ⇐ T. This put, even if it happened after the delete, will be masked by the delete tombstone. Performing the put will not fail, but when you do a get you will notice the put did have no effect. It will start working again after the major compaction has run. These issues should not be a problem if you use always-increasing versions for new puts to a row. But they can occur even if you do not care about time: just do delete and put immediately after each other, and there is some chance they happen within the same millisecond.

B.H.
  • 107
  • 9