Classes | Typedefs | Functions
Data Management Group

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...
 

Detailed Description

The Data Management Group contains the API managing data as a whole (not record based), or on a large scale.

Typedef Documentation

typedef int(* mdbm_clean_func)(MDBM *, const datum *, const datum *, struct mdbm_clean_data *, int *quit)

Function Documentation

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.

Parameters
[in,out]dbDatabase 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).

Parameters
[in,out]dbDatabase handle
void mdbm_prune ( MDBM db,
int(*)(MDBM *, datum, datum, void *)  prune,
void *  param 
)

Prunes an MDBM.

Iterates through the database calling the supplied prune function for each item in the database. Prune function:

int (*prune)(MDBM *, datum, datum, void *)

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.

Parameters
[in,out]dbDatabase handle
[in]prunePrune function
[in]paramUser 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.

Parameters
[in,out]dbDatabase 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:

typedef int (*mdbm_clean_func)(MDBM *, const datum*, const datum*,
struct mdbm_clean_data *,
int* quit);

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:

mdbm_set_cleanfunc(dbh, mycleanerfunction, mycleanerdata);
mdbm_limit_size(dbh, limitNumPages, 0); // notice no shake function is specified

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.

Parameters
[in,out]dbDatabase handle
[in]funcUser-provided function to determine re-use of an entry
[in]dataOpaque data passed to the user-provided function func
Returns
Set clean function status
Return values
-1Error, and errno is set
0Success
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

Parameters
[in,out]dbDatabase handle
[in]pagenumPage number to start cleaning. If < 0, then clean all pages in the database.
[in]flagsIgnored
Returns
Clean status or count
Return values
-1Error
Numberof cleaned entries