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
impl RunReader
pub fn open( path: impl AsRef<Path>, schema: Schema, kek: Option<Arc<Kek>>, ) -> Result<Self>
pub fn header(&self) -> &RunHeader
Sourcepub fn is_clean(&self) -> bool
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.
pub fn row_count(&self) -> usize
Sourcepub fn get_version(
&mut self,
row_id: RowId,
snapshot: Epoch,
) -> Result<Option<(Epoch, Row)>>
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.
Sourcepub fn get_version_column(
&mut self,
row_id: RowId,
snapshot: Epoch,
column_id: u16,
) -> Result<Option<(Epoch, bool, Option<Value>)>>
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.
Sourcepub fn all_rows(&mut self) -> Result<Vec<Row>>
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.
Sourcepub fn visible_indices(&mut self, snapshot: Epoch) -> Result<Vec<usize>>
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.
Sourcepub fn gather_column(
&mut self,
column_id: u16,
indices: &[usize],
) -> Result<Vec<Value>>
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.
Sourcepub fn column_native(&mut self, column_id: u16) -> Result<NativeColumn>
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.
Sourcepub fn has_mmap(&self) -> bool
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.
&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.
Sourcepub fn range_row_ids_i64(
&mut self,
column_id: u16,
lo: i64,
hi: i64,
) -> Result<HashSet<u64>>
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.
Sourcepub fn range_row_ids_f64(
&mut self,
column_id: u16,
lo: f64,
lo_inclusive: bool,
hi: f64,
hi_inclusive: bool,
) -> Result<HashSet<u64>>
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.
pub fn visible_indices_native(&mut self, snapshot: Epoch) -> Result<Vec<usize>>
Sourcepub fn range_row_ids_visible_i64(
&mut self,
column_id: u16,
lo: i64,
hi: i64,
snapshot: Epoch,
) -> Result<Vec<u64>>
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.
Sourcepub 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>>
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).
Sourcepub fn null_row_ids_visible(
&mut self,
column_id: u16,
want_nulls: bool,
snapshot: Epoch,
) -> Result<Vec<u64>>
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.
Sourcepub fn visible_positions_with_rids(
&mut self,
snapshot: Epoch,
) -> Result<(Vec<usize>, Vec<i64>)>
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.
Sourcepub fn page_row_counts(&self, column_id: u16) -> Result<Vec<usize>>
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).
Sourcepub fn has_column(&self, column_id: u16) -> bool
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).
Sourcepub fn column_page_stats(&self, column_id: u16) -> Option<&[PageStat]>
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.
Auto Trait Implementations§
impl !RefUnwindSafe for RunReader
impl !UnwindSafe for RunReader
impl Freeze for RunReader
impl Send for RunReader
impl Sync for RunReader
impl Unpin for RunReader
impl UnsafeUnpin for RunReader
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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