Struct extindex::builder::Builder

source ·
pub struct Builder<K, V, KS = u16, VS = u16>
where K: Ord + Serializable, V: Serializable, KS: DataSize, VS: DataSize,
{ /* private fields */ }
Expand description

Index builder that creates a file index from any iterator. If the given iterator is already sorted, the build_from_sorted method can be used, while build can take any iterator. The build method will sort the iterator first using external sorting with the extsort crate.

As the index is being built, checkpoints/nodes are added to the file. These checkpoints/nodes are similar to the ones in a skip list, except that they point to previous checkpoints instead of pointing to next checkpoints.

Implementations§

source§

impl<K, V> Builder<K, V, u16, u16>
where K: Ord + Serializable, V: Serializable,

source

pub fn new<P: Into<PathBuf>>(path: P) -> Builder<K, V, u16, u16>

Creates an index builder that will write to the given file path with default key and value size of u16.

source§

impl<K, V, KS, VS> Builder<K, V, KS, VS>
where K: Ord + Serializable, V: Serializable, KS: DataSize, VS: DataSize,

source

pub fn new_sized<P: Into<PathBuf>>(path: P) -> Builder<K, V, KS, VS>

Creates an index builder that will write to the given file path with the given key and value size.

source

pub fn with_log_base(self, log_base: f64) -> Self

Indicates the approximate number of items we want per last-level checkpoint.

A higher value means that once a checkpoint is found in which we know the item is after, we may need to iterate through up to log_base items. A lower value will prevent creating too many levels when the index gets bigger, but will require scanning through more entries to find the right one.

Default value: 5.0

source

pub fn with_extsort_segment_size(self, max_size: usize) -> Self

When using the build method with a non-sorted iterator, this value is passed to the extsort crate to define the number of items that will be buffered in memory before being flushed to disk.

This number represents the actual count of entries, not the sum of their sizes.

source

pub fn build<I>(self, iter: I) -> Result<(), BuilderError>
where I: Iterator<Item = Entry<K, V>>,

Builds the index using a non-sorted iterator.

source

pub fn build_from_sorted<I>( self, iter: I, nb_items: u64 ) -> Result<(), BuilderError>
where I: Iterator<Item = Entry<K, V>>,

source

pub fn build_from_sorted_fallible<I>( self, iter: I, nb_items: u64 ) -> Result<(), BuilderError>
where I: Iterator<Item = Result<Entry<K, V>>>,

Builds the index using a sorted iterator.

Auto Trait Implementations§

§

impl<K, V, KS, VS> Freeze for Builder<K, V, KS, VS>

§

impl<K, V, KS, VS> RefUnwindSafe for Builder<K, V, KS, VS>

§

impl<K, V, KS, VS> Send for Builder<K, V, KS, VS>

§

impl<K, V, KS, VS> Sync for Builder<K, V, KS, VS>
where K: Sync, V: Sync,

§

impl<K, V, KS, VS> Unpin for Builder<K, V, KS, VS>
where K: Unpin, KS: Unpin, V: Unpin, VS: Unpin,

§

impl<K, V, KS, VS> UnwindSafe for Builder<K, V, KS, VS>
where K: UnwindSafe, KS: UnwindSafe, V: UnwindSafe, VS: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.