From bd334fe7b8aa657836eea45630330eb29132f66f Mon Sep 17 00:00:00 2001 From: Ruoxi Sun Date: Wed, 6 Nov 2024 14:50:15 +0800 Subject: [PATCH] Fixing some renamings --- cpp/src/arrow/compute/api_vector.h | 6 +++--- cpp/src/arrow/compute/kernels/vector_swizzle.cc | 5 ++--- docs/source/cpp/compute.rst | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cpp/src/arrow/compute/api_vector.h b/cpp/src/arrow/compute/api_vector.h index b53b4697f048a..c7dd4acef2ac1 100644 --- a/cpp/src/arrow/compute/api_vector.h +++ b/cpp/src/arrow/compute/api_vector.h @@ -266,8 +266,8 @@ class ARROW_EXPORT InversePermutationOptions : public FunctionOptions { static InversePermutationOptions Defaults() { return InversePermutationOptions(); } /// \brief The max value in the input indices to process. Any indices that are greater - /// to this length will be ignored. If negative, this value will be set to the length of - /// the input indices minus 1. + /// than this value will be ignored. If negative, this value will be set to the length + /// of the input indices minus 1. int64_t max_index = -1; /// \brief The type of the output inverse permutation. If null, the output will be of /// the same type as the input indices, otherwise must be integer types. An invalid @@ -284,7 +284,7 @@ class ARROW_EXPORT ScatterOptions : public FunctionOptions { static ScatterOptions Defaults() { return ScatterOptions(); } /// \brief The max value in the input indices to process. Any values with indices that - /// are greater to this length will be ignored. If negative, this value will be set to + /// are greater than this value will be ignored. If negative, this value will be set to /// the length of the input minus 1. int64_t max_index = -1; }; diff --git a/cpp/src/arrow/compute/kernels/vector_swizzle.cc b/cpp/src/arrow/compute/kernels/vector_swizzle.cc index 03330240d9f5d..3975e74dff9ea 100644 --- a/cpp/src/arrow/compute/kernels/vector_swizzle.cc +++ b/cpp/src/arrow/compute/kernels/vector_swizzle.cc @@ -123,8 +123,7 @@ struct InversePermutationImpl { // buffer is preallocated and filled with all "impossible" values (that is, // input_length - note that the range of inverse_permutation is [0, input_length)) for // the subsequent processing to detect validity. - bool likely_many_nulls = LikelyManyNulls(); - if (likely_many_nulls) { + if (LikelyManyNulls()) { RETURN_NOT_OK(AllocateValidityBufAndFill(false)); RETURN_NOT_OK(AllocateDataBuf(output_type)); return Execute(); @@ -158,7 +157,7 @@ struct InversePermutationImpl { ARROW_ASSIGN_OR_RAISE(validity_buf, ctx->AllocateBitmap(output_length)); auto validity = validity_buf->mutable_data_as(); - std::memset(validity, valid ? 0xff : 0, bit_util::BytesForBits(output_length)); + std::memset(validity, valid ? 0xff : 0, validity_buf->size()); return Status::OK(); } diff --git a/docs/source/cpp/compute.rst b/docs/source/cpp/compute.rst index 28c31f3e7de38..98c31669d8107 100644 --- a/docs/source/cpp/compute.rst +++ b/docs/source/cpp/compute.rst @@ -1902,7 +1902,7 @@ operation to the n-th and (n+abs(p))-th inputs. Swizzle functions ~~~~~~~~~~~~~~~~~~~ -Swizzle functions reorder the input array based on targeting indices. +Swizzle functions reorder the input array based on the specified indices. +---------------------+--------+--------------+--------------+--------------+-------------------------------------+-------+ | Function name | Arity | Input type 1 | Input type 2 | Output type | Options class | Notes | @@ -1916,10 +1916,10 @@ Swizzle functions reorder the input array based on targeting indices. * \(2) 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 >= output_length``, it is ignored. If multiple indices point + where ``x < 0`` or ``x > max_index``, it is ignored. If multiple indices point to the same value, the last one is used. * \(3) 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 >= output_length``, ``values[i]`` is ignored. If multiple indices +``x < 0`` or ``x > max_index``, ``values[i]`` is ignored. If multiple indices point to the same value, the last one is used.