reth_nippy_jar

Struct NippyJarWriter

Source
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>

Source

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.

Source

pub const fn user_header(&self) -> &H

Returns a reference to H of NippyJar

Source

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.

Source

pub const fn is_dirty(&self) -> bool

Returns whether there are changes that need to be committed.

Source

pub fn set_dirty(&mut self)

Sets writer as dirty.

Source

pub const fn rows(&self) -> usize

Gets total writer rows in jar.

Source

pub fn into_jar(self) -> NippyJar<H>

Consumes the writer and returns the associated NippyJar.

Source

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.

Source

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.

Source

pub fn prune_rows(&mut self, num_rows: usize) -> Result<(), NippyJarError>

Prunes rows from data and offsets file and updates its configuration on disk

Source

pub fn commit(&mut self) -> Result<(), NippyJarError>

Commits configuration and offsets to disk. It drains the internal offset list.

Source

pub fn commit_without_sync_all(&mut self) -> Result<(), NippyJarError>

Available on crate feature 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.

Source

pub fn data_file(&mut self) -> &mut BufWriter<File>

Available on crate feature test-utils only.

Returns a mutable reference to the buffered writer for the data file.

Source

pub const fn jar(&self) -> &NippyJar<H>

Available on crate feature test-utils only.

Returns a reference to the associated NippyJar instance.

Trait Implementations§

Source§

impl<H: Debug + NippyJarHeader> Debug for NippyJarWriter<H>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

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.