Skip to content

Commit 59bcf21

Browse files
authored
Introduce extendable access plan for DF scans (#5855)
Building on top of some previous work, this should make using extensions more durable in the future, allowing us to support multiple ones. --------- Signed-off-by: Adam Gutglick <[email protected]>
1 parent b66d5e9 commit 59bcf21

File tree

3 files changed

+237
-170
lines changed

3 files changed

+237
-170
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use vortex::scan::ScanBuilder;
5+
use 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)]
13+
pub struct VortexAccessPlan {
14+
selection: Option<Selection>,
15+
}
16+
17+
impl 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+
25+
impl 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+
}

vortex-datafusion/src/persistent/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
//! Persistent implementation of a Vortex table provider.
5+
mod access_plan;
56
mod cache;
67
mod format;
78
pub mod metrics;
89
mod opener;
910
mod sink;
1011
mod source;
1112

13+
pub use access_plan::VortexAccessPlan;
1214
pub use format::VortexFormat;
1315
pub use format::VortexFormatFactory;
1416
pub use format::VortexOptions;

0 commit comments

Comments
 (0)