在Hbase 1.2.4中 checkAndPut和checkAndMutate有什么区别?
答案 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);
checkAndPut