HBase update operation

爱⌒轻易说出口 提交于 2021-02-06 09:01:14

问题


  1. I am new to HBase, I find in HBase client API, update operation is not supported? Is that correct?
  2. If so, what is the suggested best practices to update the values for a specific rowkey?

回答1:


You can use PUT which will create or update the value of any cell. You don't need to use delete unless you want the new version to not have some of the old cells .

say we have

r1:f1:c1:value1
r1:f1:c2:value2 

you can put r1:f1:c1 new value and you'd get:

r1:f1:c1:new value 
r1:f1:c2:value2 

Note that actually each cell is stored as rowkey, column family, cell, timestamp, version and value. So depending on how you set versioning (per column family) you can also access the old values including doing a point in time query to see deleted values.




回答2:


I think what you want to do is perform a Put operation. You can look at the HBase's Put API client docs as well as this blog post titled: Java Example Code using HBase Data Model Operations for some examples, and descriptions of the operations.

To update a row, you will have to issue a sequence of "Delete" and "Put", in a single Mutation, so they are seen as an update externally.

See the Class RowMutations documentation on how to build such a call.



来源:https://stackoverflow.com/questions/13667901/hbase-update-operation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!