Hbase checkAndPut和checkAndMutate有什么区别?

时间:2016-11-22 09:47:32

标签: hadoop hbase key-value bigdata

在Hbase 1.2.4中 checkAndPut和checkAndMutate有什么区别?

1 个答案:

答案 0 :(得分:2)

checkAndPut - 根据传递的CompareOp将值与hbase中的当前值进行比较。 CompareOp = EQUALS如果期望值相等,则将值添加到put对象。

checkAndMutate - 根据传递的CompareOp.CompareOp = EQUALS将值与hbase中的当前值进行比较。如果期望值相等,则将值添加到rowmutation对象。

您可以按照希望在hbase中执行变异的顺序添加多个put和delete对象到rowmutation对象

在rowmutation中,put和deletes的顺序很重要

RowMutations mutations = new RowMutations(row);
//add new columns
Put put = new Put(row);
put.add(cf, col1, v1);
put.add(cf, col2, v2);

Delete delete = new Delete(row);
delete.deleteFamily(cf1, now);

//delete column family and add new columns to same family
mutations.add(delete);
mutations.add(put);

table.mutateRow(mutations);

checkAndMutate https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#checkAndMutate-byte:A-byte:A-byte:A-org.apache.hadoop.hbase.filter.CompareFilter.CompareOp-byte:A-org.apache.hadoop.hbase.client.RowMutations-

checkAndPut

https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#checkAndPut-byte:A-byte:A-byte:A-org.apache.hadoop.hbase.filter.CompareFilter.CompareOp-byte:A-org.apache.hadoop.hbase.client.Put-