Nathan-Fenner commented on code in PR #5086:
URL: https://github.com/apache/arrow-rs/pull/5086#discussion_r1397682541


##########
arrow-select/src/zip.rs:
##########
@@ -29,19 +29,39 @@ use arrow_schema::ArrowError;
 /// * `falsy` - Values of this array are taken if mask evaluates `false`
 pub fn zip(
     mask: &BooleanArray,
-    truthy: &dyn Array,
-    falsy: &dyn Array,
+    truthy: impl Datum,

Review Comment:
   Ah, I see, that makes sense. How about splitting like this:
   
   ```rs
   #[inline(always)]
   pub fn zip(
     mask: &BooleanArray,
     truthy: impl Datum,
     falsy: impl Datum,
   ) -> Result<ArrayRef, ArrowError> {
     zip_impl(mask, truthy.get(), falsy.get())
   }
   
   /// This version is dynamic, to avoid duplicated code-gen
   fn zip_impl(
     mask: &BooleanArray,
     truthy: (&dyn Array, bool),
     falsy: (&dyn Array, bool),
   ) -> Result<ArrayRef, ArrowError> {
     /* Impl goes here */
   }
   ```
   
   This way the call to `.get()` should always get inlined, avoiding the 
overhead of re-wrapping any arrays as `&dyn Datum`, but the body of the 
computation remains monomorphic.
   
   I think this gives the best of both worlds.



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

Reply via email to