Skip to main content

RunReader

Struct RunReader 

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

Reads a sorted run: decodes columns lazily (cached), answers MVCC point lookups via page-pruned SYS_ROW_ID bounds, and materializes visible rows for scans.

Implementations§

Source§

impl RunReader

Source

pub fn open( path: impl AsRef<Path>, schema: Schema, kek: Option<Arc<Kek>>, ) -> Result<Self>

Source

pub fn header(&self) -> &RunHeader

Source

pub fn is_clean(&self) -> bool

Whether this run is “clean” (one version per RowId, no tombstones, ascending row_ids) — stamped at write time via RUN_FLAG_CLEAN.

Source

pub fn row_count(&self) -> usize

Source

pub fn get_version( &mut self, row_id: RowId, snapshot: Epoch, ) -> Result<Option<(Epoch, Row)>>

Newest version of row_id with epoch <= snapshot, including tombstones (returned as a Row with deleted=true). None if no such version.

Page-pruned: SYS_ROW_ID pages carry exact first_row_id/last_row_id bounds (rows are written in ascending (RowId, Epoch) order), so this decodes only the page(s) that can contain row_id instead of the whole column — the old implementation decoded every row’s SYS_ROW_ID (and SYS_EPOCH) up front, making every single-row point lookup (the common case for a PK/unique check feeding insert/update/delete) pay a full-column decode. A row’s version group can span at most two adjacent pages (split at a page boundary mid-group); candidate_pages below collects every page whose bounds include row_id, which is normally one page and two only in that split case.

Source

pub fn get_version_column( &mut self, row_id: RowId, snapshot: Epoch, column_id: u16, ) -> Result<Option<(Epoch, bool, Option<Value>)>>

Like Self::get_version, but decodes only column_id (plus the SYS_DELETED flag) instead of materializing every schema column via Self::materialize_in_page. For a wide schema this avoids paying to decode every other column’s page just to read one value and throw the rest away — e.g. Table::remove_hot_for_row’s PK-only lookup, which used to pull the whole row (every column, every page) just for the primary key.

Source

pub fn all_rows(&mut self) -> Result<Vec<Row>>

Every row in the run (all versions), in (RowId, Epoch) order. Used by compaction, which must see every version to apply snapshot retention.

Source

pub fn visible_indices(&mut self, snapshot: Epoch) -> Result<Vec<usize>>

Indices of the newest non-deleted version per RowId visible at snapshot, ascending. This is the columnar scan primitive: compute the visible set once (one pass over the row-id/epoch/deleted columns), then Self::gather_column each user column at these indices — no per-row HashMap/Row materialization.

Source

pub fn gather_column( &mut self, column_id: u16, indices: &[usize], ) -> Result<Vec<Value>>

Gather column_id’s values at the given indices (column cached). Used with Self::visible_indices for vectorized scans. A column absent from this run (e.g. added via schema evolution after the run was written) yields all-nulls.

Source

pub fn column_native(&mut self, column_id: u16) -> Result<NativeColumn>

Decode a column straight to a typed [NativeColumn] (no Value), concatenating all pages. A column absent from this run (schema evolution) yields an all-null column. Pages are decoded in parallel (rayon) when the run is mmap-backed and has more than one page; otherwise sequentially.

Source

pub fn has_mmap(&self) -> bool

Whether this reader is backed by a memory map (the prerequisite for the &self parallel decode paths). Readers on filesystems that reject mmap fall back to per-page read() and has_mmap() is false.

Source

pub fn column_native_shared(&self, column_id: u16) -> Result<NativeColumn>

&self variant of [column_native] for cross-column parallel scans (Phase 15.1). Requires the mmap backing (uses [read_page_shared], which is rayon-safe); callers without mmap use the &mut [column_native]. Pages within the column decode in parallel when there is more than one, and MADV_WILLNEED is hinted up front so the kernel pre-faults the whole column’s byte range (Phase 15.2) before the decode workers touch it.

Source

pub fn range_row_ids_i64( &mut self, column_id: u16, lo: i64, hi: i64, ) -> Result<HashSet<u64>>

Row ids whose Int64 value is in [lo, hi], skipping pages whose [min,max] stat excludes the range (Parquet-style page-index pruning). Nulls are excluded. Used by Table::query_columns_native to serve Condition::Range without decoding every page.

Source

pub fn range_row_ids_f64( &mut self, column_id: u16, lo: f64, lo_inclusive: bool, hi: f64, hi_inclusive: bool, ) -> Result<HashSet<u64>>

Float64 analogue of Self::range_row_ids_i64 with per-bound inclusivity, for Condition::RangeF64.

Source

pub fn visible_indices_native(&mut self, snapshot: Epoch) -> Result<Vec<usize>>

Source

pub fn range_row_ids_visible_i64( &mut self, column_id: u16, lo: i64, hi: i64, snapshot: Epoch, ) -> Result<Vec<u64>>

Page-pruned, MVCC-visible Int64 range resolution (Phase 16.3).

Like Self::range_row_ids_i64 (skips pages whose [min,max] excludes [lo, hi]) but restricts the output to the newest non-deleted version per RowId visible at snapshot. This is the layout-independent range primitive: correct under any memtable / multi-run / deletion-vector state, so the engine no longer has to fall back to a full-column decode when the “single clean run” invariant doesn’t hold. Nulls are excluded.

Source

pub fn range_row_ids_visible_f64( &mut self, column_id: u16, lo: f64, lo_inclusive: bool, hi: f64, hi_inclusive: bool, snapshot: Epoch, ) -> Result<Vec<u64>>

Float64 analogue of Self::range_row_ids_visible_i64 with per-bound inclusivity (Phase 16.3).

Source

pub fn null_row_ids_visible( &mut self, column_id: u16, want_nulls: bool, snapshot: Epoch, ) -> Result<Vec<u64>>

MVCC-visible IS NULL / IS NOT NULL resolution. Follows the same page-stat-pruned + visible-positions pattern as Self::range_row_ids_visible_i64, but checks the validity bitmap instead of a value range. Pages with no nulls (for IS NULL) or all-nulls (for IS NOT NULL) are skipped.

Source

pub fn visible_positions_with_rids( &mut self, snapshot: Epoch, ) -> Result<(Vec<usize>, Vec<i64>)>

tombstones excluded) paired with each position’s RowId, in one pass. Used by crate::cursor::NativePageCursor to map survivors to pages without re-decoding the system columns.

Source

pub fn page_row_counts(&self, column_id: u16) -> Result<Vec<usize>>

Row count of each PAX page of column_id, in page order. Every column in a run shares the same PAX row partition, so this yields the table’s page layout (cumulative sums give page start offsets).

Source

pub fn has_column(&self, column_id: u16) -> bool

Whether this run stores column_id (false for a column added via add_column after the run was written — those read as all-null).

Source

pub fn column_page_stats(&self, column_id: u16) -> Option<&[PageStat]>

The per-page PageStats for column_id, or None if the column is absent from this run (schema evolution). Used to compute exact column min/max/null_count for the analytical aggregate fast path.

Source

pub fn visible_versions(&mut self, snapshot: Epoch) -> Result<Vec<Row>>

Newest visible version per RowId at snapshot, including tombstones (as Rows with deleted=true). Ascending RowId. Used by the engine to merge versions across runs and the memtable.

Source

pub fn visible_rows(&mut self, snapshot: Epoch) -> Result<Vec<Row>>

All non-deleted rows visible at snapshot. Ascending RowId.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.