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>
impl<S: ParallelScheduler + Default, const FAMILIES: usize> TurboPersistence<S, FAMILIES>
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_with_config(
path: PathBuf,
config: DbConfig<FAMILIES>,
) -> Result<Self>
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.
Sourcepub fn open_read_only_with_config(
path: PathBuf,
config: DbConfig<FAMILIES>,
) -> Result<Self>
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>
impl<S: ParallelScheduler, const FAMILIES: usize> TurboPersistence<S, FAMILIES>
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_with_config_and_parallel_scheduler(
path: PathBuf,
config: DbConfig<FAMILIES>,
parallel_scheduler: S,
) -> Result<Self>
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.
Sourcepub fn write_batch<K: StoreKey + Send + Sync>(
&self,
) -> Result<WriteBatch<K, S, FAMILIES>>
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.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clears all caches of the database.
Sourcepub fn clear_block_caches(&self)
pub fn clear_block_caches(&self)
Clears block caches of the database.
Sourcepub fn prepare_all_sst_caches(&self)
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.
Sourcepub fn commit_write_batch<K: StoreKey + Send + Sync>(
&self,
write_batch: WriteBatch<K, S, FAMILIES>,
) -> Result<()>
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.
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<ArcBytes>>
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.
Sourcepub fn get_multiple<K: QueryKey>(
&self,
family: usize,
key: &K,
) -> Result<SmallVec<[ArcBytes; 1]>>
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).
pub fn batch_get<K: QueryKey>( &self, family: usize, keys: &[K], ) -> Result<Vec<Option<ArcBytes>>>
pub fn meta_info(&self) -> Result<Vec<MetaFileInfo>>
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> 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