Skip to main content

ColumnExport

Enum ColumnExport 

Source
pub enum ColumnExport {
    Owned(Vec<u8>),
    Mapped(Mmap),
}
Expand description

Fixed-size column storage backed by a seek-based file.

§Durability

Append methods write to the OS page cache but do not call fsync per append. Data written by append_* is immediately readable (via read_*) on the same or any other file descriptor to the same file, but a crash before flush may lose the most recent appends. Call flush() at commit boundaries or before advancing the WAL checkpoint. The backing of one columnar export batch — the substrate half of the language bindings’ Arrow / columnar-export path.

A columnar export hands the caller (generated FFI glue) a single contiguous, stable-pointer byte buffer for one column at one live-row selection. This type owns that buffer through whichever of the two production paths produced it, behind an identical as_ptr() / len() surface so the consumer (e.g. an Arrow ArrowArray) is alias-or-gather transparent:

  • ColumnExport::Mapped — a zero-copy mmap alias of the column file’s dense prefix, taken when the live selection is exactly the contiguous prefix [0, n) (no updates, no tombstones). No bytes are copied; the pointer aliases the page cache directly. Because numeric columns are stored little-endian (to_le_bytes), the mapped prefix is a valid Arrow primitive buffer as-is.
  • ColumnExport::Owned — a gathered contiguous copy (FixedColumn::gather), the fallback whenever the selection is not an aliasable dense prefix (update-heavy or tombstoned tables), or is empty.

§Safety / aliasing invariant (Mapped)

The mapped prefix aliases live file pages, so it relies on the same single-writer, append-only discipline the reader handles already assume: prefix rows [0, n) are committed and immutable (appends only ever extend past n, never rewrite mapped bytes), and a compaction/rollback that would renumber or truncate below n does not run while an export is outstanding (exports are synchronous reads taken on the single writer). Under that discipline the alias observes a stable snapshot.

Variants§

§

Owned(Vec<u8>)

A gathered / copied contiguous buffer.

§

Mapped(Mmap)

A zero-copy read-only mmap alias of the column file’s dense prefix.

Implementations§

Source§

impl ColumnExport

Source

pub fn as_ptr(&self) -> *const u8

Pointer to the first byte of the exported buffer. Stable across moving the ColumnExport (both a Vec’s heap allocation and an Mmap’s mapped address are independent of where the owner struct itself lives), so the FFI layer can capture it, then move self into an owner box.

Source

pub fn len(&self) -> usize

Total exported byte length (live_rows * value_size).

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_slice(&self) -> &[u8] ⓘ

The exported bytes as a slice.

Auto Trait Implementations§

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.