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:
pwritethe blob bytes at the reserved extent;fsyncthe blobs — the bytes are on the platter;- write one Arrow IPC
RecordBatchnaming the extent into the journal; flush()the journal’sBufWriter— userspace → kernel;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
impl SafeWriter
Sourcepub fn create(archive: &Path) -> Result<Self>
pub fn create(archive: &Path) -> Result<Self>
Open archive and start a journal segment beside it at
<archive>.journal.
Sourcepub fn create_with_faults(archive: &Path, faults: Faults) -> Result<Self>
pub fn create_with_faults(archive: &Path, faults: Faults) -> Result<Self>
Same, with an injected fault. Tests only.
Sourcepub fn journal_path(archive: &Path) -> PathBuf
pub fn journal_path(archive: &Path) -> PathBuf
Path of the journal segment beside archive.
Sourcepub fn journal_file(&self) -> PathBuf
pub fn journal_file(&self) -> PathBuf
The journal segment this writer is appending rows to.
Trait Implementations§
Source§impl ArchiveWrite for SafeWriter
impl ArchiveWrite for SafeWriter
Source§fn append(&self, bytes: &[u8]) -> Result<Extent>
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 durability(&self) -> &'static str
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§
impl !Freeze for SafeWriter
impl RefUnwindSafe for SafeWriter
impl Send for SafeWriter
impl Sync for SafeWriter
impl Unpin for SafeWriter
impl UnsafeUnpin for SafeWriter
impl UnwindSafe for SafeWriter
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more