Hbase checkAndPut和checkAndMutate有什么區別?(What is the difference between Hbase checkAndPut and checkAndMutate?


 

 

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-

 

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);



checkAndMutate 
https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#checkAndMutate-byte:A字節: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-

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM