vortex_datafusion/persistent/
access_plan.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex::scan::ScanBuilder;
5use vortex::scan::Selection;
6
7/// Custom Vortex-specific information that can be provided by external indexes or other sources.
8///
9/// This is intended as a low-level interface for users building their own data systems, see the [advance index] example from the DataFusion repo for a similar usage with Parquet.
10///
11/// [advance index]: https://github.com/apache/datafusion/blob/47df535d2cd5aac5ad5a92bdc837f38e05ea0f0f/datafusion-examples/examples/data_io/parquet_advanced_index.rs
12#[derive(Default)]
13pub struct VortexAccessPlan {
14    selection: Option<Selection>,
15}
16
17impl VortexAccessPlan {
18    /// Sets a [`Selection`] for this plan.
19    pub fn with_selection(mut self, selection: Selection) -> Self {
20        self.selection = Some(selection);
21        self
22    }
23}
24
25impl VortexAccessPlan {
26    /// Apply the plan to the scan's builder.
27    pub fn apply_to_builder<A>(&self, mut scan_builder: ScanBuilder<A>) -> ScanBuilder<A>
28    where
29        A: 'static + Send,
30    {
31        let Self { selection } = self;
32
33        if let Some(selection) = selection {
34            scan_builder = scan_builder.with_selection(selection.clone());
35        }
36
37        scan_builder
38    }
39}