MTBL_SOURCE(3)

πŸ’– MTBL_SOURCE πŸ’–

ok so bestie, welcome to mtbl_source(3) β€” this is the manual page for getting key-value entries out of a data source. it's giving interface, it's giving abstraction, and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

mtbl_source β€” obtain key-value entries from a data source. yes that's the whole job. slay. πŸ’…


🌸 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 πŸ¦‹

okay so the mtbl_source interface is literally the vibe layer that lets you read key-value entries from mtbl data sources. it's the abstraction, bestie. it's the whole mood. ✨

  • mtbl_source_iter() β€” hands you an iterator over all the entries in the data source. every single one. no skips. πŸ‘‘
  • mtbl_source_get() β€” this one's your exact match iterator. it returns all the entries whose key matches the key you passed in via the key and len_key arguments. it said "we're only doing exact matches today" and honestly, periodt. 🎯
  • mtbl_source_get_prefix() β€” the prefix iterator. it returns all entries whose keys start with prefix and are at least len_prefix bytes long. both conditions, no exceptions, she's thorough. 🧚
  • mtbl_source_get_range() β€” the range iterator. returns all entries whose keys are between key0 and key1 inclusive. inclusive!! both ends are invited to the party. 🌈
  • mtbl_source_write() β€” the convenience function, the bestie who does the errand for you. it reads all the entries from a source and writes them to an mtbl_writer object. and it's equivalent to calling mtbl_writer_add() on all of the entries returned from mtbl_source_iter(). same thing, just with less typing. lowkey iconic. πŸ’œ

⭐ RETURN VALUE ⭐

mtbl_source_iter(), mtbl_source_get(), mtbl_source_get_prefix(), and mtbl_source_get_range() all return mtbl_iter objects. go get your iterator, bestie. 🫢

mtbl_source_write() returns mtbl_res_success if all of the entries in the data source were successfully written to the mtbl_writer argument. if not? it returns mtbl_res_failure. so like, check it. don't just assume. 😭


πŸ’€ SEE ALSO πŸ’€


and that's the page, fr fr. MTBL_SOURCE(3) β€” part of the mtbl crew, dated 11/21/2016. not me getting emotional over a manpage. anyways, go forth and read your key-value entries, my main character. mwah. πŸ’–βœ¨πŸŽ€