2013-11-05

Delete all versions of a column with Clojure-HBase

To delete all versions of a given column, we call Delete.deleteColumns(family, quantifier) in Java. However, it is not yet implemented in Clojure-HBase. I have submitted an issue and a pull-request. Before the pull-request is accepted, you can delete a row in the right way like this:
(hb/with-table [ht (hb/table TABLE)]
  (io!
    (.delete ht (.deleteColumns (new Delete (tobyte ROWKEY))
                                (tobyte COLUMNFAMILY) (tobyte COLUMNQUANTIFIER)))))

DON'T DO

I did something stupid like calling:
(hb/with-table [ht (hb/table TABLE)]
  (hb/delete ROWKEY :with-timestamp-before
             3000000000   ; DON'T TO THIS
             [[:column CF CQ]]))
In fact, HBase inserts a DELETE mark with the timestamp, meaning that you can no longer put a new value before it is expired.

沒有留言: