Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mtbl_source(3) [debian man page]

MTBL_SOURCE(3)															    MTBL_SOURCE(3)

NAME
mtbl_source - obtain key-value entries from a data source SYNOPSIS
#include <mtbl.h> struct mtbl_iter * mtbl_source_iter(const struct mtbl_source *s); struct mtbl_iter * mtbl_source_get(const struct mtbl_source *s, const uint8_t *key, size_t len_key); struct mtbl_iter * mtbl_source_get_prefix( const struct mtbl_source *s, const uint8_t *prefix, size_t len_prefix); struct mtbl_iter * mtbl_source_get_range( const struct mtbl_source *s, const uint8_t *key0, size_t len_key0, const uint8_t *key1, size_t len_key1); mtbl_res mtbl_source_write(const struct mtbl_source *s, struct mtbl_writer *w); void mtbl_source_destroy(struct mtbl_source **s); DESCRIPTION
The mtbl_source iterface provides an abstraction for reading key-value entries from mtbl data sources. mtbl_source_iter() provides an iterator over all of the entries in the data source. mtbl_source_get() provides an exact match iterator which returns all entries whose key matches the key provided in the arguments key and len_key. mtbl_source_get_prefix() provides a prefix iterator which returns all entries whose keys start with prefix and are at least len_prefix bytes long. mtbl_source_get_range() provides a range iterator which returns all entries whose keys are between key0 and key1 inclusive. mtbl_source_write() is a convenience function for reading all of the entries from a source and writing them to an mtbl_writer object. It is equivalent to calling mtbl_writer_add() on all of the entries returned from mtbl_source_iter(). RETURN VALUE
mtbl_source_iter(), mtbl_source_get(), mtbl_source_get_prefix(), and mtbl_source_get_range() return mtbl_iter objects. mtbl_source_write() returns mtbl_res_success if all of the entries in the data source were successfully written to the mtbl_writer argument, and mtbl_res_failure otherwise. SEE ALSO
mtbl_iter(3) 05/29/2012 MTBL_SOURCE(3)

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