Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cdbw_close(3) [netbsd man page]

CDBW(3) 						   BSD Library Functions Manual 						   CDBW(3)

NAME
cdbw_open, cdbw_put, cdbw_put_data, cdbw_put_key, cdbw_stable_seeder, cdbw_output, cdbw_close -- create constant databases SYNOPSIS
#include <archive_entry.h> struct cdbw * cdbw_open(void); int cdbw_put(struct cdbw *cdbw, const void *key, size_t keylen, const void *data, size_t datalen); int cdbw_put_data(struct cdbw *cdbw, const void *data, size_t datalen, uint32_t *index); int cdbw_put_key(struct cdbw *cdbw, const void *key, size_t keylen, uint32_t index); uint32_t cdbw_stable_seeder(void); int cdbw_output(struct cdbw *cdbw, int output, const char descr[16], uint32_t (*seedgen)(void)); void cdbw_close(struct cdbw *cdbw); DESCRIPTION
The cdbw functions are used to create a constant databases for use with cdbr(3). Details about the file format, including overhead and limi- tations, can be found in cdb(5). cdbw_open() prepares a new cdb writer. The function returns a handle to pass to the other functions. cdbw_close() frees all resources associated with the handle. cdbw_put() adds the given (key,value) pair after checking for a duplicate key. cdbw_put_data() adds the given value to the writer without adding a key reference. The returned index can be used in subsequent calls to cdbw_put_key() to add one or more keys pointing to this value. cdbw_put_key() checks for duplicate keys and valid index arguments. On success it adds the given key. cdbw_output() computes the database file and writes it to the given descriptor. The function returns an error if the file cannot be written correctly. The descr() parameter provides a human readable description of the database content. The seedgen() parameter can be used to override the default PRNG. The bitwise layout of the output depends on the chosen seed. The function should return a different value for each invocation. The cdbw_stable_seeder() can be used to create reproducible output. It may be slower than the default. SEE ALSO
cdbr(3), cdb(5) HISTORY
Support for the cdb format first appeared in NetBSD 6.0. AUTHORS
The cdbr and cdbw functions have been written by Joerg Sonnenberger <joerg@NetBSD.org>. BSD
June 3, 2012 BSD

Check Out this Related Man Page

MTBL_WRITER(3)															    MTBL_WRITER(3)

NAME
mtbl_writer - create an MTBL file SYNOPSIS
#include <mtbl.h> Writer objects: struct mtbl_writer * mtbl_writer_init(const char *fname, const struct mtbl_writer_options *wopt); struct mtbl_writer * mtbl_writer_init_fd(int fd, const struct mtbl_writer_options *wopt); void mtbl_writer_destroy(struct mtbl_writer **w); mtbl_res mtbl_writer_add(struct mtbl_writer *w, const uint8_t *key, size_t len_key, const uint8_t *val, size_t len_val); Writer options: struct mtbl_writer_options * mtbl_writer_options_init(void); void mtbl_writer_options_destroy(struct mtbl_writer_options **wopt); void mtbl_writer_options_set_compression( struct mtbl_writer_options *wopt, mtbl_compression_type compression_type); void mtbl_writer_options_set_block_size( struct mtbl_writer_options *wopt, size_t block_size); void mtbl_writer_options_set_block_restart_interval( struct mtbl_writer_options *wopt, size_t block_restart_interval); DESCRIPTION
MTBL files are written to disk by creating an mtbl_writer object, calling mtbl_writer_add() for each key-value entry, and then calling mtbl_writer_destroy(). mtbl_writer_add() copies key-value pairs from the caller into the mtbl_writer object. Keys are specified as a pointer to a buffer, key, and the length of that buffer, len_key. Values are specified as a pointer to a buffer, val, and the length of that buffer, len_val. Keys must be in sorted, lexicographical byte order. The same key may not be added to an mtbl_writer more than once. If the input entries are not sorted or may contain duplicate keys, then the mtbl_sorter(3) interface should be used instead. mtbl_writer objects may be created by calling mtbl_writer_init() with an fname argument specifying a filename to be created. The filename must not already exist on the filesystem. Or, mtbl_writer_init_fd() may be called with an fd argument specifying an open, writable file descriptor. No data may have been written to the file descriptor. If the wopt parameter to mtbl_writer_init() or mtbl_writer_init_fd() is non-NULL, the parameters specified in the mtbl_writer_options object will be configured into the mtbl_writer object. Writer options compression Specifies the compression algorithm to use on data blocks. Possible values are MTBL_COMPRESSION_NONE, MTBL_COMPRESSION_SNAPPY, or MTBL_COMPRESSION_ZLIB (the default). block_size The maximum size of uncompressed data blocks, specified in bytes. The default is 8 kilobytes. block_restart_interval How frequently to restart intra-block key prefix compression. The default is every 16 keys. RETURN VALUE
mtbl_writer_init() and mtbl_writer_init_fd() return NULL on failure, and non-NULL on success. mtbl_writer_add() returns mtbl_res_success if the key-value entry was successfully copied into the mtbl_writer object, and mtbl_res_failure if not, for instance if there has been a key-ordering violation. 05/29/2012 MTBL_WRITER(3)
Man Page