Struct pearl::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

Is used to initialize a Storage.

Required params:

Example

use pearl::{Builder, Storage, ArrayKey};

let storage: Storage<ArrayKey<8>> = Builder::new()
        .blob_file_name_prefix("benchmark")
        .max_blob_size(10_000_000)
        .max_data_in_blob(1_000)
        .work_dir(std::env::temp_dir().join("pearl_benchmark"))
        .build()
        .unwrap();

Implementations§

source§

impl Builder

source

pub fn new() -> Self

Create new uninitialized Builder

source

pub fn build<K>(self) -> Result<Storage<K>>where for<'a> K: Key<'a> + 'static,

Creates Storage based on given configuration, returns error if not all params are set.

Errors

Return error if some of the required params is missed or wrong

source

pub fn work_dir<S: Into<PathBuf>>(self, work_dir: S) -> Self

Sets working directory. If path doesn’t exists, Storage will try to create it at initialization stage.

source

pub fn corrupted_dir_name(self, name: impl Into<String>) -> Self

Sets directory name for corrupted files. If path doesn’t exists, Storage will try to create it at initialization stage.

source

pub fn max_blob_size(self, max_blob_size: u64) -> Self

Sets blob file size approximate limit. When the file size exceeds it, active blob update is activated. Must be greater than zero

source

pub fn max_data_in_blob(self, max_data_in_blob: u64) -> Self

Limits max number of records in a single blob. Must be greater than zero

source

pub fn blob_file_name_prefix<U: Into<String>>( self, blob_file_name_prefix: U ) -> Self

Sets blob file name prefix, e.g. if prefix set to hellopearl, files will be named as hellopearl.[N].blob. Where N - index number of file If the prefix is empty, param won’t be set.

source

pub fn allow_duplicates(self) -> Self

Disables check existence of the record on write. Writing becomes faster because there is no additional disk access for searching for duplicates.

source

pub fn ignore_corrupted(self) -> Self

Ignores blobs with corrupted header for index file and continues work with normal ones (also leaves error logs for bad blobs). It’s worth noticing that index file maybe corrupted likely in case of irregular stop of the storage: either the disk disconnected or server crashed. In these cases blob file is likely either corrupted, so there is no a try to restore indices from blob file.

source

pub fn set_filter_config(self, config: BloomConfig) -> Self

Sets custom bloom filter config, if not set, use default values.

source

pub fn set_validate_data_during_index_regen(self, value: bool) -> Self

Enables or disables data checksum validation during index regeneration

source

pub fn create_work_dir(self, create: bool) -> Self

[Optional] Sets whether to create work directory if its missing on storage initialization. Default value is true

source

pub fn set_io_driver(self, iodriver: IoDriver) -> Self

Set io driver to be used during file io operations. If the driver is not set, then sync is used as the default

source

pub fn set_dump_sem(self, dump_sem: Arc<Semaphore>) -> Self

Sets semaphore for index dumping on blob change. Parallel saving of indexes onto the disk will be limited by this semaphore. This can prevent disk overusage in systems with multiple pearls.

source

pub fn set_bloom_filter_group_size(self, size: usize) -> Self

Sets bloom filter group size

source

pub fn set_deferred_index_dump_times(self, min: Duration, max: Duration) -> Self

Set min and max waiting time for deferred index dump

source

pub fn set_max_dirty_bytes_before_sync(self, bytes: u64) -> Self

Set max dirty bytes before filesync will be performed in background

Trait Implementations§

source§

impl Debug for Builder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Builder

source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.