scovich commented on code in PR #8031:
URL: https://github.com/apache/arrow-rs/pull/8031#discussion_r2670129180
##########
parquet-variant/src/builder/object.rs:
##########
@@ -244,42 +284,133 @@ impl<'a, S: BuilderSpecificState> ObjectBuilder<'a, S> {
(if is_large { 4 } else { 1 }) + // num_fields
(num_fields * id_size as usize) + // field IDs
((num_fields + 1) * offset_size as usize); // field offsets +
data_size
+ // Calculated header size becomes a hint; being wrong only risks extra
allocations.
+ // Make sure to reserve enough capacity to handle the extra bytes
we'll truncate.
+ let mut bytes_to_splice = Vec::with_capacity(header_size + 3);
+ // let header = object_header(is_large, id_size, offset_size);
+ // bytes_to_splice.push(header);
+
+ match (offset_size, id_size) {
+ (1, 1) => ObjectHeaderWriter::<1, 1>::write(
+ &mut bytes_to_splice,
+ num_fields,
+ self.fields.keys().copied(),
+ self.fields.values().copied(),
+ data_size,
+ ),
+ (1, 2) => ObjectHeaderWriter::<1, 2>::write(
+ &mut bytes_to_splice,
+ num_fields,
+ self.fields.keys().copied(),
+ self.fields.values().copied(),
+ data_size,
+ ),
Review Comment:
(I figured out a way to write a cartesian product expansion macro (it needs
two macros, actually), but it's hideously complex and way more than sixteen
LoC. Not worth it unless we're _really_ worried about typos in the match arms)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]