vortex_layout/scan/execution/mod.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Scan execution over physical plans through the planner I/O and compute protocol.
5//!
6//! A `ProjectionPlanner` emits one `ProjectionMorsel` for each fixed-size work chunk. The morsel
7//! runs the physical projection plan over the chunk's selected rows through
8//! the pipeline [`Scan`](crate::plan::physical::pipeline::Scan). Every segment read is published
9//! through a `ScanAdaptor`, so the planning driver can advance other work while reads wait.
10
11mod adaptor;
12mod projection;
13mod selection;
14
15use std::sync::Arc;
16
17use vortex_buffer::Alignment;
18use vortex_io::request::IoTarget;
19use vortex_mask::Mask;
20use vortex_scan::planning::planner::WorkScope;
21use vortex_session::VortexSession;
22
23pub(super) use self::selection::plan_selection;
24use crate::plan::physical::PlanRef;
25use crate::plan::physical::pipeline::ValueCache;
26
27/// Where a segment's bytes live in its source.
28#[derive(Clone, Copy, Debug, PartialEq, Eq)]
29pub struct SegmentLocation {
30 /// Byte offset of the segment from the start of the source.
31 pub offset: u64,
32 /// Length of the segment in bytes.
33 pub length: u32,
34 /// Alignment the segment's bytes must have once delivered.
35 pub alignment: Alignment,
36}
37
38impl SegmentLocation {
39 /// The byte range a read of the segment asks for.
40 fn target(&self) -> IoTarget {
41 IoTarget::Range {
42 offset: self.offset,
43 len: self.length as usize,
44 alignment: self.alignment,
45 }
46 }
47}
48
49/// What every split of a scan shares: the projection plan and where its segments live.
50#[derive(Clone)]
51pub(super) struct ScanPlans {
52 /// The session used for decoding and expression evaluation.
53 pub(super) session: VortexSession,
54 /// The location of every segment, indexed by segment id.
55 pub(super) locations: Arc<[SegmentLocation]>,
56 /// The optimized projection plan, over the scan's root row domain.
57 pub(super) projection: PlanRef,
58 /// The global row index of the root row domain's first row.
59 pub(super) row_offset: u64,
60 /// Whole values, such as dictionary values, shared by the splits of this scan. Their plans
61 /// always read the same complete row domain, independently of a split's selection.
62 pub(super) values: ValueCache,
63}
64
65/// The rows of a split selected for projection.
66struct SelectedRows {
67 /// The split the rows belong to.
68 scope: WorkScope,
69 /// Which rows of `scope.rows` are selected.
70 mask: Mask,
71}