alamb commented on code in PR #16087:
URL: https://github.com/apache/datafusion/pull/16087#discussion_r2096115219


##########
datafusion/functions/src/string/ascii.rs:
##########
@@ -103,19 +103,22 @@ impl ScalarUDFImpl for AsciiFunc {
 
 fn calculate_ascii<'a, V>(array: V) -> Result<ArrayRef, ArrowError>
 where
-    V: ArrayAccessor<Item = &'a str>,
+    V: StringArrayType<'a, Item = &'a str>,
 {
-    let iter = ArrayIter::new(array);
-    let result = iter
-        .map(|string| {
-            string.map(|s| {
-                let mut chars = s.chars();
-                chars.next().map_or(0, |v| v as i32)
-            })
+    let values: Vec<_> = (0..array.len())
+        .map(|i| {
+            if array.is_null(i) {
+                0

Review Comment:
   It would be legal. I am not sure it would be faster, though we could easily 
check with a benchmark once this PR is merged
   
   We could at least add a check on the outside of the loop
   
   ```rust
   // If the array has no nulls, skip checking each value
   if array.null_count() == 0 {
     let values: Vec<_> = (0..array.len())....
   }
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to