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

Method Rank

cpp/src/arrow/compute/kernels/vector_rank.cc:346–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344 protected:
345 template <typename T>
346 Result<Datum> Rank(const T& input, const FunctionOptions& function_options,
347 ExecContext* ctx) const {
348 const auto& options =
349 checked_cast<const typename Derived::FunctionOptionsType&>(function_options);
350
351 SortOrder order = SortOrder::Ascending;
352 NullPlacement null_placement = NullPlacement::AtEnd;
353 if (!options.sort_keys.empty()) {
354 order = options.sort_keys[0].order;
355 null_placement = options.sort_keys[0].null_placement;
356 }
357 ARROW_SUPPRESS_DEPRECATION_WARNING
358 if (options.null_placement.has_value()) {
359 null_placement = options.null_placement.value();
360 }
361 ARROW_UNSUPPRESS_DEPRECATION_WARNING
362
363 int64_t length = input.length();
364 ARROW_ASSIGN_OR_RAISE(auto indices,
365 MakeMutableUInt64Array(length, ctx->memory_pool()));
366 std::span<uint64_t> indices_span{indices->GetMutableValues<uint64_t>(1),
367 static_cast<size_t>(length)};
368 std::iota(indices_span.begin(), indices_span.end(), 0);
369 auto needs_duplicates = Derived::NeedsDuplicates(options);
370 ARROW_ASSIGN_OR_RAISE(
371 auto sorted, SortAndMarkDuplicate(ctx, indices_span, input, order, null_placement,
372 needs_duplicates)
373 .Run());
374
375 auto ranker = Derived::GetRanker(options);
376 return ranker.CreateRankings(ctx, sorted);
377 }
378};
379
380class RankMetaFunction : public RankMetaFunctionBase<RankMetaFunction> {

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.45
valueMethod · 0.45
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
CreateRankingsMethod · 0.45

Tested by

no test coverage detected