Skip to main content

SafeWriter

Struct SafeWriter 

Source
pub struct SafeWriter { /* private fields */ }
Expand description

The ordering znippy’s own hot path already uses, followed rather than re-invented.

Per append, in this order and no other:

  1. pwrite the blob bytes at the reserved extent;
  2. fsync the blobs — the bytes are on the platter;
  3. write one Arrow IPC RecordBatch naming the extent into the journal;
  4. flush() the journal’s BufWriter — userspace → kernel;
  5. sync_all() the journal file — kernel → platter.

Steps 4 and 5 are not interchangeable and 5 alone is not enough: see the module docs’ “BufWriter trap”. Steps 2 and 3 are not interchangeable either — that is the crash-ordering contract, and crash_between_fsyncs_leaves_orphan_bytes_not_a_dangling_reference asserts it on real files.

§Durability on return

The bytes are on the device and a journal row on the device points at them. A crash after return keeps both.

Implementations§

Source§

impl SafeWriter

Source

pub fn create(archive: &Path) -> Result<Self>

Open archive and start a journal segment beside it at <archive>.journal.

Source

pub fn create_with_faults(archive: &Path, faults: Faults) -> Result<Self>

Same, with an injected fault. Tests only.

Source

pub fn journal_path(archive: &Path) -> PathBuf

Path of the journal segment beside archive.

Source

pub fn blobs(&self) -> &File

The blob file, for a reader that wants to pread an extent back.

Source

pub fn journal_file(&self) -> PathBuf

The journal segment this writer is appending rows to.

Trait Implementations§

Source§

impl ArchiveWrite for SafeWriter

Source§

fn append(&self, bytes: &[u8]) -> Result<Extent>

Append these bytes and return when this implementation’s durability contract is met. Returns the byte extent written. Read more
Source§

fn name(&self) -> &'static str

Name it on a bench row.
Source§

fn durability(&self) -> &'static str

One-line statement of what a crash immediately after append returns does to the bytes. On the bench table next to the throughput, because a throughput without this is not a comparison.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.