Functions used in nmdb utilities

These functions are used almost exclusively by nmdb utilities, although they may be used by external applications. More...

Functions

ssize_t nmdb_firstkey (nmdb_t *db, unsigned char *key, size_t ksize)
 Get the first key.
ssize_t nmdb_nextkey (nmdb_t *db, const unsigned char *key, size_t ksize, unsigned char *newkey, size_t nksize)
 Get the key that follows the one given.
int nmdb_stats (nmdb_t *db, unsigned char *buf, size_t bsize, unsigned int *nservers, unsigned int *nstats)
 Request servers' statistics.

Detailed Description

These functions are used almost exclusively by nmdb utilities, although they may be used by external applications.

They often require some knowledge about nmdb's inner workings so they should be used with care.


Function Documentation

ssize_t nmdb_firstkey ( nmdb_t db,
unsigned char *  key,
size_t  ksize 
)

Get the first key.

Returns the first key in the database, which can then be used to get the following one with nmdb_nextkey(). Together, they can be used to iterate over all the keys of a *single server*. It has some caveats:

  • It will fail if db has more than one server.
  • If the database is being modified during iteration, the walk can result in skipping nodes or walking the same one twice.
  • There is absolutely no guarantee about the order of the keys.
  • The order is not stable and must not be relied upon.

This is almost exclusively used for replication utilities.

Parameters:
db connection instance.
[out] key the first key.
ksize the key size.
Returns:
-2 on error, -1 if the database is empty, or the key size on success.
ssize_t nmdb_nextkey ( nmdb_t db,
const unsigned char *  key,
size_t  ksize,
unsigned char *  newkey,
size_t  nksize 
)

Get the key that follows the one given.

Together with nmdb_firstkey(), they can be used to iterate This function, along with nmdb_firstkey(), are used to iterate over all the keys of a *single server*. It has some caveats:

  • It will fail if db has more than one server.
  • If the database is being modified during iteration, the walk can result in skipping nodes or walking the same one twice.
  • There is absolutely no guarantee about the order of the keys.
  • The order is not stable and must not be relied upon.

This is almost exclusively used for replication utilities.

Parameters:
db connection instance.
key the current key.
ksize the current key size.
[out] newkey the key that follows the current one.
nksize the newkey size.
Returns:
-2 on error, -1 if the database is empty, or the new key size on success.
int nmdb_stats ( nmdb_t db,
unsigned char *  buf,
size_t  bsize,
unsigned int *  nservers,
unsigned int *  nstats 
)

Request servers' statistics.

This API is used by nmdb-stats, and likely to change in the future. Do not rely on it.

Parameters:
db connection instance.
[out] buf buffer used to store the results.
bsize size of the buffer.
[out] nservers number of servers queried.
[out] nstats number of stats per server.
Returns:
1 if success, -1 if there was an error in the server, -2 if there was a network error, -3 if the buffer was too small, -4 if the server replies were of different size (indicates different server versions, not supported at the time)
Generated on Sun Oct 10 19:50:36 2010 for libnmdb (public) by  doxygen 1.6.3