[py-lmdb] Re: create_env() and open_env()

  • From: "Dinesh Vadhia" <dineshvadhia@xxxxxxxxxxx>
  • To: <py-lmdb@xxxxxxxxxxxxx>
  • Date: Fri, 23 May 2014 05:19:08 -0700

The lmdb api doc says:

http://symas.com/mdb/doc/group__mdb.html#gaad6be3d8dcd4ea01f8df436f41d158d4
"create_env(): This function allocates memory for a MDB_env structure. To release the allocated memory and discard the handle, call mdb_env_close(). Before the handle may be used, it must be opened using mdb_env_open()."

http://symas.com/mdb/doc/group__mdb.html#ga32a193c6bf4d7d5c5d579e71f22e9340
"env       An environment handle returned by mdb_env_create()"

The way I read this (and probably incorrectly!) is that create_env() creates an Env. It says, "allocates memory for a MDB_env structure" but it also sets aside storage using map_size (surely?).

Say, an lmdb db has been created with create_env(). Now, how to use it within a program or modules? Is create_env() called first to allocate memory and a handle and then open_env() to use it? If so, py-lmdb's lmdb.open(path, *kwargs) doesn't ask for the Env handle.

Just a bit confused!


--------------------------------------------------
From: "David Wilson" <dw@xxxxxxxx>
Sent: Wednesday, May 21, 2014 4:41 PM
To: <py-lmdb@xxxxxxxxxxxxx>
Subject: [py-lmdb] Re: create_env() and open_env()

Hey Dinesh,

Neither of these are functions from py-lmdb. There it is simply
"lmdb.open()", unless I'm somehow confused. :)


David

On Wed, May 21, 2014 at 03:44:50PM -0700, Dinesh Vadhia wrote:
Maybe I don't understand the difference but:

a. create_env() creates the initial environment including setting the path to
the env, the map_size etc.

b. open_env(path) opens an env

In practice, open_env() has to be passed all the parameters that were used for
create_env().

It seems as if create_env() and open_env() are identical.

Is this right?



Other related posts: