'Good enough' solution for this case happened to be based on checkAndPut()
method. What I intended to do is new row insertion with key duplication check and for individual inserts solution is perfect:
HTable checkAndPut()
method can check certain column is not set (check it fornull
value).- As rows anyway contain some 'ID' field which is mandatory for all objects (you can use any other field that you always set for your object) it is possible to check if row exists.
Put
object passed tocheckAndPut()
is to contain initial object state with mandatory field set.
Well, for bulk insertion (what I really needed) it happened to be too slow so I moved to UUID used as row keys without any checks on new row insertion. For me it is much better. The only consideration in this case is really good random generator. Standard Java java.util.UUID
class contains everything I need including it is based on somewhat slow but pretty strong java.security.SecureRandom
generator.
Just note: it looks like HBase user row locking feature is going to be dropped due to security / other risks related to its usage.