jhorstmann commented on a change in pull request #8722:
URL: https://github.com/apache/arrow/pull/8722#discussion_r528238296



##########
File path: rust/arrow/src/compute/kernels/sort.rs
##########
@@ -222,6 +224,106 @@ impl Default for SortOptions {
     }
 }
 
+#[cfg(feature = "avx512")]
+/// Sort primitive values
+fn sort_primitive<T>(
+    values: &ArrayRef,
+    value_indices: Vec<u32>,
+    null_indices: Vec<u32>,
+    nan_indices: Vec<u32>,
+    options: &SortOptions,
+) -> Result<UInt32Array>
+where
+    T: ArrowPrimitiveType,
+    T::Native: std::cmp::PartialOrd,
+{
+    let values = as_primitive_array::<T>(values);
+    let descending = options.descending;
+
+    let mut nulls = null_indices;
+    let mut nans = nan_indices;
+
+    let perm_exch_width = PERMUTE_EXCHANGE_WIDTH * 2;
+
+    let valids = if crate::util::bit_util::is_power_of_two(values.len())
+        && values.len() > perm_exch_width
+    {
+        let value_data = value_indices
+            .iter()
+            .copied()
+            .map(|e| e as i64)
+            .collect::<Vec<i64>>();
+        let value_data = unsafe {
+            if !descending {
+                avx512_vec_sort_i64(&value_data)
+            } else {
+                let mut d = avx512_vec_sort_i64(&value_data);
+                d.reverse();
+                nans.reverse();
+                nulls.reverse();
+                d
+            }
+        };
+        // create tuples after the actual sorting

Review comment:
       I must be missing something, but how does this work if the goal of the 
function is to sort the indices based on the values?




----------------------------------------------------------------
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:
[email protected]


Reply via email to