Struct pagecache::Log[][src]

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

let conf = pagecache::ConfigBuilder::new()
    .temporary(true)
    .segment_mode(pagecache::SegmentMode::Linear)
    .build();
let log = pagecache::Log::start_raw_log(conf).unwrap();
let (first_lsn, _first_offset) = log.write(b"1".to_vec()).unwrap();
log.write(b"22".to_vec()).unwrap();
log.write(b"333".to_vec()).unwrap();

// stick an abort in the middle, which should not be returned
let res = log.reserve(b"never_gonna_hit_disk".to_vec()).unwrap();
res.abort().unwrap();

log.write(b"4444".to_vec());
let (last_lsn, _last_offset) = log.write(b"55555".to_vec()).unwrap();
log.make_stable(last_lsn).unwrap();
let mut iter = log.iter_from(first_lsn);
assert_eq!(iter.next().unwrap().2, b"1".to_vec());
assert_eq!(iter.next().unwrap().2, b"22".to_vec());
assert_eq!(iter.next().unwrap().2, b"333".to_vec());
assert_eq!(iter.next().unwrap().2, b"4444".to_vec());
assert_eq!(iter.next().unwrap().2, b"55555".to_vec());
assert_eq!(iter.next(), None);

Methods

impl Log
[src]

Start the log, open or create the configured file, and optionally start the periodic buffer flush thread.

Starts a log for use without a materializer.

Flushes any pending IO buffers to disk to ensure durability.

Reserve space in the log for a pending linearized operation.

Write a buffer into the log. Returns the log sequence number and the file offset of the write.

Return an iterator over the log, starting with a specified offset.

read a buffer from the disk

returns the current stable offset written to disk

blocks until the specified log sequence number has been made stable on disk

Trait Implementations

impl Send for Log
[src]

impl Sync for Log
[src]