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()方法会安全一些。

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