Dandandan commented on a change in pull request #9301:
URL: https://github.com/apache/arrow/pull/9301#discussion_r563171151



##########
File path: rust/arrow/src/compute/kernels/take.rs
##########
@@ -269,64 +417,44 @@ fn take_primitive<T, I>(
 ) -> Result<PrimitiveArray<T>>
 where
     T: ArrowPrimitiveType,
-    T::Native: num::Num,
     I: ArrowNumericType,
     I::Native: ToPrimitive,
 {
-    let data_len = indices.len();
-
-    let mut buffer =
-        MutableBuffer::from_len_zeroed(data_len * 
std::mem::size_of::<T::Native>());
-    let data = buffer.typed_data_mut();
-
-    let nulls;
-
-    if values.null_count() == 0 {
-        // Take indices without null checking
-        for (i, elem) in data.iter_mut().enumerate() {
-            let index = ToPrimitive::to_usize(&indices.value(i)).ok_or_else(|| 
{
-                ArrowError::ComputeError("Cast to usize failed".to_string())
-            })?;
-
-            *elem = values.value(index);
+    let indices_has_nulls = indices.null_count() != 0;

Review comment:
       `> 0` might be slightly more clear here?




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

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


Reply via email to