Tag Archives: checkAndPut

HBase checkandput() method

The common method for adding (modifying) data in a table in Hbase is void put(put put), which returns no value
But if you put the same data, you get an error, which is not very friendly
So, there’s also the checkAndPut() method

   * 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

If the data (Row, family, Qualifier, value) is present, then put will not be performed and false will be returned; otherwise, true will be performed
Therefore, this method is safer than the put() method.