Skip to content

Commit bdf1f2d

Browse files
committed
use metadata lenght as the max_id for field id
1 parent 690dc35 commit bdf1f2d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

parquet-variant/src/builder.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,12 @@ impl<'a> ObjectBuilder<'a> {
12041204
let field_b_name = metadata_builder.field_name(field_b_id as usize);
12051205
field_a_name.cmp(field_b_name)
12061206
});
1207-
let max_id = self.fields.iter().map(|(i, _)| *i).max().unwrap_or(0);
1208-
let id_size = int_size(max_id as usize);
1207+
1208+
// the length of the metadata's field names is a very cheap to compute the upper bound.
1209+
// it will almost always be a tight upper bound as well -- it would take a pretty
1210+
// carefully crafted object to use only the early field ids of a large dictionary.
1211+
let max_id = metadata_builder.field_names.len();
1212+
let id_size = int_size(max_id);
12091213

12101214
let parent_buffer = self.parent_state.buffer();
12111215
let current_offset = parent_buffer.offset();

0 commit comments

Comments
 (0)