scovich commented on code in PR #9685:
URL: https://github.com/apache/arrow-rs/pull/9685#discussion_r3064960913


##########
parquet-variant-compute/src/from_json.rs:
##########
@@ -26,12 +26,21 @@ use parquet_variant_json::JsonToVariant;
 /// Macro to convert string array to variant array
 macro_rules! string_array_to_variant {
     ($input:expr, $array:expr, $builder:expr) => {{
-        for i in 0..$input.len() {
-            if $input.is_null(i) {
-                $builder.append_null();
-            } else {
+        let len = $input.len();
+        let mut i = 0;
+        while i < len {

Review Comment:
   It's not obvious to me that this is a good use of `append_nulls` -- it takes 
almost as much work to detect runs as to just append the nulls directly, so 
we're likely slowing down the loop by up to 2x in almost all cases even if we 
ignore the extra branching (and branch mispredictions) of this more complex 
control flow.



##########
parquet-variant-compute/src/variant_array_builder.rs:
##########
@@ -156,6 +156,26 @@ impl VariantArrayBuilder {
         self.value_offsets.push(self.value_builder.offset());
     }
 
+    /// Appends `count` null rows to the builder.
+    pub fn append_nulls(&mut self, count: usize) {
+        if count == 0 {
+            return;
+        }
+        if count == 1 {

Review Comment:
   I'd suggest following whatever e.g. `StructBuilder` does. If that approach 
hasn't caused any performance issues there, it probably works fine here as 
well. Plus, there's something to be said for uniformity of implementations.



-- 
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]

Reply via email to