Skip to content

Commit 81d3bf4

Browse files
authored
configurable layouts for open options (#2081)
Allows custom / external layout implementations to be passed into a file reader through `VortexOpenOptions`.
1 parent 3383522 commit 81d3bf4

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vortex-file/src/open/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ impl VortexOpenOptions {
6565
}
6666
}
6767

68+
/// Configure a layout context.
69+
pub fn with_layouts(mut self, layout_ctx: LayoutContextRef) -> Self {
70+
self.layout_ctx = layout_ctx;
71+
self
72+
}
73+
6874
/// Configure a known file layout.
6975
///
7076
/// If this is provided, then the Vortex file can be opened without performing any I/O.

vortex-layout/src/context.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ impl LayoutContext {
1717
Self { layout_refs }
1818
}
1919

20+
pub fn with_layout(mut self, layout: LayoutEncodingRef) -> Self {
21+
self.layout_refs.insert(layout.id(), layout);
22+
self
23+
}
24+
25+
pub fn with_layouts<E: IntoIterator<Item = LayoutEncodingRef>>(mut self, layouts: E) -> Self {
26+
self.layout_refs
27+
.extend(layouts.into_iter().map(|e| (e.id(), e)));
28+
self
29+
}
30+
2031
pub fn lookup_layout(&self, id: LayoutId) -> Option<LayoutEncodingRef> {
2132
self.layout_refs.get(&id).cloned()
2233
}

vortex/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ vortex-sampling-compressor = { workspace = true }
4545
vortex-scalar = { workspace = true, default-features = true }
4646
vortex-scan = { workspace = true, default-features = true }
4747
vortex-zigzag = { workspace = true }
48+
vortex-layout = { workspace = true }
4849

4950
[features]
5051
tokio = ["vortex-io/tokio", "vortex-file/tokio"]

vortex/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ pub use vortex_array::*;
22
pub use {
33
vortex_buffer as buffer, vortex_datetime_dtype as datetime_dtype, vortex_dtype as dtype,
44
vortex_error as error, vortex_expr as expr, vortex_file as file,
5-
vortex_flatbuffers as flatbuffers, vortex_io as io, vortex_ipc as ipc, vortex_mask as mask,
6-
vortex_proto as proto, vortex_sampling_compressor as sampling_compressor,
5+
vortex_flatbuffers as flatbuffers, vortex_io as io, vortex_ipc as ipc, vortex_layout as layout,
6+
vortex_mask as mask, vortex_proto as proto, vortex_sampling_compressor as sampling_compressor,
77
vortex_scalar as scalar, vortex_scan as scan,
88
};
99

0 commit comments

Comments
 (0)