[Date Prev][Date Next]
Re: [LMDB] Two API questions
On Mon, May 04, 2015 at 09:48:42AM +0200, Klaus Malorny wrote:
> during the implementation of my first project using LMDB I got two questions:
> 1. I wanted to write a small utility function that determines a rough
> estimation of the free space, using the mdb_env_stat, mdb_env_info and
> mdb_stat functions, summing up the block counts, multiplying it with the
> block size and putting this in relation to the map size. Typically I know
> which databases exist, but I wondered whether there would be a possibility
> to enumerate the existing databases and did not find anything. Is it
> correct that currently there is no way to get the names?
Correct. Read the mdb_stat.c or mdb_dump.c source code.
> 2. For one task, I needed to walk through a subset of the keys with a cursor
> and to delete key/value pairs that meet some criteria. From the
> documentation, it is unclear to me how to proceed after a deletion,
> i.e. which cursor operation should be used to access the next key/value pair.
> Both MDB_GET_CURRENT and MDB_NEXT seemed to work. Which one is preferred
> or the "officially" correct way? I guess MDB_NEXT.
Both work, there is no official approach. But this task is typically
accomplished using a _NEXT operation in other DB libraries, like BerkeleyDB.
If you like keepping your code logically similar to other DBs (which I find
to be a good idea) then use MDB_NEXT.