basho/riak_kv — pull request #314 by seancribbs (2012-04-10 20:16:24+00:00)
Title: Add 2I to Memory backend

As it says, this adds secondary indexes to the memory backend. Why?

* The memory backend is useful when running automated test suites because it is less expensive than creating and deleting LevelDB instances.
* ETS is capable of providing this feature with minimal additional work.

Caveats:

* Index postings are not considered when computing the size of an object, and therefore do not count towards its eviction when used as an LRU. This could be added later but is potentially expensive to compute without introducing a coupling to `riak_object`.
* It is necessary to use `ets:match_delete/2` and `ets:select/1,3` operations to efficiently select items from the index, as ETS has no concept of cursors beyond `ets:first/1` and `ets:next/2` which do not let you specify a starting key. `match` and `select` have been known to be locky in certain scenarios.