mbutrovich commented on code in PR #4876:
URL: https://github.com/apache/datafusion-comet/pull/4876#discussion_r3559923288


##########
native/spark-expr/src/math_funcs/unhex.rs:
##########
@@ -68,7 +94,13 @@ fn spark_unhex_inner<T: OffsetSizeTrait>(
             let string_array = as_generic_string_array::<T>(array)?;
 
             let mut encoded = Vec::new();
-            let mut builder = arrow::array::BinaryBuilder::new();
+            // Every two input hex digits produce one output byte, so the 
decoded data is at most
+            // half the total input length. Preallocating both the offset and 
value buffers avoids
+            // the repeated doublings a fresh `BinaryBuilder` would incur 
across the whole column.
+            let mut builder = arrow::array::BinaryBuilder::with_capacity(

Review Comment:
   Prefer proper use over FQNs.



##########
native/spark-expr/src/math_funcs/unhex.rs:
##########
@@ -68,7 +94,13 @@ fn spark_unhex_inner<T: OffsetSizeTrait>(
             let string_array = as_generic_string_array::<T>(array)?;
 
             let mut encoded = Vec::new();
-            let mut builder = arrow::array::BinaryBuilder::new();
+            // Every two input hex digits produce one output byte, so the 
decoded data is at most
+            // half the total input length. Preallocating both the offset and 
value buffers avoids
+            // the repeated doublings a fresh `BinaryBuilder` would incur 
across the whole column.
+            let mut builder = arrow::array::BinaryBuilder::with_capacity(

Review Comment:
   Prefer proper `use` over FQNs.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to