rkrishn7 commented on code in PR #27499:
URL: https://github.com/apache/datafusion/pull/27499#discussion_r4617998771


##########
datafusion/physical-expr-common/src/binary_map.rs:
##########
@@ -547,6 +547,84 @@ where
         )
     }
 
+    /// Looks up each value in `values` without inserting anything.
+    ///
+    /// `observe_payload_fn` is called once per row, in order, with
+    /// `Some(payload)` if the value is already stored and `None` otherwise. A
+    /// null row maps to the payload of the null entry if one exists, matching
+    /// [`Self::insert_if_new`].
+    pub fn find<OP>(&mut self, values: &ArrayRef, observe_payload_fn: OP)
+    where
+        OP: FnMut(Option<V>),
+    {
+        match self.output_type {
+            OutputType::Binary => {
+                assert!(matches!(
+                    values.data_type(),
+                    DataType::Binary | DataType::LargeBinary
+                ));
+                self.find_inner::<OP, GenericBinaryType<O>>(values, 
observe_payload_fn)
+            }
+            OutputType::Utf8 => {
+                assert!(matches!(
+                    values.data_type(),
+                    DataType::Utf8 | DataType::LargeUtf8
+                ));
+                self.find_inner::<OP, GenericStringType<O>>(values, 
observe_payload_fn)
+            }
+            _ => unreachable!("View types should use `ArrowBytesViewMap`"),
+        }
+    }
+
+    /// Generic version of [`Self::find`] that handles `ByteArrayType`
+    fn find_inner<OP, B>(&mut self, values: &ArrayRef, mut observe_payload_fn: 
OP)

Review Comment:
   Tried to extract the closure and had Claude run some microbenchmarks after 
on `intern`. It seems that extracting it into a separate function prevents LLVM 
from inlining the contents, which caused some significant perf regressions. I 
think probably worth handling as a follow-up.



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