Skip to content

Commit 13e5cc2

Browse files
committed
Apply suggestion of using a regular method
1 parent c85bb4c commit 13e5cc2

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

cpp/src/arrow/compute/kernels/vector_sort.cc

+3-6
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ class ChunkedArraySorter : public TypeVisitor {
114114

115115
std::vector<ChunkedNullPartitionResult> chunk_sorted(num_chunks);
116116
for (int i = 0; i < num_chunks; ++i) {
117-
chunk_sorted[i] = ChunkedNullPartitionResult::TranslateFrom(
118-
sorted[i], indices_begin_, chunked_indices_begin);
117+
chunk_sorted[i] = sorted[i].TranslateTo(indices_begin_, chunked_indices_begin);
119118
}
120119

121120
auto merge_nulls = [&](CompressedChunkLocation* nulls_begin,
@@ -158,8 +157,7 @@ class ChunkedArraySorter : public TypeVisitor {
158157

159158
// Reverse everything
160159
sorted.resize(1);
161-
sorted[0] = NullPartitionResult::TranslateFrom(
162-
chunk_sorted[0], chunked_indices_begin, indices_begin_);
160+
sorted[0] = chunk_sorted[0].TranslateTo(chunked_indices_begin, indices_begin_);
163161

164162
RETURN_NOT_OK(chunked_mapper.PhysicalToLogical());
165163
}
@@ -706,8 +704,7 @@ class TableSorter {
706704

707705
std::vector<ChunkedNullPartitionResult> chunk_sorted(num_batches);
708706
for (int64_t i = 0; i < num_batches; ++i) {
709-
chunk_sorted[i] = ChunkedNullPartitionResult::TranslateFrom(
710-
sorted[i], indices_begin_, chunked_indices_begin);
707+
chunk_sorted[i] = sorted[i].TranslateTo(indices_begin_, chunked_indices_begin);
711708
}
712709

713710
struct Visitor {

cpp/src/arrow/compute/kernels/vector_sort_internal.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,14 @@ struct GenericNullPartitionResult {
195195
return {midpoint, indices_end, indices_begin, midpoint};
196196
}
197197

198-
template <typename SourceIndexType>
199-
static GenericNullPartitionResult TranslateFrom(
200-
GenericNullPartitionResult<SourceIndexType> source,
201-
SourceIndexType* source_indices_begin, IndexType* target_indices_begin) {
198+
template <typename TargetIndexType>
199+
GenericNullPartitionResult<TargetIndexType> TranslateTo(
200+
IndexType* indices_begin, TargetIndexType* target_indices_begin) const {
202201
return {
203-
(source.non_nulls_begin - source_indices_begin) + target_indices_begin,
204-
(source.non_nulls_end - source_indices_begin) + target_indices_begin,
205-
(source.nulls_begin - source_indices_begin) + target_indices_begin,
206-
(source.nulls_end - source_indices_begin) + target_indices_begin,
202+
(non_nulls_begin - indices_begin) + target_indices_begin,
203+
(non_nulls_end - indices_begin) + target_indices_begin,
204+
(nulls_begin - indices_begin) + target_indices_begin,
205+
(nulls_end - indices_begin) + target_indices_begin,
207206
};
208207
}
209208
};

0 commit comments

Comments
 (0)