Skip to content

Commit 0c2b023

Browse files
Remove field from struct layout (#1919)
1 parent 86b6ab4 commit 0c2b023

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

vortex-layout/src/layouts/struct_/eval_expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use itertools::Itertools;
44
use vortex_array::array::StructArray;
55
use vortex_array::validity::Validity;
66
use vortex_array::{ArrayData, IntoArrayData};
7-
use vortex_dtype::Field;
87
use vortex_error::VortexResult;
98
use vortex_expr::transform::partition::partition;
109
use vortex_expr::ExprRef;
@@ -22,7 +21,7 @@ impl ExprEvaluator for StructReader {
2221
.partitions
2322
.iter()
2423
// TODO(joe): remove field from self.child
25-
.map(|partition| self.child(&Field::Name(partition.name.clone())))
24+
.map(|partition| self.child(&partition.name.clone()))
2625
.try_collect()?;
2726

2827
let arrays = try_join_all(

vortex-layout/src/layouts/struct_/reader.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::{Arc, OnceLock};
22

33
use vortex_array::aliases::hash_map::HashMap;
44
use vortex_array::ContextRef;
5-
use vortex_dtype::{DType, Field, FieldName, StructDType};
5+
use vortex_dtype::{DType, FieldName, StructDType};
66
use vortex_error::{vortex_err, vortex_panic, VortexExpect, VortexResult};
77

88
use crate::layouts::struct_::StructLayout;
@@ -63,14 +63,13 @@ impl StructReader {
6363
}
6464

6565
/// Return the child reader for the chunk.
66-
pub(crate) fn child(&self, field: &Field) -> VortexResult<&Arc<dyn LayoutReader>> {
67-
let idx = match field {
68-
Field::Name(n) => *self
69-
.field_lookup
70-
.get(n)
71-
.ok_or_else(|| vortex_err!("Field {} not found in struct layout", n))?,
72-
Field::Index(idx) => *idx,
73-
};
66+
pub(crate) fn child(&self, name: &FieldName) -> VortexResult<&Arc<dyn LayoutReader>> {
67+
let idx = *self
68+
.field_lookup
69+
.get(name)
70+
.ok_or_else(|| vortex_err!("Field {} not found in struct layout", name))?;
71+
72+
// TODO: think about a hashmap for large |fields|.
7473
self.field_readers[idx].get_or_try_init(|| {
7574
let child_layout = self
7675
.layout

0 commit comments

Comments
 (0)