Skip to content

Commit c4d26db

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

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

parquet-variant/src/builder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,11 @@ 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);
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();
12081212
let id_size = int_size(max_id as usize);
12091213

12101214
let parent_buffer = self.parent_state.buffer();

0 commit comments

Comments
 (0)