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

Method Exec

cpp/src/arrow/compute/kernels/vector_array_sort.cc:59–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 using ArrayType = typename TypeTraits<InType>::ArrayType;
58
59 static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) {
60 using GetView = GetViewType<InType>;
61
62 if (ctx->state() == nullptr) {
63 return Status::Invalid("NthToIndices requires PartitionNthOptions");
64 }
65 const auto& options = PartitionNthToIndicesState::Get(ctx);
66
67 ArrayType arr(batch[0].array.ToArrayData());
68
69 const int64_t pivot = options.pivot;
70 if (pivot > arr.length()) {
71 return Status::IndexError("NthToIndices index out of bound");
72 }
73 ArrayData* out_arr = out->array_data().get();
74 std::span<uint64_t> out_span{out_arr->GetMutableValues<uint64_t>(1),
75 static_cast<size_t>(arr.length())};
76 std::iota(out_span.begin(), out_span.end(), 0);
77 if (pivot == arr.length()) {
78 return Status::OK();
79 }
80 const auto p = PartitionNullsAndNans<ArrayType, NonStablePartitioner>(
81 out_span, arr, 0, options.null_placement);
82 auto nth_begin = out_span.data() + pivot;
83 auto non_null_begin = p.non_null_like_begin();
84 auto non_null_end = p.non_null_like_end();
85 if (nth_begin >= non_null_begin && nth_begin < non_null_end) {
86 std::nth_element(non_null_begin, nth_begin, non_null_end,
87 [&arr](uint64_t left, uint64_t right) {
88 const auto lval = GetView::LogicalValue(arr.GetView(left));
89 const auto rval = GetView::LogicalValue(arr.GetView(right));
90 return lval < rval;
91 });
92 }
93 return Status::OK();
94 }
95};
96
97template <typename OutType>

Callers

nothing calls this directly

Calls 15

IndexErrorFunction · 0.85
ToArrayDataMethod · 0.80
array_dataMethod · 0.80
non_null_like_beginMethod · 0.80
non_null_like_endMethod · 0.80
InvalidFunction · 0.50
GetFunction · 0.50
OKFunction · 0.50
stateMethod · 0.45
lengthMethod · 0.45
getMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected