comphead commented on code in PR #4919:
URL: https://github.com/apache/datafusion-comet/pull/4919#discussion_r3582690367
##########
native/spark-expr/src/static_invoke/char_varchar_utils/read_side_padding.rs:
##########
@@ -195,36 +196,37 @@ fn spark_read_side_padding_internal<T: OffsetSizeTrait>(
) -> Result<ColumnarValue, DataFusionError> {
let string_array = as_generic_string_array::<T>(array)?;
- // Pre-compute pad characters once to avoid repeated iteration
- let pad_chars: Vec<char> = pad_string.chars().collect();
-
match pad_type {
ColumnarValue::Array(array_int) => {
let int_pad_array = array_int.as_primitive::<Int32Type>();
+ // Every row is padded to its target length, so the sum of the
target
+ // lengths sizes the output (exactly, for ASCII input), except
when a
+ // row is longer than its target and passes through untruncated.
+ let mut data_capacity = 0usize;
+ let mut max_length = 0usize;
+ for length in int_pad_array.values() {
+ let length = (*length).max(0) as usize;
Review Comment:
Hopefully this every row cast is not expensive on modern CPUs
--
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]