Skip to main content

TurboPersistence

Struct TurboPersistence 

Source
pub struct TurboPersistence<S: ParallelScheduler, const FAMILIES: usize> { /* private fields */ }
Expand description

TurboPersistence is a persistent key-value store. It is limited to a single writer at a time using a single write batch. It allows for concurrent reads.

Implementations§

Source§

impl<S: ParallelScheduler + Default, const FAMILIES: usize> TurboPersistence<S, FAMILIES>

Source

pub fn open(path: PathBuf) -> Result<Self>

Open a TurboPersistence database at the given path. This will read the directory and might performance cleanup when the database was not closed properly. Cleanup only requires to read a few bytes from a few files and to delete files, so it’s fast.

Source

pub fn open_with_config( path: PathBuf, config: DbConfig<FAMILIES>, ) -> Result<Self>

Open a TurboPersistence database at the given path with custom per-family configuration.

Source

pub fn open_read_only_with_config( path: PathBuf, config: DbConfig<FAMILIES>, ) -> Result<Self>

Open a TurboPersistence database at the given path in read only mode. This will read the directory. No Cleanup is performed.

Source§

impl<S: ParallelScheduler, const FAMILIES: usize> TurboPersistence<S, FAMILIES>

Source

pub fn open_with_parallel_scheduler( path: PathBuf, parallel_scheduler: S, ) -> Result<Self>

Open a TurboPersistence database at the given path. This will read the directory and might performance cleanup when the database was not closed properly. Cleanup only requires to read a few bytes from a few files and to delete files, so it’s fast.

Source

pub fn open_with_config_and_parallel_scheduler( path: PathBuf, config: DbConfig<FAMILIES>, parallel_scheduler: S, ) -> Result<Self>

Open a TurboPersistence database at the given path with custom per-family configuration.

Source

pub fn is_empty(&self) -> bool

Returns true if the database is empty.

Source

pub fn write_batch<K: StoreKey + Send + Sync>( &self, ) -> Result<WriteBatch<K, S, FAMILIES>>

Starts a new WriteBatch for the database. Only a single write operation is allowed at a time. The WriteBatch need to be committed with TurboPersistence::commit_write_batch. Note that the WriteBatch might start writing data to disk while it’s filled up with data. This data will only become visible after the WriteBatch is committed.

Source

pub fn clear_cache(&self)

Clears all caches of the database.

Source

pub fn clear_block_caches(&self)

Clears block caches of the database.

Source

pub fn prepare_all_sst_caches(&self)

Prefetches all SST files which are usually lazy loaded. This can be used to reduce latency for the first queries after opening the database.

Source

pub fn commit_write_batch<K: StoreKey + Send + Sync>( &self, write_batch: WriteBatch<K, S, FAMILIES>, ) -> Result<()>

Commits a WriteBatch to the database. This will finish writing the data to disk and make it visible to readers.

Source

pub fn full_compact(&self) -> Result<()>

Runs a full compaction on the database. This will rewrite all SST files, removing all duplicate keys and separating all key ranges into unique files.

Source

pub fn compact(&self, compact_config: &CompactConfig) -> Result<bool>

Runs a (partial) compaction. Compaction will only be performed if the coverage of the SST files is above the given threshold. The coverage is the average number of SST files that need to be read to find a key. It also limits the maximum number of SST files that are merged at once, which is the main factor for the runtime of the compaction.

Source

pub fn get<K: QueryKey>( &self, family: usize, key: &K, ) -> Result<Option<ArcBytes>>

Get a value from the database. Returns None if the key is not found. The returned value might hold onto a block of the database and it should not be hold long-term.

Source

pub fn get_multiple<K: QueryKey>( &self, family: usize, key: &K, ) -> Result<SmallVec<[ArcBytes; 1]>>

Looks up a key and returns all matching values.

This is useful for keyspaces where keys are not unique and multiple mappings are possible. Unlike get, which returns only the first match, this method returns all entries with the same key from all SST files. By default however we assume these collections are small and thus optimize for there being exactly 0 or 1 results.

The order of returned values is undefined and duplicates are preserved. Callers must not rely on any particular ordering (neither insertion order nor byte order).

Source

pub fn batch_get<K: QueryKey>( &self, family: usize, keys: &[K], ) -> Result<Vec<Option<ArcBytes>>>

Source

pub fn meta_info(&self) -> Result<Vec<MetaFileInfo>>

Source

pub fn shutdown(&self) -> Result<()>

Shuts down the database. This will print statistics if the print_stats feature is enabled.

Auto Trait Implementations§

§

impl<S, const FAMILIES: usize> !Freeze for TurboPersistence<S, FAMILIES>

§

impl<S, const FAMILIES: usize> !RefUnwindSafe for TurboPersistence<S, FAMILIES>

§

impl<S, const FAMILIES: usize> Send for TurboPersistence<S, FAMILIES>

§

impl<S, const FAMILIES: usize> Sync for TurboPersistence<S, FAMILIES>

§

impl<S, const FAMILIES: usize> Unpin for TurboPersistence<S, FAMILIES>
where S: Unpin,

§

impl<S, const FAMILIES: usize> UnsafeUnpin for TurboPersistence<S, FAMILIES>
where S: UnsafeUnpin,

§

impl<S, const FAMILIES: usize> !UnwindSafe for TurboPersistence<S, FAMILIES>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more