pub struct Marble { /* private fields */ }
Expand description
Garbage-collecting object store. A nice solution to back a pagecache, for people building their own databases.
Writes should generally be performed by some background process whose job it is to clean logs etc…
Implementations§
source§impl Marble
impl Marble
sourcepub fn maintenance(&self) -> Result<usize>
pub fn maintenance(&self) -> Result<usize>
Defragments backing storage files, blocking
concurrent calls to write_batch
but not
blocking concurrent calls to read
. Returns the
number of rewritten objects.
source§impl Marble
impl Marble
sourcepub fn write_batch<B, I>(&self, write_batch: I) -> Result<()>where
B: AsRef<[u8]>,
I: IntoIterator<Item = (u64, Option<B>)>,
pub fn write_batch<B, I>(&self, write_batch: I) -> Result<()>where B: AsRef<[u8]>, I: IntoIterator<Item = (u64, Option<B>)>,
Write a batch of objects to disk. This function is crash-atomic but NOT runtime atomic. If you are concurrently serving reads, and require atomic batch semantics, you should serve reads out of an in-memory cache until this function returns. Creates one file per call. May perform several fsync calls per call. Ideally, you will heavily batch objects being written using a logger of some sort before calling this function occasionally in the background, then deleting corresponding logs after this function returns.
source§impl Marble
impl Marble
sourcepub fn stats(&self) -> Stats
pub fn stats(&self) -> Stats
Statistics about current files, intended to inform
decisions about when to call maintenance
based on
desired write and space amplification
characteristics.
sourcepub fn sync_all(&self) -> Result<()>
pub fn sync_all(&self) -> Result<()>
If Config::fsync_each_batch
is false
, this
method can be called at a desired interval to
ensure that the written batches are durable on
disk.
sourcepub fn free_object_ids<'a>(&'a self) -> (u64, impl 'a + Iterator<Item = u64>)
pub fn free_object_ids<'a>(&'a self) -> (u64, impl 'a + Iterator<Item = u64>)
Intended for use in recovery, to bootstrap a higher level object ID allocator.
Returns a tuple of 1 higher than the current max allocated object ID,
and an iterator over all object IDs beneath that which are
currently deleted (due to being stored as a None
in a write batch).
sourcepub fn allocated_object_ids<'a>(&'a self) -> impl 'a + Iterator<Item = u64>
pub fn allocated_object_ids<'a>(&'a self) -> impl 'a + Iterator<Item = u64>
Returns an Iterator over all currently allocated object IDs.