gpt4 book ai didi

hadoop - 同时使用 Delete 和 Put 时无法在 HBase 中插入新数据

转载 作者:可可西里 更新时间:2023-11-01 14:48:36 25 4
gpt4 key购买 nike

我正在使用 Hbase mapreduce 来计算报告。在 reducer 中,我尝试清除“result”列族,然后添加一个新的“total”列。但我发现列族是删除的,但新数据不是插入的。 Put 操作似乎不起作用。你知道为什么吗?

reducer 类中的示例代码:

      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);

最佳答案

是hbase的限制: 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.

关于hadoop - 同时使用 Delete 和 Put 时无法在 HBase 中插入新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40622669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com