pub struct Builder<K, V, KS = u16, VS = u16>{ /* 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, KS, VS> Builder<K, V, KS, VS>
impl<K, V, KS, VS> Builder<K, V, KS, VS>
sourcepub fn new_sized<P: Into<PathBuf>>(path: P) -> Builder<K, V, KS, VS>
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.
sourcepub fn with_log_base(self, log_base: f64) -> Self
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
sourcepub fn with_extsort_segment_size(self, max_size: usize) -> Self
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.
sourcepub fn build<I>(self, iter: I) -> Result<(), BuilderError>
pub fn build<I>(self, iter: I) -> Result<(), BuilderError>
Builds the index using a non-sorted iterator.
pub fn build_from_sorted<I>( self, iter: I, nb_items: u64 ) -> Result<(), BuilderError>
sourcepub fn build_from_sorted_fallible<I>(
self,
iter: I,
nb_items: u64
) -> Result<(), BuilderError>
pub fn build_from_sorted_fallible<I>( self, iter: I, nb_items: u64 ) -> Result<(), BuilderError>
Builds the index using a sorted iterator.