From 13e5cc260cc7aac8446a4a8d9b52fff02d2e5a96 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 26 Nov 2024 11:11:01 +0100 Subject: [PATCH] Apply suggestion of using a regular method --- cpp/src/arrow/compute/kernels/vector_sort.cc | 9 +++------ .../arrow/compute/kernels/vector_sort_internal.h | 15 +++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/vector_sort.cc b/cpp/src/arrow/compute/kernels/vector_sort.cc index 9185bfb72477f..d81187837de7e 100644 --- a/cpp/src/arrow/compute/kernels/vector_sort.cc +++ b/cpp/src/arrow/compute/kernels/vector_sort.cc @@ -114,8 +114,7 @@ class ChunkedArraySorter : public TypeVisitor { std::vector chunk_sorted(num_chunks); for (int i = 0; i < num_chunks; ++i) { - chunk_sorted[i] = ChunkedNullPartitionResult::TranslateFrom( - sorted[i], indices_begin_, chunked_indices_begin); + chunk_sorted[i] = sorted[i].TranslateTo(indices_begin_, chunked_indices_begin); } auto merge_nulls = [&](CompressedChunkLocation* nulls_begin, @@ -158,8 +157,7 @@ class ChunkedArraySorter : public TypeVisitor { // Reverse everything sorted.resize(1); - sorted[0] = NullPartitionResult::TranslateFrom( - chunk_sorted[0], chunked_indices_begin, indices_begin_); + sorted[0] = chunk_sorted[0].TranslateTo(chunked_indices_begin, indices_begin_); RETURN_NOT_OK(chunked_mapper.PhysicalToLogical()); } @@ -706,8 +704,7 @@ class TableSorter { std::vector chunk_sorted(num_batches); for (int64_t i = 0; i < num_batches; ++i) { - chunk_sorted[i] = ChunkedNullPartitionResult::TranslateFrom( - sorted[i], indices_begin_, chunked_indices_begin); + chunk_sorted[i] = sorted[i].TranslateTo(indices_begin_, chunked_indices_begin); } struct Visitor { diff --git a/cpp/src/arrow/compute/kernels/vector_sort_internal.h b/cpp/src/arrow/compute/kernels/vector_sort_internal.h index e7ff870782c8a..97a2db1d11a8f 100644 --- a/cpp/src/arrow/compute/kernels/vector_sort_internal.h +++ b/cpp/src/arrow/compute/kernels/vector_sort_internal.h @@ -195,15 +195,14 @@ struct GenericNullPartitionResult { return {midpoint, indices_end, indices_begin, midpoint}; } - template - static GenericNullPartitionResult TranslateFrom( - GenericNullPartitionResult source, - SourceIndexType* source_indices_begin, IndexType* target_indices_begin) { + template + GenericNullPartitionResult TranslateTo( + IndexType* indices_begin, TargetIndexType* target_indices_begin) const { return { - (source.non_nulls_begin - source_indices_begin) + target_indices_begin, - (source.non_nulls_end - source_indices_begin) + target_indices_begin, - (source.nulls_begin - source_indices_begin) + target_indices_begin, - (source.nulls_end - source_indices_begin) + target_indices_begin, + (non_nulls_begin - indices_begin) + target_indices_begin, + (non_nulls_end - indices_begin) + target_indices_begin, + (nulls_begin - indices_begin) + target_indices_begin, + (nulls_end - indices_begin) + target_indices_begin, }; } };