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

Method MergeNonNulls

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

Source from the content-addressed store, hash-verified

835 //
836 template <typename ArrowType>
837 enable_if_t<!is_null_type<ArrowType>::value> MergeNonNulls(
838 CompressedChunkLocation* range_begin, CompressedChunkLocation* range_middle,
839 CompressedChunkLocation* range_end, CompressedChunkLocation* temp_indices) {
840 auto& comparator = comparator_;
841 const auto& first_sort_key = sort_keys_[0];
842
843 std::merge(range_begin, range_middle, range_middle, range_end, temp_indices,
844 [&](CompressedChunkLocation left, CompressedChunkLocation right) {
845 // Both values are never null nor NaN.
846 const auto left_loc = ChunkLocation{left};
847 const auto right_loc = ChunkLocation{right};
848 auto chunk_left = first_sort_key.GetChunk(left_loc);
849 auto chunk_right = first_sort_key.GetChunk(right_loc);
850 DCHECK(!chunk_left.IsNull());
851 DCHECK(!chunk_right.IsNull());
852 const auto value_left = chunk_left.Value<ArrowType>();
853 const auto value_right = chunk_right.Value<ArrowType>();
854 if (value_left == value_right) {
855 // If the left value equals to the right value,
856 // we need to compare the second and following
857 // sort keys.
858 return comparator.Compare(left_loc, right_loc, 1);
859 } else {
860 auto compared = value_left < value_right;
861 if (first_sort_key.order == SortOrder::Ascending) {
862 return compared;
863 } else {
864 return !compared;
865 }
866 }
867 });
868
869 // Copy back temp area into main buffer
870 std::copy(temp_indices, temp_indices + (range_end - range_begin), range_begin);
871 }
872
873 template <typename ArrowType>
874 enable_if_null<ArrowType> MergeNonNulls(CompressedChunkLocation* range_begin,

Callers

nothing calls this directly

Calls 3

GetChunkMethod · 0.45
IsNullMethod · 0.45
CompareMethod · 0.45

Tested by

no test coverage detected