Classes | Macros | Typedefs | Functions
Record Iteration Group

The Record Iteration Group contains the API for iterating over records in an MDBM. More...

Classes

struct  mdbm_page_info
 
struct  mdbm_entry_info
 
struct  mdbm_iterate_info
 

Macros

#define MDBM_ENTRY_DELETED   0x1
 
#define MDBM_ENTRY_LARGE_OBJECT   0x2
 
#define MDBM_ITERATE_ENTRIES   0x01
 Iterate over page entries. More...
 
#define MDBM_ITERATE_NOLOCK   0x80
 Iterate without locking. More...
 

Typedefs

typedef struct mdbm_page_info mdbm_page_info_t
 
typedef struct mdbm_entry_info mdbm_entry_info_t
 
typedef struct mdbm_iterate_info mdbm_iterate_info_t
 
typedef int(* mdbm_iterate_func_t )(void *user, const mdbm_iterate_info_t *info, const kvpair *kv)
 

Functions

kvpair mdbm_first (MDBM *db)
 Returns the first key/value pair from the database. More...
 
kvpair mdbm_first_r (MDBM *db, MDBM_ITER *iter)
 Fetches the first record in an MDBM. More...
 
kvpair mdbm_next (MDBM *db)
 Returns the next key/value pair from the database. More...
 
kvpair mdbm_next_r (MDBM *db, MDBM_ITER *iter)
 Fetches the next record in an MDBM. More...
 
datum mdbm_firstkey (MDBM *db)
 Returns the first key from the database. More...
 
datum mdbm_firstkey_r (MDBM *db, MDBM_ITER *iter)
 Fetches the first key in an MDBM. More...
 
datum mdbm_nextkey (MDBM *db)
 Returns the next key pair from the database. More...
 
datum mdbm_nextkey_r (MDBM *db, MDBM_ITER *iter)
 Fetches the next key in an MDBM. More...
 
int mdbm_iterate (MDBM *db, int pagenum, mdbm_iterate_func_t func, int flags, void *user)
 Iterates through all keys starting on page pagenum and continuing through the rest of the database. More...
 

Detailed Description

The Record Iteration Group contains the API for iterating over records in an MDBM.

Macro Definition Documentation

#define MDBM_ENTRY_DELETED   0x1
#define MDBM_ENTRY_LARGE_OBJECT   0x2
#define MDBM_ITERATE_ENTRIES   0x01

Iterate over page entries.

#define MDBM_ITERATE_NOLOCK   0x80

Iterate without locking.

Typedef Documentation

typedef int(* mdbm_iterate_func_t)(void *user, const mdbm_iterate_info_t *info, const kvpair *kv)

Function Documentation

kvpair mdbm_first ( MDBM db)

Returns the first key/value pair from the database.

The order that records are returned is not specified.

Todo:
Is it safe to update/delete an entry returned via mdbm_first?
Parameters
[in,out]dbDatabase handle
Returns
kvpair. If database is empty, return a null kvpair (key and value dsize==0, dptr==NULL).
kvpair mdbm_first_r ( MDBM db,
MDBM_ITER iter 
)

Fetches the first record in an MDBM.

Initializes the iterator, and returns the first key/value pair from the db. Subsequent calls to mdbm_next_r or mdbm_nextkey_r with this iterator will loop through the entire db.

Parameters
[in,out]dbDatabase handle
[in,out]iterMDBM iterator
Returns
kvpair. If database is empty, return a null kvpair (key and value dsize==0, dptr==NULL).
kvpair mdbm_next ( MDBM db)

Returns the next key/value pair from the database.

The order that records are returned is not specified.

Todo:
Is it safe to update/delete an entry returned via mdbm_next?
Parameters
[in,out]dbDatabase handle
Returns
kvpair. If no more records exist, return a null kvpair (key and value dsize==0, dptr==NULL).
kvpair mdbm_next_r ( MDBM db,
MDBM_ITER iter 
)

Fetches the next record in an MDBM.

Returns the next key/value pair from the db, based on the iterator.

Parameters
[in,out]dbDatabase handle
[in,out]iterMDBM iterator
Returns
kvpair. If no more records exist, return a null kvpair (key and value dsize==0, dptr==NULL).
datum mdbm_firstkey ( MDBM db)

Returns the first key from the database.

The order that records are returned is not specified.

Parameters
[in,out]dbDatabase handle
Returns
datum. If the database is empty, return a null datum (dsize==0, dptr==NULL).
datum mdbm_firstkey_r ( MDBM db,
MDBM_ITER iter 
)

Fetches the first key in an MDBM.

Initializes the iterator, and returns the first key from the db. Subsequent calls to mdbm_next_r or mdbm_nextkey_r with this iterator will loop through the entire db.

Parameters
[in,out]dbDatabase handle
[in,out]iterMDBM iterator
Returns
datum. If the database is empty, return a null datum (dsize==0, dptr==NULL).
datum mdbm_nextkey ( MDBM db)

Returns the next key pair from the database.

The order that records are returned is not specified.

Parameters
[in,out]dbDatabase handle
Returns
datum. If the database is empty, return a null datum (dsize==0, dptr==NULL).
datum mdbm_nextkey_r ( MDBM db,
MDBM_ITER iter 
)

Fetches the next key in an MDBM.

Returns the next key from the db. Subsequent calls to mdbm_next_r or mdbm_nextkey_r with this iterator will loop through the entire db.

Parameters
[in,out]dbDatabase handle
[in,out]iterMDBM iterator
Returns
datum. If there are no more records, return a null datum (dsize==0, dptr==NULL).
int mdbm_iterate ( MDBM db,
int  pagenum,
mdbm_iterate_func_t  func,
int  flags,
void *  user 
)

Iterates through all keys starting on page pagenum and continuing through the rest of the database.

If flags contains MDBM_ITERATE_ENTRIES, function func is invoked for each record. If flag does not have MDBM_ITERATE_ENTRIES set, then func is invoke once per page with kv set to NULL.

Parameters
[in,out]dbDatabase handle
[in]pagenumStarting page number
[in]funcFunction to invoke for each key
[in]flagsiteration control (below)
[in]userUser-supplied opaque pointer to pass to func
Returns
Iteration status
Return values
-1Error
0Success

Values for flags mask:

  • MDBM_ITERATE_NOLOCK - Do not lock when iterating
  • MDBM_ITERATE_ENTRIES - Invoke func for each record