friendlymatthew commented on code in PR #7833:
URL: https://github.com/apache/arrow-rs/pull/7833#discussion_r2183801232
##########
parquet-variant/src/builder.rs:
##########
@@ -237,18 +237,37 @@ impl ValueBuffer {
struct MetadataBuilder {
// Field names -- field_ids are assigned in insert order
field_names: IndexSet<String>,
+
+ // flag that checks if field names by insertion order are also
lexicographically sorted
+ is_sorted: bool,
}
impl MetadataBuilder {
/// Upsert field name to dictionary, return its ID
fn upsert_field_name(&mut self, field_name: &str) -> u32 {
- let (id, _) = self.field_names.insert_full(field_name.to_string());
+ let (id, new_entry) =
self.field_names.insert_full(field_name.to_string());
+
+ if new_entry {
+ let n = self.num_field_names();
+
+ self.is_sorted =
+ n == 1 || self.is_sorted & (self.field_names[n - 2] <
self.field_names[n - 1]);
Review Comment:
If this is too unreadable, I can revert back to:
```rs
if n == 1 {
self.is_sorted = true;
} else {
self.is_sorted &= self.field_names[n - 2] < self.field_names[n - 1];
}
```
I just wanted to remove the superfluous branch!
--
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]