Struct TurboPersistence

Source
pub struct TurboPersistence { /* 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 TurboPersistence

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_read_only(path: PathBuf) -> Result<Self>

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

Source

pub fn is_empty(&self) -> bool

Returns true if the database is empty.

Source

pub fn write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>( &self, ) -> Result<WriteBatch<K, 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 commit_write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>( &self, write_batch: WriteBatch<K, 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<()>

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<ArcSlice<u8>>>

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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