Struct rsdb::LockFreeLog
[−]
[src]
pub struct LockFreeLog { /* fields omitted */ }
A sequential store which allows users to create reservations placed at known log offsets, used for writing persistent data structures that need to know where to find persisted bits in the future.
Working with LockFreeLog
use rsdb::Log; let log = rsdb::Config::default().log(); let first_offset = log.write(b"1".to_vec()); log.write(b"22".to_vec()); log.write(b"333".to_vec()); // stick an abort in the middle, which should not be returned let res = log.reserve(b"never_gonna_hit_disk".to_vec()); res.abort(); log.write(b"4444".to_vec()); let last_offset = log.write(b"55555".to_vec()); log.make_stable(last_offset); let mut iter = log.iter_from(first_offset); assert_eq!(iter.next().unwrap().1, b"1".to_vec()); assert_eq!(iter.next().unwrap().1, b"22".to_vec()); assert_eq!(iter.next().unwrap().1, b"333".to_vec()); assert_eq!(iter.next().unwrap().1, b"4444".to_vec()); assert_eq!(iter.next().unwrap().1, b"55555".to_vec()); assert_eq!(iter.next(), None);
Methods
impl LockFreeLog
[src]
fn start_system(config: Config) -> LockFreeLog
create new lock-free log
fn flush(&self)
Flush the next io buffer.
Trait Implementations
impl Send for LockFreeLog
[src]
impl Sync for LockFreeLog
[src]
impl Drop for LockFreeLog
[src]
impl Log for LockFreeLog
[src]
fn reserve(&self, buf: Vec<u8>) -> Reservation
Create a log offset reservation for a particular write, which may later be filled or canceled. Read more
fn config(&self) -> &Config
return the config in use for this log
fn write(&self, buf: Vec<u8>) -> u64
Write a buffer to underlying storage.
fn read(&self, id: u64) -> Result<LogRead>
read a buffer from the disk
fn stable_offset(&self) -> u64
returns the current stable offset written to disk
fn make_stable(&self, id: u64)
blocks until the specified id has been made stable on disk
fn punch_hole(&self, id: u64)
deallocates the data part of a log id
fn iter_from(&self, id: u64) -> LogIter<Self>
Return an iterator over the log, starting with a specified offset. Read more