The Configuration Group contains the API the gets/sets the underlying configuration of an MDBM.
More...
|
void | mdbm_stat_header (MDBM *db) |
| Prints to stdout various pieces of information, specifically: page size, page count, hash function, running with or without locking. More...
|
|
int | mdbm_get_hash (MDBM *db) |
| Gets the MDBM's hash function identifier. More...
|
|
int | mdbm_sethash (MDBM *db, int hashid) |
| Sets the hashing function for a given MDBM. More...
|
|
int | mdbm_setspillsize (MDBM *db, int size) |
| Sets the size of item data value which will be put on the large-object heap rather than inline. More...
|
|
int | mdbm_get_alignment (MDBM *db) |
| Gets the MDBM's record byte-alignment. More...
|
|
int | mdbm_set_alignment (MDBM *db, int align) |
| Sets a database's byte-size alignment for keys and values within a page. More...
|
|
uint64_t | mdbm_get_limit_size (MDBM *db) |
| Gets the MDBM's size limit. More...
|
|
int | mdbm_limit_size_v3 (MDBM *db, mdbm_ubig_t max_page, mdbm_shake_func_v3 shake, void *user) |
| Limits the size of a V3 database to a maximum number of pages. More...
|
|
int | mdbm_limit_dir_size (MDBM *db, int pages) |
| Limits the internal page directory size to a number of pages. More...
|
|
uint32_t | mdbm_get_version (MDBM *db) |
| Gets the on-disk format version number of an MDBM. More...
|
|
uint64_t | mdbm_get_size (MDBM *db) |
| Gets the current MDBM's size. More...
|
|
int | mdbm_get_page_size (MDBM *db) |
| Get the MDBM's page size. More...
|
|
int | mdbm_get_magic_number (MDBM *db, uint32_t *magic) |
| Gets the magic number from an MDBM. More...
|
|
int | mdbm_set_window_size (MDBM *db, size_t wsize) |
| Sets the window size for an MDBM. More...
|
|
The Configuration Group contains the API the gets/sets the underlying configuration of an MDBM.
Most of the commands that set the configuration must be done at MDBM-creation time.
#define MDBM_ALIGN_8_BITS 0x0 |
#define MDBM_ALIGN_16_BITS 0x1 |
#define MDBM_ALIGN_32_BITS 0x3 |
#define MDBM_ALIGN_64_BITS 0x7 |
#define _MDBM_MAGIC 0x01023962 |
#define _MDBM_MAGIC_NEW 0x01023963 |
V2 file identifier with large objects.
#define _MDBM_MAGIC_NEW2 0x01023964 |
void mdbm_stat_header |
( |
MDBM * |
db | ) |
|
Prints to stdout various pieces of information, specifically: page size, page count, hash function, running with or without locking.
NOTE: There is only a V2 implementation. V3 not currently supported.
- Parameters
-
[in,out] | db | Database handle |
int mdbm_get_hash |
( |
MDBM * |
db | ) |
|
Gets the MDBM's hash function identifier.
- Parameters
-
[in,out] | db | Database handle |
- Returns
- Hash function identifier
- Return values
-
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 |
int mdbm_sethash |
( |
MDBM * |
db, |
|
|
int |
hashid |
|
) |
| |
Sets the hashing function for a given MDBM.
The hash function must be set before storing anything to the db (this is not enforced, but entries stored before the hash change will become inaccessible if the hash function is changed).
NOTE: setting the hash must be be done at creation time, or when there is no data in an MDBM. Changing the hash function when there is existing data will result in not being able access that data in the future.
- Parameters
-
[in,out] | db | Database handle |
[in] | hashid | Numeric identifier for new hash function. |
- Returns
- Set hash status
- Return values
-
0 | Error, invalid hashid |
1 | Success |
Available Hash IDs are:
- 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
int mdbm_setspillsize |
( |
MDBM * |
db, |
|
|
int |
size |
|
) |
| |
Sets the size of item data value which will be put on the large-object heap rather than inline.
The spill size can be changed at any point after the db has been created. However, it's a recommended practice to set the spill size at creation time.
NOTE: The database has to be opened with the MDBM_LARGE_OBJECTS flag for spillsize to take effect.
- Parameters
-
[in,out] | db | Database handle |
[in] | size | New large-object threshold size |
- Returns
- Set spill size status
- Return values
-
-1 | Error, and errno is set |
0 | Success |
int mdbm_get_alignment |
( |
MDBM * |
db | ) |
|
Gets the MDBM's record byte-alignment.
- Parameters
-
[in,out] | db | Database handle |
- Returns
- Alignment mask.
- Return values
-
0 | - 8-bit alignment |
1 | - 16-bit alignment |
3 | - 32-bit alignment |
7 | - 64-bit alignment |
int mdbm_set_alignment |
( |
MDBM * |
db, |
|
|
int |
align |
|
) |
| |
Sets a database's byte-size alignment for keys and values within a page.
This feature is useful for hardware/memory architectures that incur a performance penalty for unaligned accesses. Later (2006+) i386 and x86 architectures do not need special byte alignment, and should use the default of 8-bit alignment.
NOTE: setting the byte alignment must be be done at MDBM-creation time, or when there is no data in an MDBM. Changing the byte alignment when there is existing data will result in in undefined behavior and probably a crash.
- Parameters
-
[in,out] | db | Database handle |
[in] | align | Alignment mask |
- Returns
- Alignment status
- Return values
-
-1 | Error, and errno is set |
0 | Success |
uint64_t mdbm_get_limit_size |
( |
MDBM * |
db | ) |
|
Gets the MDBM's size limit.
Returns the limit set for the size of the db using the mdbm_limit_size_v3 routine.
- Parameters
-
[in,out] | db | Database handle |
- Returns
- database size limit
- Return values
-
0 | No limit is set |
Total | number of bytes for maximum database size, including header and directory |
Limits the size of a V3 database to a maximum number of pages.
This function causes the MDBM to shake whenever a full page would cause the db to grow beyond the specified max number of pages. The limit size for an MDBM may be increased over time, but is may never be decreased.
- Parameters
-
[in,out] | db | Database handle |
[in] | max_page | Maximum number of data pages |
[in] | shake | Shake function. |
[in] | user | Pointer to user data that will be passed to the shake function |
- Returns
- Limit size status
- Return values
-
-1 | Error, and errno is set |
0 | Success |
int mdbm_limit_dir_size |
( |
MDBM * |
db, |
|
|
int |
pages |
|
) |
| |
Limits the internal page directory size to a number of pages.
The number of pages is rounded up to a power of 2.
- Parameters
-
[in,out] | db | Database handle |
[in] | pages | Number of data pages |
- Returns
- Limit dir size status
- Return values
-
-1 | Error, and errno is set |
0 | Success |
uint32_t mdbm_get_version |
( |
MDBM * |
db | ) |
|
Gets the on-disk format version number of an MDBM.
- Parameters
-
[in,out] | db | Database handle |
- Returns
- On-disk file format version number
- Return values
-
uint64_t mdbm_get_size |
( |
MDBM * |
db | ) |
|
Gets the current MDBM's size.
- Parameters
-
[in,out] | db | Database handle |
- Returns
- Size of database in bytes.
int mdbm_get_page_size |
( |
MDBM * |
db | ) |
|
Get the MDBM's page size.
- Parameters
-
[in,out] | db | Database handle |
- Returns
- Number of bytes in a database page
int mdbm_get_magic_number |
( |
MDBM * |
db, |
|
|
uint32_t * |
magic |
|
) |
| |
Gets the magic number from an MDBM.
- Parameters
-
[in,out] | db | Database handle |
[out] | magic | MDBM magic number (internal version identifier) |
- Returns
- Magic number status
- Return values
-
-3 | Cannot read all of the magic number |
-2 | File is truncated (empty) |
-1 | Cannot read file |
0 | Magic number returned in magic |
int mdbm_set_window_size |
( |
MDBM * |
db, |
|
|
size_t |
wsize |
|
) |
| |
Sets the window size for an MDBM.
Windowing is typically used for a very large data store where only part of it will be mapped to memory. In windowing mode, pages are accessed through a "window" to the database.
In order to use windowing mode, the page size must be a multiple of the system page size (4K on most systems). The system page size can be retrieved by calling getpagesize or sysconf(_SC_PAGESIZE).
NOTE: It is best if the minimum window size chosen is: (4*max-large-object-size + n*8*pagesize)
NOTE: API exists in MDBM V3 only, and using mdbm_set_window_size requires opening MDBM with MDBM_O_RDWR.
- Parameters
-
[in,out] | db | Database handle for windowed access, typically a backing store database |
[in] | wsize | Window size which must be at least 4X the page size used for the database. 0 means to remove windowing |
- Returns
- Set window status
- Return values
-
-1 | Error, and errno is set |
0 | Success |