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


##########
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:
   Isn’t this highly dependent on heuristics—whether the cost of performing the 
bitmap union is actually justified by the append_nulls operations it helps us 
avoid?
   
   Especially since the other approach of 1 by 1 scanning rows is also 
sequential IO ?



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