First of all, I wanted to thank you for developing and contributing to
community this state of the art library!
I have couple of questions about the API. I did not
1. I've noticed that MDB_val contains "void* mv_data" and not "const
Is there a reason for requiring non const pointers in this data structure?
I am asking because the c++ functions in my code that wrap lmdb API - they
receive "const char* key" argument that I am either forced to forcefully
const_cast the argument into void* or to strdup just to pass it into the
For put methods, it seems that at some point MDB must copy the data from
mv_data to its storage so mv_data may be const ptr in this case.
For get methods, MDB just changes the value of the pointer to point to its
internal memory buffer and the clients should not change the contents of
the buffer (I think) so again it can be const.
Am I wrong?
2. I do not completely understand how to use lmdb in multi-threaded
environment . Is it correct to say that there can be only one open write
transaction per MDB_env? In addition each thread can have at most one open
transaction and this transaction is thread-local?
3. Is it possible to reuse dbi handle for all the transactions and all
threads? In other words, is it possible at initialization step (when
opening the database) to do the following:
mdb_env_open(env, "some_path", MDB_WRITEMAP | MDB_NOSYNC , 0664);
mdb_txn_begin(env, NULL, 0, &txn);
mdb_dbi_open(txn, NULL, 0, &dbi);
mdb_txn_commit(txn); // needed to keep dbi valid?
and then to use value of dbi for all the subsequent operations on that db?
Show replies by date