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