MCPcopy Create free account
hub / github.com/apache/arrow / MergeInternal

Method MergeInternal

cpp/src/arrow/compute/kernels/vector_sort.cc:747–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745 // Recursive merge routine, typed on the first sort key
746 template <typename ArrowType>
747 Status MergeInternal(std::vector<ChunkedNullPartitionResult>* sorted,
748 int64_t null_count) {
749 auto merge_nulls = [&](CompressedChunkLocation* nulls_begin,
750 CompressedChunkLocation* nulls_middle,
751 CompressedChunkLocation* nulls_end,
752 CompressedChunkLocation* temp_indices, int64_t null_count) {
753 MergeNulls<ArrowType>(nulls_begin, nulls_middle, nulls_end, temp_indices,
754 null_count);
755 };
756 auto merge_non_nulls =
757 [&](CompressedChunkLocation* range_begin, CompressedChunkLocation* range_middle,
758 CompressedChunkLocation* range_end, CompressedChunkLocation* temp_indices) {
759 MergeNonNulls<ArrowType>(range_begin, range_middle, range_end, temp_indices);
760 };
761
762 ChunkedMergeImpl merge_impl(options_.null_placement, std::move(merge_nulls),
763 std::move(merge_non_nulls));
764 RETURN_NOT_OK(merge_impl.Init(ctx_, table_.num_rows()));
765
766 while (sorted->size() > 1) {
767 auto out_it = sorted->begin();
768 auto it = sorted->begin();
769 while (it < sorted->end() - 1) {
770 const auto& left = *it++;
771 const auto& right = *it++;
772 DCHECK_EQ(left.overall_end(), right.overall_begin());
773 *out_it++ = merge_impl.Merge(left, right, null_count);
774 }
775 if (it < sorted->end()) {
776 *out_it++ = *it++;
777 }
778 sorted->erase(out_it, sorted->end());
779 }
780 return comparator_.status();
781 }
782
783 template <typename ArrowType>
784 void MergeNulls(CompressedChunkLocation* nulls_begin,

Callers

nothing calls this directly

Calls 9

overall_endMethod · 0.80
overall_beginMethod · 0.80
InitMethod · 0.45
num_rowsMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
MergeMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected