RatulDawar commented on code in PR #21877:
URL: https://github.com/apache/datafusion/pull/21877#discussion_r3149769578


##########
datafusion/functions/src/unicode/substrindex.rs:
##########
@@ -261,30 +261,37 @@ fn visible_string_bytes<T: OffsetSizeTrait>(
     offsets[offsets.len() - 1].as_usize() - offsets[0].as_usize()
 }
 
-fn substr_index_general<'a, S, B>(
+fn substr_index_general<'a, S, O>(
     string_array: S,
     delimiter_array: S,
     count_array: &PrimitiveArray<Int64Type>,
-    mut builder: B,
+    mut builder: GenericStringArrayBuilder<O>,
 ) -> Result<ArrayRef>
 where
     S: StringArrayType<'a> + Copy,
-    B: StringLikeArrayBuilder,
+    O: OffsetSizeTrait,
 {
-    for ((string, delimiter), n) in string_array
-        .iter()
-        .zip(delimiter_array.iter())
-        .zip(count_array.iter())
-    {
-        match (string, delimiter, n) {
-            (Some(string), Some(delimiter), Some(n)) => {
-                builder.append_value(substr_index_slice(string, delimiter, n));
-            }
-            _ => builder.append_null(),
+    let num_rows = string_array.len();
+    // Output is null IFF any input is null.
+    let nulls = NullBuffer::union(

Review Comment:
   > * in the bulk-NULL builder does not need to touch the NULL bitmap for 
every row, whereas in the Arrow builder it does. That means fewer per-row 
branches and also less data cache pressure.
   
   Makes sense, I can go ahead and draw a conclusion from this that in many 
cases, we can isolate simpler / coupled operations for better cache locality 
and SIMD.
   Thanks for the explanation here @neilconway 



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