Functions
Miscellaneous Group

The Miscellaneous Group contains the API for routines that don't clearly fit into any of the other module API groups. More...

Functions

int mdbm_get_errno (MDBM *db)
 Returns the value of internally saved errno. More...
 
int mdbm_get_hash_value (datum key, int hashFunctionCode, uint32_t *hashValue)
 Given a hash function code, get the hash value for the given key. More...
 
mdbm_ubig_t mdbm_get_page (MDBM *db, const datum *key)
 Gets the MDBM page number for a given key. More...
 
int mdbm_preload (MDBM *db)
 Preload mdbm: Read every 4k bytes to force all pages into memory. More...
 
int mdbm_lock_pages (MDBM *db)
 mdbm_lock_pages: Locks MDBM data pages into memory. More...
 
int mdbm_unlock_pages (MDBM *db)
 mdbm_unlock_pages: Releases MDBM data pages from always staying in memory More...
 

Detailed Description

The Miscellaneous Group contains the API for routines that don't clearly fit into any of the other module API groups.

Function Documentation

int mdbm_get_errno ( MDBM db)

Returns the value of internally saved errno.

Contains the value of errno that is set during some lock failures. Under other circumstances, mdbm_get_errno will not return the actual value of the errno variable.

Parameters
[in,out]dbDatabase handle
Returns
Saved errno value, or zero if OK
int mdbm_get_hash_value ( datum  key,
int  hashFunctionCode,
uint32_t *  hashValue 
)

Given a hash function code, get the hash value for the given key.

See mdbm_sethash for the list of valid hash function codes.

Parameters
[in]keyKey
[in]hashFunctionCodefor a valid hash function (below)
[out]hashValueis calculated according to the hashFunctionCode
Returns
Get Hash status
Return values
-1Error, and errno is set
0Success

Values for hashFunctionCode:

  • MDBM_HASH_CRC32 - Table based 32bit CRC
  • MDBM_HASH_EJB - From hsearch
  • MDBM_HASH_PHONG - Congruential hash
  • MDBM_HASH_OZ - From sdbm
  • MDBM_HASH_TOREK - From BerkeleyDB
  • MDBM_HASH_FNV - Fowler/Vo/Noll hash (DEFAULT)
  • MDBM_HASH_STL - STL string hash
  • MDBM_HASH_MD5 - MD5
  • MDBM_HASH_SHA_1 - SHA_1
  • MDBM_HASH_JENKINS - Jenkins string
  • MDBM_HASH_HSIEH - Hsieh SuperFast
mdbm_ubig_t mdbm_get_page ( MDBM db,
const datum key 
)

Gets the MDBM page number for a given key.

The key does not actually have to exist.

Parameters
[in,out]dbDatabase handle
[in]keyLookup key
Returns
Page number or error indicator
Return values
-1Error, and errno is set
Pagenumber where the parameter key would be stored.
int mdbm_preload ( MDBM db)

Preload mdbm: Read every 4k bytes to force all pages into memory.

Parameters
[in,out]dbDatabase handle
Returns
preload status
Return values
-1Error
0Success
int mdbm_lock_pages ( MDBM db)

mdbm_lock_pages: Locks MDBM data pages into memory.

When running MDBM as root, mdbm_lock_pages will expand the amount of RAM that can be locked to infinity using setrlimit(RLIMIT_MEMLOCK). When not running as root, mdbm_lock_pages will expand the amount of RAM that can be locked up to the maximum allowed (retrieved using getrlimit(MEMLOCK), and normally a very small amount), and if the MDBM is larger than the amount of RAM that can be locked, a warning will be logged but mdbm_lock_pages will return 0 for success.

Parameters
[in,out]dbDatabase handle
Returns
lock pages status
Return values
-1Error
0Success
int mdbm_unlock_pages ( MDBM db)

mdbm_unlock_pages: Releases MDBM data pages from always staying in memory

Parameters
[in,out]dbDatabase handle
Returns
unlock pages status
Return values
-1Error
0Success