Skip to content

Commit

Permalink
expose mdb_set_dupsort
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Sep 24, 2024
1 parent 3a54bfd commit 0ccfb6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions heed/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,22 @@ impl<KC, DC, C> Database<KC, DC, C> {
pub fn lazily_decode_data(&self) -> Database<KC, LazyDecode<DC>, C> {
self.remap_types::<KC, LazyDecode<DC>>()
}

/// Set a custom data comparison function for a MDB_DUPSORT database.
///
/// http://www.lmdb.tech/doc/group__internal.html#gacef4ec3dab0bbd9bc978b73c19c879ae
pub fn set_dupsort_cmp(
&self,
txn: &mut RwTxn,
cmp: lmdb_master_sys::MDB_cmp_func,
) -> Result<bool> {
let result = unsafe { mdb_result(ffi::mdb_set_dupsort(txn.txn.txn, self.dbi, cmp)) };

match result {
Ok(()) => Ok(true),
Err(err) => Err(err.into()),
}
}
}

impl<KC, DC, C> Clone for Database<KC, DC, C> {
Expand Down
6 changes: 3 additions & 3 deletions heed/src/mdb/lmdb_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pub use ffi::{
mdb_env_get_fd, mdb_env_get_flags, mdb_env_get_maxkeysize, mdb_env_info, mdb_env_open,
mdb_env_set_flags, mdb_env_set_mapsize, mdb_env_set_maxdbs, mdb_env_set_maxreaders,
mdb_env_stat, mdb_env_sync, mdb_filehandle_t, mdb_get, mdb_put, mdb_reader_check,
mdb_set_compare, mdb_stat, mdb_txn_abort, mdb_txn_begin, mdb_txn_commit, mdb_version,
MDB_cursor, MDB_dbi, MDB_env, MDB_stat, MDB_txn, MDB_val, MDB_CP_COMPACT, MDB_CURRENT,
MDB_RDONLY, MDB_RESERVE,
mdb_set_compare, mdb_set_dupsort, mdb_stat, mdb_txn_abort, mdb_txn_begin, mdb_txn_commit,
mdb_version, MDB_cursor, MDB_dbi, MDB_env, MDB_stat, MDB_txn, MDB_val, MDB_CP_COMPACT,
MDB_CURRENT, MDB_RDONLY, MDB_RESERVE,
};
use lmdb_master_sys as ffi;

Expand Down

0 comments on commit 0ccfb6b

Please sign in to comment.