Struct mtbl::Sorter [] [src]

pub struct Sorter {
    pub options: SorterOptions,
    pub merge_fn: Box<Box<MergeFn>>,
    // some fields omitted
}

A tool to create an MTBL file out of keys in any order.

A Sorter will buffer entries in memory, periodically writing them to (sorted) temporary files. When everything has been added, the temporary files will be merged into a single MTBL file.

To create a Sorter with non-default options, see SorterOptions.

Example

let mut sorter = Sorter::create_from_path("/tmp/f.mtbl",
                                          |k, v0, v1| "collision".as_bytes().to_vec());
sorter.add("b", dat_b);
sorter.add("a", dat_a);
sorter.add("a", other_dat_a);
sorter.add_all((0..100).map(|i| (format!("key {}", i), format!("entry {}", i))));Run

Fields

The options used to create this sorter.

The function used to merge entries with colliding keys.

Methods

impl Sorter
[src]

Create a new Sorter.

Once sorting is done, the resulting sequence of entries will be written to the supplied Writer. Note that a MergeFn must be supplied to combine values for entries with colliding keys.

Create a new Sorter.

Once sorting is done, the resulting sequence of entries will be written to the supplied path. Note that a MergeFn must be supplied to combine values for entries with colliding keys.

Create a new Sorter.

Once sorting is done, the resulting sequence of entries will be written to the supplied path. Note that a MergeFn must be supplied to combine values for entries with colliding keys.

Add all elements from an iterator.

This will result in an Error only if the output Writer receives items out of order, which can only happen if the output Writer had already had items added, not from the Sorter.

Trait Implementations

impl Write for Sorter
[src]

Add a key-value pair to be written to the MTBL file.

impl Drop for Sorter
[src]

A method called when the value goes out of scope. Read more