Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force 64-bit LMDB to generate a 32-bit database?

Tags:

c++

c

linux

build

lmdb

The executable which uses the lmdb library is in 64 bit linux format .

Because dependency libraries of the executable are in 64 bit .Building executable & lmdb lib as 32bit solution not possible.

Is there any way i can force 64 bit lmdb lib to generate a 32 bit lmdb database.

I need this 32 bit database file because the generated db will be exported to a 32 bit device.

Note : db generated on 64bit machine will not work on 32 bit machine.

like image 660
Rajesh Gopu Avatar asked Jun 07 '17 08:06

Rajesh Gopu


1 Answers

I guess, the usage of a 64 bit database on a 32 bit lmdb is hard til impossible due to the fact, that lmdb is based on memory-mapping.

Thus, a converter would be necessary requiring the understanding of the underlying data format. This link The LMDB file format seems to be a good start for this.

A cheap alternative seems to be to dump the file on the 64 bit platform (mdb_dump) and to reload it on the 32 bit platform (mdb_load). Though, this causes limitations as pointed out in the linked man page:

Dumping and reloading databases that use user-defined comparison functions will result in new databases that use the default comparison functions. In this case it is quite likely that the reloaded database will be damaged beyond repair permitting neither record storage nor retrieval.

However, during searching the internet, I somewhere read that this can be used to port a 32 bit DB to 64 bit. I can only suspect that it should work the opposite way also (as I've never seen the format). As the dump is a text format, it should be possible – may be with an intermediate text processing step.

Another, IMHO rather cheap alternative, would be to run a 32 bit lmdb on the 64 bit platform. As I know that is common and usual on Windows, I was not (fully) sure for Linux and found this: SE: How to run 32-bit app in Ubuntu 64-bit?. Unfortunately, the questioner stated that it is not an option in this specific case.

like image 71
Scheff's Cat Avatar answered Oct 24 '22 09:10

Scheff's Cat