pub struct NippyJarWriter<H: NippyJarHeader = ()> { /* private fields */ }
Expand description
Writer of NippyJar
. Handles table data and offsets only.
Table data is written directly to disk, while offsets and configuration need to be flushed by
calling commit()
.
§Offset file layout
The first byte is the size of a single offset in bytes, m
.
Then, the file contains n
entries, each with a size of m
. Each entry represents an offset,
except for the last entry, which represents both the total size of the data file, as well as the
next offset to write new data to.
§Data file layout
The data file is represented just as a sequence of bytes of data without any delimiters
Implementations§
Source§impl<H: NippyJarHeader> NippyJarWriter<H>
impl<H: NippyJarHeader> NippyJarWriter<H>
Sourcepub fn new(jar: NippyJar<H>) -> Result<Self, NippyJarError>
pub fn new(jar: NippyJar<H>) -> Result<Self, NippyJarError>
Creates a NippyJarWriter
from NippyJar
.
If will always attempt to heal any inconsistent state when called.
Sourcepub const fn user_header(&self) -> &H
pub const fn user_header(&self) -> &H
Returns a reference to H
of NippyJar
Sourcepub fn user_header_mut(&mut self) -> &mut H
pub fn user_header_mut(&mut self) -> &mut H
Returns a mutable reference to H
of NippyJar
.
Since there’s no way of knowing if H
has been actually changed, this sets self.dirty
to
true.
Sourcepub const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
Returns whether there are changes that need to be committed.
Sourcepub fn append_rows(
&mut self,
column_values_per_row: Vec<impl IntoIterator<Item = ColumnResult<impl AsRef<[u8]>>>>,
num_rows: u64,
) -> Result<(), NippyJarError>
pub fn append_rows( &mut self, column_values_per_row: Vec<impl IntoIterator<Item = ColumnResult<impl AsRef<[u8]>>>>, num_rows: u64, ) -> Result<(), NippyJarError>
Appends rows to data file. fn commit()
should be called to flush offsets and config to
disk.
column_values_per_row
: A vector where each element is a column’s values in sequence,
corresponding to each row. The vector’s length equals the number of columns.
Sourcepub fn append_column(
&mut self,
column: Option<ColumnResult<impl AsRef<[u8]>>>,
) -> Result<(), NippyJarError>
pub fn append_column( &mut self, column: Option<ColumnResult<impl AsRef<[u8]>>>, ) -> Result<(), NippyJarError>
Appends a column to data file. fn commit()
should be called to flush offsets and config to
disk.
Sourcepub fn prune_rows(&mut self, num_rows: usize) -> Result<(), NippyJarError>
pub fn prune_rows(&mut self, num_rows: usize) -> Result<(), NippyJarError>
Prunes rows from data and offsets file and updates its configuration on disk
Sourcepub fn commit(&mut self) -> Result<(), NippyJarError>
pub fn commit(&mut self) -> Result<(), NippyJarError>
Commits configuration and offsets to disk. It drains the internal offset list.
Sourcepub fn commit_without_sync_all(&mut self) -> Result<(), NippyJarError>
Available on crate feature test-utils
only.
pub fn commit_without_sync_all(&mut self) -> Result<(), NippyJarError>
test-utils
only.Commits changes to the data file and offsets without synchronizing all data to disk.
This function flushes the buffered data to the data file and commits the offsets, but it does not guarantee that all data is synchronized to persistent storage.
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for NippyJarWriter<H>where
H: Freeze,
impl<H> RefUnwindSafe for NippyJarWriter<H>where
H: RefUnwindSafe,
impl<H> Send for NippyJarWriter<H>
impl<H> Sync for NippyJarWriter<H>
impl<H> Unpin for NippyJarWriter<H>where
H: Unpin,
impl<H> UnwindSafe for NippyJarWriter<H>where
H: UnwindSafe,
Blanket Implementations§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.