pub struct TurboPersistence<S: ParallelScheduler> { /* 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> TurboPersistence<S>
impl<S: ParallelScheduler + Default> TurboPersistence<S>
Sourcepub fn open(path: PathBuf) -> Result<Self>
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.
Sourcepub fn open_read_only(path: PathBuf) -> Result<Self>
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§impl<S: ParallelScheduler> TurboPersistence<S>
impl<S: ParallelScheduler> TurboPersistence<S>
Sourcepub fn open_with_parallel_scheduler(
path: PathBuf,
parallel_scheduler: S,
) -> Result<Self>
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.
Sourcepub fn open_read_only_with_parallel_scheduler(
path: PathBuf,
parallel_scheduler: S,
) -> Result<Self>
pub fn open_read_only_with_parallel_scheduler( path: PathBuf, parallel_scheduler: S, ) -> Result<Self>
Open a TurboPersistence database at the given path in read only mode. This will read the directory. No Cleanup is performed.
Sourcepub fn write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>(
&self,
) -> Result<WriteBatch<K, S, FAMILIES>>
pub fn write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>( &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.
Sourcepub fn commit_write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>(
&self,
write_batch: WriteBatch<K, S, FAMILIES>,
) -> Result<()>
pub fn commit_write_batch<K: StoreKey + Send + Sync + 'static, const FAMILIES: usize>( &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.
Sourcepub fn full_compact(&self) -> Result<()>
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.
Sourcepub fn compact(&self, compact_config: &CompactConfig) -> Result<bool>
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.
Sourcepub fn get<K: QueryKey>(
&self,
family: usize,
key: &K,
) -> Result<Option<ArcSlice<u8>>>
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.
pub fn meta_info(&self) -> Result<Vec<MetaFileInfo>>
Auto Trait Implementations§
impl<S> !Freeze for TurboPersistence<S>
impl<S> !RefUnwindSafe for TurboPersistence<S>
impl<S> Send for TurboPersistence<S>
impl<S> Sync for TurboPersistence<S>
impl<S> Unpin for TurboPersistence<S>where
S: Unpin,
impl<S> !UnwindSafe for TurboPersistence<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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