[Date Prev][Date Next] [Chronological] [Thread] [Top]

Question about MDB_INTEGERKEY flag



Hello,
sorry for being a noob but I have a question regarding the MDB_INTEGERKEY flag.

I am using the LMDB library through Lua wrappers from
https://github.com/shmul/lightningmdb.

I have an LMDB file which was created with keys that are named "key0",
"key1", ...

When I open the database with mdb_dbi_open(txn, NULL, MDB_INTEGERKEY,
& dbi) and enumerate keys with successive calls to
mdb_cursor_get(cursor, &key, &val, MDB_NEXT) the key values that I
read are the same as in the LMDB (i.e. "key0", ...). Since I am using
the MDB_INTEGERKEY flag I was hoping to read keys as 1,2,3, etc. And I
thought I would then be able to retrieve entries doing e.g.
mdb_get(txn, dbi, "1", &data).

Am I doing anything wrong or is MDB_INTEGERKEY just used to enforce
integer keys when putting entries?

To give my question some background: what I am trying to achieve is to
read entries in my LMDB file in random/arbitrary order. Since I have
may 10 million entries or more, I do not want to store keys in memory.
I'd rather retrieve entries using an index. Is that possible? Note
that I do not have control over the key naming convention so keys
could be named anything.

Thanks!

Greg.