The Data Management Group contains the API managing data as a whole (not record based), or on a large scale. More...
Classes | |
struct | mdbm_clean_data |
Typedefs | |
typedef int(* | mdbm_clean_func )(MDBM *, const datum *, const datum *, struct mdbm_clean_data *, int *quit) |
Functions | |
void | mdbm_compress_tree (MDBM *db) |
Compresses the existing MDBM directory. More... | |
void | mdbm_truncate (MDBM *db) |
Truncates the MDBM to single empty page. More... | |
void | mdbm_prune (MDBM *db, int(*prune)(MDBM *, datum, datum, void *), void *param) |
Prunes an MDBM. More... | |
void | mdbm_purge (MDBM *db) |
Purges (removes) all entries from an MDBM. More... | |
int | mdbm_set_cleanfunc (MDBM *db, mdbm_clean_func func, void *data) |
The specified cleaner function will be called by mdbm_clean. More... | |
int | mdbm_clean (MDBM *db, int pagenum, int flags) |
Mark entries clean/re-usable in the database for the specified page. More... | |
The Data Management Group contains the API managing data as a whole (not record based), or on a large scale.
typedef int(* mdbm_clean_func)(MDBM *, const datum *, const datum *, struct mdbm_clean_data *, int *quit) |
void mdbm_compress_tree | ( | MDBM * | db | ) |
Compresses the existing MDBM directory.
Attempts to rebalance the directory and to compress the db to a smaller size.
NOTE: This function does not work with Windowed-Mode. For that use case, you should export your data and re-import it into a clean MDBM.
NOTE: Support for this feature in V4 should be considered experimental. Please run it on an offline DB, after making a backup of your uncompressed DB.
[in,out] | db | Database handle |
void mdbm_truncate | ( | MDBM * | db | ) |
Truncates the MDBM to single empty page.
V3 WARNING: This loses the existing configuration information (ex. large object support or a hash function that was set other than the default).
[in,out] | db | Database handle |
Prunes an MDBM.
Iterates through the database calling the supplied prune function for each item in the database. Prune function:
The user-supplied param pointer is passed as the 4th parameter to the prune function. If the prune function returns 1, the item is deleted. If the prune function returns 0, the item is retained.
[in,out] | db | Database handle |
[in] | prune | Prune function |
[in] | param | User supplied param, passed to prune function. |
void mdbm_purge | ( | MDBM * | db | ) |
Purges (removes) all entries from an MDBM.
This does not change the MDBM's configuration or general structure.
[in,out] | db | Database handle |
int mdbm_set_cleanfunc | ( | MDBM * | db, |
mdbm_clean_func | func, | ||
void * | data | ||
) |
The specified cleaner function will be called by mdbm_clean.
It can be called by mdbm_store should space be needed on a page. mdbm_store will call it if there is no registered shake function (see mdbm_limit_size_v3) or the registered shake function does not clear enough space for the store. An entry marked clean means it may be re-used to store new data.
NOTE: V3 API
The clean function is typedef'd like the following:
When the mdbm_clean_func is called to check an entry on a page, it will be passed the data parameter from the call to mdbm_set_cleanfunc.
The quit parameter is used by callers of the mdbm_clean_func to determine whether other entries on the page should be cleaned. If the mdbm_clean_func sets quit to true (non 0) then no other entries on the page will be checked for cleaning. Otherwise mdbm_clean or mdbm_store will continue checking entries on the page to determine if they can be re-used/cleaned.
The mdbm_clean_func should return true (non 0) if the key/value may be re-used, AKA clean. IMPORTANT: To enable this feature cache mode must be set on the database. Ex:
Both of the cache mode flags are required. The second flag(MDBM_CACHEMODE_GDSF) used in the example can be replaced by MDBM_CACHEMODE_LFU or MDBM_CACHEMODE_LRU.
[in,out] | db | Database handle |
[in] | func | User-provided function to determine re-use of an entry |
[in] | data | Opaque data passed to the user-provided function func |
-1 | Error, and errno is set |
0 | Success |
int mdbm_clean | ( | MDBM * | db, |
int | pagenum, | ||
int | flags | ||
) |
Mark entries clean/re-usable in the database for the specified page.
If pagenum is -1, then clean all pages. It relies on the user provided callback function set via mdbm_set_cleanfunc to determine re-usability/cleanliness of an entry. To be clean means an entry can be re-used to store new data.
NOTE: V3 API
[in,out] | db | Database handle |
[in] | pagenum | Page number to start cleaning. If < 0, then clean all pages in the database. |
[in] | flags | Ignored |
-1 | Error |
Number | of cleaned entries |