juji-io / datalevin

A simple, fast and versatile Datalog database
https://github.com/juji-io/datalevin
Eclipse Public License 1.0
1.07k stars 60 forks source link

Use FreeBSD package manager provided liblmdb. #253

Closed markusalbertgraf closed 1 month ago

markusalbertgraf commented 1 month ago

Hi,

datalevin 0.9 throws "Unsupported OS FreeBSD" on FreeBSD.

FreeBSD provides a package and a port for lmdb, currently at version 0.9.32.1 see https://www.freshports.org/databases/lmdb/.

This patch checks whether the file liblmdb.so exists in the canonical location and points the system property "lmdbjava.native.lib" at it. If the file does not exist it throws with a reminder to install the package.

I added the function use-os-package instead of adding it to the platform detection in extract-lmdb because it would make the function name extract-lmdb misleading.

Running lein test, all tests pass on FreeBSD 14.0 amd64.

huahaiy commented 1 month ago

Wouldn't it be better to modify extract-lmdb (change it to access-lmdb), so that checking OS provided LMDB is done before throwing exception? Right now, this PR checks OS package first. It is possible that Datalevin requires a version of LMDB that is different from the OS provided, for we mostly tracks the master branch of LMDB that would be likely ahead of OS provided ones. It works for you case now by accident.

We will likely add freebsd to the jar as well in the future. We use zig for cross compilation, so it is simple to add a new target at https://github.com/juji-io/dtlvnative . Right now, freebsd is not a cross-compilation target for zig, so we will do that after it becomes so.