zanmato1984 commented on code in PR #55169:
URL: https://github.com/apache/arrow/pull/55169#discussion_r4446599517
##########
cpp/src/arrow/compute/kernels/vector_swizzle.cc:
##########
@@ -296,28 +362,37 @@ struct InversePermutationChunked {
}
};
+template <typename Ignored, typename Type>
+using UnsignedInversePermutation = InversePermutation<Ignored,
UnsignedIntegerType<Type>>;
+
+template <typename Ignored, typename Type>
+using UnsignedInversePermutationChunked =
+ InversePermutationChunked<Ignored, UnsignedIntegerType<Type>>;
+
void RegisterVectorInversePermutation(FunctionRegistry* registry) {
auto function = std::make_shared<VectorFunction>("inverse_permutation",
Arity::Unary(),
inverse_permutation_doc,
GetDefaultInversePermutationOptions());
- auto add_kernel = [&function](Type::type type_id) {
- VectorKernel kernel;
- kernel.signature =
- KernelSignature::Make({InputType(match::SameTypeId(type_id))},
- OutputType(ResolveInversePermutationOutputType));
- kernel.init = InversePermutationState::Init;
- kernel.exec = GenerateInteger<InversePermutation, void,
ArrayKernelExec>(type_id);
- kernel.exec_chunked =
- GenerateInteger<InversePermutationChunked, void,
VectorKernel::ChunkedExec>(
- type_id);
- kernel.can_execute_chunkwise = false;
- kernel.output_chunked = false;
- DCHECK_OK(function->AddKernel(std::move(kernel)));
+ // Exact dispatch scans every kernel. Match integers once, then select the
+ // shared physical implementation without increasing per-call matching costs.
+ VectorKernel kernel;
+ kernel.signature = KernelSignature::Make(
+ {InputType(match::Integer())},
OutputType(ResolveInversePermutationOutputType));
+ kernel.init = InversePermutationState::Init;
+ kernel.exec = [](KernelContext* ctx, const ExecSpan& span, ExecResult*
result) {
+ const auto exec = GenerateInteger<UnsignedInversePermutation, void,
ArrayKernelExec>(
Review Comment:
Rebased onto main and switched both the array and chunked dispatch paths to
`GenerateKernelExec` with `TypeIdToUnsigned`, removing the local adapters.
--
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]