Hbase-checkAndPut()方法

Hbase中關於表中數據的添加(修改)的方法,常用的是void put(Put put),沒有返回值

但是如果put了相同的數據,那麼就會報錯,其實不是很友好

所以,還有checkAndPut()方法

   * Atomically checks if a row/family/qualifier value matches the expected
   * value. If it does, it adds the put.  If the passed value is null, the check
   * is for the lack of column (ie: non-existance)


boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
    byte[] value, Put put) throws IOException

該方法會先進行校驗,如果數據(row,family,qualifier,value)存在,則不會執行put,並返回false,否則,就會執行,返回true

因此,該方法相比於put()方法會安全一些。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章