Struct mtbl::Merger
[−]
[src]
pub struct Merger { pub merge_fn: Box<Box<MergeFn>>, // some fields omitted }
An MTBL reader that opens and reads from several MTBL files, merging their contents.
An MTBL can have only one value for a key, so when the inputs have a key
collision (more than one source contains the same key), it uses a
MergeFn
to combine them.
Fields
merge_fn: Box<Box<MergeFn>>
The function used to combine values for colliding keys.
Methods
impl Merger
[src]
fn merge_choose_last_value(_key: &[u8], _val0: &[u8], val1: &[u8]) -> Vec<u8>
A default MTBL merging function that chooses the last (second) value for the colliding key.
fn merge_choose_first_value(_key: &[u8], val0: &[u8], _val1: &[u8]) -> Vec<u8>
A simple MTBL merging function that chooses the first value for the colliding key.
fn new<F>(sources: Vec<Reader>, merge_fn: F) -> Merger where F: Fn(&[u8], &[u8], &[u8]) -> Vec<u8> + 'static
Create a merger from a collection of other sources. Note that you must provide a merge_fn to combine values for colliding keys.
fn add_source<T: 'static + Read>(self: &mut Self, source: T)
Add an additional source of data to be merged.
Trait Implementations
impl Read for Merger
[src]
fn raw_mtbl_source(&self) -> &*const mtbl_source
Get the internal mtbl_source pointer.
fn get<T>(&self, key: T) -> Option<Vec<u8>> where Self: Sized, T: AsRef<[u8]>
Get the value of a key, if it's present.
fn iter(&self) -> Iter
Get an iterator over all keys and values.
fn get_prefix<T>(&self, prefix: T) -> Iter where Self: Sized, T: AsRef<[u8]>
Get an iterator over all keys and values where the key starts with the given prefix.
fn get_range<T, U>(&self, key0: T, key1: U) -> Iter where Self: Sized, T: AsRef<[u8]>, U: AsRef<[u8]>
Get an iterator over all keys and values, where the keys are between key0 and key1 (inclusive). Read more
impl<'a> IntoIterator for &'a Merger
[src]
type Item = (Vec<u8>, Vec<u8>)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a>
Creates an iterator from a value. Read more
impl Drop for Merger
[src]
impl Send for Merger
[src]
Merger is thread-safe.
impl Sync for Merger
[src]
Merger is thread-safe.