@@ -2,7 +2,7 @@ use std::sync::{Arc, OnceLock};
22
33use vortex_array:: aliases:: hash_map:: HashMap ;
44use vortex_array:: ContextRef ;
5- use vortex_dtype:: { DType , Field , FieldName , StructDType } ;
5+ use vortex_dtype:: { DType , FieldName , StructDType } ;
66use vortex_error:: { vortex_err, vortex_panic, VortexExpect , VortexResult } ;
77
88use 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