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);
checkAndPut
checkAndPut-比较根据传递的CompareOp将值与hbase中的当前值进行比较。 CompareOp = EQUALS如果期望值相等,则将值添加到放置对象中。
checkAndMutate-根据传递的CompareOp将值与hbase中的当前值进行比较。CompareOp= EQUALS如果期望值相等,则将值添加到rowmutation对象。 / p>
您可以按照希望突变在hbase中执行的顺序向rowmutation对象添加和删除多个对象
在行变异中,放置和删除内容的顺序
RowMutations变异=新的RowMutations(row);
//添加新列
Put put = new Put(row);
put.add(cf,col1,v1);
put.add(cf,col2,v2);
Delete delete = new Delete(row);
delete.deleteFamily(cf1,现在);
//删除列族并将新列添加到同一族
突变。add(delete);
mutation.add(put);
table.mutateRow(mutations);
checkAndPut