Config

Struct Config 

Source
pub struct Config {
Show 13 fields pub tree_type: TreeType, pub level_count: u8, pub data_block_compression_policy: CompressionPolicy, pub index_block_compression_policy: CompressionPolicy, pub data_block_restart_interval_policy: RestartIntervalPolicy, pub index_block_restart_interval_policy: RestartIntervalPolicy, pub data_block_size_policy: BlockSizePolicy, pub index_block_size_policy: BlockSizePolicy, pub index_block_pinning_policy: PinningPolicy, pub filter_block_pinning_policy: PinningPolicy, pub data_block_hash_ratio_policy: HashRatioPolicy, pub filter_policy: FilterPolicy, pub blob_compression: CompressionType, /* private fields */
}
Expand description

Tree configuration builder

Fields§

§tree_type: TreeType

Tree type (unused)

§level_count: u8

Number of levels of the LSM tree (depth of tree)

Once set, the level count is fixed (in the “manifest” file)

§data_block_compression_policy: CompressionPolicy

What type of compression is used for data blocks

§index_block_compression_policy: CompressionPolicy

What type of compression is used for index blocks

§data_block_restart_interval_policy: RestartIntervalPolicy

Restart interval inside data blocks

§index_block_restart_interval_policy: RestartIntervalPolicy

Restart interval inside index blocks

§data_block_size_policy: BlockSizePolicy

Block size of data blocks

§index_block_size_policy: BlockSizePolicy

Block size of index blocks

§index_block_pinning_policy: PinningPolicy

Whether to pin index blocks

§filter_block_pinning_policy: PinningPolicy

Whether to pin filter blocks

§data_block_hash_ratio_policy: HashRatioPolicy

Data block hash ratio

§filter_policy: FilterPolicy

Filter construction policy

§blob_compression: CompressionType

What type of compression is used for blobs

Implementations§

Source§

impl Config

Source

pub fn new<P: AsRef<Path>>(path: P) -> Self

Initializes a new config

Source

pub fn use_cache(self, cache: Arc<Cache>) -> Self

Sets the global cache.

You can create a global Cache and share it between multiple trees to cap global cache memory usage.

Defaults to a cache with 8 MiB of capacity per tree.

Source

pub fn expect_point_read_hits(self, b: bool) -> Self

If true, the last level will not build filters, reducing the filter size of a database by ~90% typically.

Enable this only if you know that point reads generally are expected to find a key-value pair.

Source

pub fn filter_block_pinning_policy(self, policy: PinningPolicy) -> Self

Sets the pinning policy for filter blocks.

Source

pub fn index_block_pinning_policy(self, policy: PinningPolicy) -> Self

Sets the pinning policy for index blocks.

Source

pub fn data_block_restart_interval_policy( self, policy: RestartIntervalPolicy, ) -> Self

Sets the restart interval inside data blocks.

A higher restart interval saves space while increasing lookup times inside data blocks.

Default = 16

Source

pub fn index_block_restart_interval_policy( self, policy: RestartIntervalPolicy, ) -> Self

Sets the restart interval inside index blocks.

A higher restart interval saves space while increasing lookup times inside index blocks.

Default = 1

Source

pub fn filter_policy(self, policy: FilterPolicy) -> Self

Sets the filter construction policy.

Source

pub fn data_block_compression_policy(self, policy: CompressionPolicy) -> Self

Sets the compression method for data blocks.

Source

pub fn index_block_compression_policy(self, policy: CompressionPolicy) -> Self

Sets the compression method for index blocks.

Source

pub fn blob_compression(self, compression: CompressionType) -> Self

Sets the blob compression method.

Source

pub fn level_count(self, n: u8) -> Self

Sets the number of levels of the LSM tree (depth of tree).

Defaults to 7, like LevelDB and RocksDB.

Cannot be changed once set.

§Panics

Panics if n is 0.

Source

pub fn data_block_size_policy(self, policy: BlockSizePolicy) -> Self

Sets the data block size policy.

Source

pub fn index_block_size_policy(self, policy: BlockSizePolicy) -> Self

Sets the index block size policy.

Source

pub fn data_block_hash_ratio_policy(self, policy: HashRatioPolicy) -> Self

Sets the hash ratio policy for data blocks.

If greater than 0.0, a hash index is embedded into data blocks that can speed up reads inside the data block.

Source

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

Sets the target size of blob files.

Smaller blob files allow more granular garbage collection which allows lower space amp for lower write I/O cost.

Larger blob files decrease the number of files on disk and maintenance overhead.

Defaults to 64 MiB.

This option has no effect when not used for opening a blob tree.

Source

pub fn blob_file_separation_threshold(self, bytes: u32) -> Self

Sets the key-value separation threshold in bytes.

Smaller value will reduce compaction overhead and thus write amplification, at the cost of lower read performance.

Defaults to 4KiB.

This option has no effect when not used for opening a blob tree.

Source

pub fn open(self) -> Result<Tree>

Opens a tree using the config.

§Errors

Will return Err if an IO error occurs.

Source

pub fn open_as_blob_tree(self) -> Result<BlobTree>

Opens a blob tree using the config.

§Errors

Will return Err if an IO error occurs.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.
Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.