vortex_layout/plan/plans/
segment_scan.rs1use vortex_array::EmptyMetadata;
5use vortex_array::dtype::DType;
6use vortex_buffer::ByteBuffer;
7use vortex_error::VortexResult;
8use vortex_session::registry::CachedId;
9use vortex_session::registry::ReadContext;
10
11use crate::plan::Plan;
12use crate::plan::PlanChildren;
13use crate::plan::PlanId;
14use crate::plan::PlanParts;
15use crate::plan::PlanVTable;
16use crate::plan::check_child_count;
17use crate::segments::SegmentId;
18
19#[derive(Clone, Debug)]
21pub struct SegmentScan;
22
23#[derive(Clone, Debug)]
25pub struct SegmentScanData {
26 segment_id: SegmentId,
27 array_ctx: ReadContext,
28 array_tree: Option<ByteBuffer>,
29}
30
31pub type SegmentScanPlan = Plan<SegmentScan>;
33
34impl SegmentScanPlan {
35 pub fn new(
37 dtype: DType,
38 row_count: u64,
39 segment_id: SegmentId,
40 array_ctx: ReadContext,
41 array_tree: Option<ByteBuffer>,
42 ) -> Self {
43 PlanParts {
44 vtable: SegmentScan,
45 dtype,
46 row_count,
47 children: PlanChildren::default(),
48 data: SegmentScanData {
49 segment_id,
50 array_ctx,
51 array_tree,
52 },
53 }
54 .into_typed()
55 }
56
57 pub fn segment_id(&self) -> SegmentId {
59 self.data().segment_id
60 }
61
62 pub fn array_ctx(&self) -> &ReadContext {
64 &self.data().array_ctx
65 }
66
67 pub fn array_tree(&self) -> Option<&ByteBuffer> {
69 self.data().array_tree.as_ref()
70 }
71}
72
73impl PlanVTable for SegmentScan {
74 type PlanData = SegmentScanData;
75 type Metadata = EmptyMetadata;
76
77 fn id(&self) -> PlanId {
78 static ID: CachedId = CachedId::new("vortex.plan.segment_scan");
79 *ID
80 }
81
82 fn metadata(_plan: &Plan<Self>) -> Option<Self::Metadata> {
83 None
85 }
86
87 fn with_children(
88 _plan: &Plan<Self>,
89 children: &PlanChildren,
90 _data: &mut Self::PlanData,
91 ) -> VortexResult<()> {
92 check_child_count("SegmentScan", children, 0)?;
93 Ok(())
94 }
95}