zanmato1984 commented on code in PR #44394:
URL: https://github.com/apache/arrow/pull/44394#discussion_r1879217436


##########
cpp/src/arrow/compute/api_vector.h:
##########
@@ -705,5 +737,52 @@ Result<std::shared_ptr<Array>> PairwiseDiff(const Array& 
array,
                                             bool check_overflow = false,
                                             ExecContext* ctx = NULLPTR);
 
+/// \brief Return the inverse permutation of the given indices.
+///
+/// For indices[i] = x, inverse_permutation[x] = i. And inverse_permutation[x] 
= null if x
+/// does not appear in the input indices. For indices[i] = x where x < 0 or x 
> max_index,
+/// it is ignored. If multiple indices point to the same value, the last one 
is used.
+///
+/// For example, with indices = [null, 0, 3, 2, 4, 1, 1], the inverse 
permutation is
+///   [1, 6, 3]                    if max_index = 2,
+///   [1, 6, 3, 2, 4, null, null]  if max_index = 6.
+///
+/// \param[in] indices array-like indices
+/// \param[in] options configures the max index and the output type
+/// \param[in] ctx the function execution context, optional
+/// \return the resulting inverse permutation
+///
+/// \since 19.0.0
+/// \note API not yet finalized
+ARROW_EXPORT
+Result<Datum> InversePermutation(
+    const Datum& indices,
+    const InversePermutationOptions& options = 
InversePermutationOptions::Defaults(),
+    ExecContext* ctx = NULLPTR);
+
+/// \brief Scatter the values into specified positions according to the 
indices.
+///
+/// For indices[i] = x, output[x] = values[i]. And output[x] = null if x does 
not appear
+/// in the input indices. For indices[i] = x where x < 0 or x > max_index, 
values[i]
+/// is ignored. If multiple indices point to the same value, the last one is 
used.

Review Comment:
   OK. This is quite reasonable. I'll update.



-- 
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...@arrow.apache.org

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

Reply via email to