File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -68,4 +68,4 @@ harness = false
6868
6969[[bench ]]
7070name = " reader"
71- harness = false
71+ harness = false
Original file line number Diff line number Diff line change @@ -59,7 +59,11 @@ impl StructArrayDecoder {
5959 )
6060 } )
6161 . collect :: < Result < Vec < _ > , ArrowError > > ( ) ?;
62- let field_name_to_index = build_field_index ( fields) ;
62+ let field_name_to_index = if struct_mode == StructMode :: ObjectOnly {
63+ build_field_index ( fields)
64+ } else {
65+ None
66+ } ;
6367 ( decoders, field_name_to_index)
6468 } ;
6569
@@ -80,7 +84,20 @@ impl ArrayDecoder for StructArrayDecoder {
8084 let fields = struct_fields ( & self . data_type ) ;
8185 let row_count = pos. len ( ) ;
8286 let field_count = fields. len ( ) ;
83- let total_len = field_count * row_count;
87+ let total_len = field_count. checked_mul ( row_count) . ok_or_else ( || {
88+ ArrowError :: JsonError ( format ! (
89+ "StructArrayDecoder child position buffer size overflow for rows={row_count} fields={field_count}"
90+ ) )
91+ } ) ?;
92+ if total_len > self . child_pos . len ( ) {
93+ self . child_pos
94+ . try_reserve ( total_len - self . child_pos . len ( ) )
95+ . map_err ( |_| {
96+ ArrowError :: JsonError ( format ! (
97+ "StructArrayDecoder child position buffer allocation failed for rows={row_count} fields={field_count}"
98+ ) )
99+ } ) ?;
100+ }
84101 self . child_pos . resize ( total_len, 0 ) ;
85102 self . child_pos . fill ( 0 ) ;
86103 let mut nulls = self
You can’t perform that action at this time.
0 commit comments