basho / eleveldb

Erlang LevelDB API
262 stars 177 forks source link

Max value comparator #224

Closed santialvarezcolombo closed 8 years ago

santialvarezcolombo commented 8 years ago

The new logging and caching module for antidote, will use eleveldb as one of its possible backends. In order to use eleveldb, we needed to code a new comparator, so keys get sorted as we want.

Keys are composed as follows:

{antidote_key, max_value_in_vc, vc_hash, op/snap, vc}

Sorting of keys

Keys get sorted first by the Antidote key. Then we look at the MAX value of it's VC, sorting first the biggest one. We reverse the "natural" order, so we can have the most recent operations first. If the max value for two keys matches, we sort taking into account the hash value. For matching hashes, we check the rest of the key, sorting accordingly.

As Erlang serialises objects sent to eleveldb, according http://erlang.org/doc/apps/erts/erl_ext_dist.html, so what we do is check those code to compare keys.

santialvarezcolombo commented 8 years ago

Sorry, this PR was intended for a fork, not this repo.