问题
In Hbase 1.2.4 What is the difference between checkAndPut and checkAndMutate?
回答1:
checkAndPut - compares the value with the current value from the hbase according to the passed CompareOp. CompareOp=EQUALS Adds the value to the put object if expected value is equal.
checkAndMutate - compares the value with the current value from the hbase according to the passed CompareOp.CompareOp=EQUALS Adds the value to the rowmutation object if expected value is equal.
you can add multiple put and delete objects in the order in which you wants the mutation to executes in hbase to the rowmutation object
In rowmutation the order of puts and deletes matter
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-
来源:https://stackoverflow.com/questions/40738516/what-is-the-difference-between-hbase-checkandput-and-checkandmutate