lmdb-safe icon indicating copy to clipboard operation
lmdb-safe copied to clipboard

Allowing easy access to keyConv

Open mzealey opened this issue 6 years ago • 0 comments

My use-case is that I want to look up the nearest key with .lower_bound and then compare it, or the previous one with the key I searched for. If I expose keyConv as per https://github.com/PowerDNS/pdns/commit/0844062224f43eac67a1c53ab3dee7420b453466#diff-562825383c4b03c7c0504a94cfc4d2abR388 for example, it means that keyConv is called twice. The easiest way to do this that I can think of is exposing keyConv function as above, and then adding an optional flag called something like raw_key to the functions that normally call keyConv which would assume that the key has already been converted. Then you could write code such as:

string rawkey = ....keyConv<1>(key);
txn.lower_bound<0>(rawkey, raw_key=true);

mzealey avatar Jul 07 '19 19:07 mzealey