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

Function PartitionNans

cpp/src/arrow/compute/kernels/vector_sort_internal.h:260–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258// `offset` is used when this is called on a chunk of a chunked array
259template <typename ArrayType, typename Partitioner>
260NanPartition PartitionNans(std::span<uint64_t> indices, const ArrayType& values,
261 int64_t offset, NullPlacement null_placement) {
262 using TypeClass = typename ArrayType::TypeClass;
263 if constexpr (has_null_like_values<TypeClass>()) {
264 Partitioner partitioner;
265 if (null_placement == NullPlacement::AtStart) {
266 auto non_null_like_tail = partitioner(indices, [&values, &offset](uint64_t ind) {
267 const auto value = GetViewType<TypeClass>::LogicalValue(
268 values.GetView(static_cast<int64_t>(ind) - offset));
269 return is_null_like<TypeClass>(value);
270 });
271 return NanPartition{.non_null_like_range = non_null_like_tail,
272 .nan_range = {indices.data(), non_null_like_tail.data()}};
273 } else {
274 auto nan_tail = partitioner(indices, [&values, &offset](uint64_t ind) {
275 const auto value = GetViewType<TypeClass>::LogicalValue(
276 values.GetView(static_cast<int64_t>(ind) - offset));
277 return !is_null_like<TypeClass>(value);
278 });
279 return NanPartition{.non_null_like_range = {indices.data(), nan_tail.data()},
280 .nan_range = nan_tail};
281 }
282 } else {
283 if (null_placement == NullPlacement::AtStart) {
284 return NanPartition{.non_null_like_range = indices,
285 .nan_range = {indices.data(), indices.data()}};
286 } else {
287 return NanPartition{.non_null_like_range = indices,
288 .nan_range = indices.subspan(indices.size())};
289 }
290 }
291}
292
293template <typename ArrayType, typename Partitioner>
294NullLikePartition PartitionNullsAndNans(std::span<uint64_t> indices,

Callers

nothing calls this directly

Calls 3

GetViewMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected