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

Method Append

cpp/src/arrow/compute/kernels/vector_hash.cc:455–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453 Status Reset() override { return indices_kernel_->Reset(); }
454
455 Status Append(const ArraySpan& arr) override {
456 auto arr_dict = arr.dictionary().ToArray();
457 if (!first_dictionary_) {
458 first_dictionary_ = arr_dict;
459 } else if (!first_dictionary_->Equals(*arr_dict)) {
460 // NOTE: This approach computes a new dictionary unification per chunk.
461 // This is in effect O(n*k) where n is the total chunked array length and
462 // k is the number of chunks (therefore O(n**2) if chunks have a fixed size).
463 //
464 // A better approach may be to run the kernel over each individual chunk,
465 // and then hash-aggregate all results (for example sum-group-by for
466 // the "value_counts" kernel).
467 if (dictionary_unifier_ == nullptr) {
468 ARROW_ASSIGN_OR_RAISE(dictionary_unifier_,
469 DictionaryUnifier::Make(first_dictionary_->type()));
470 RETURN_NOT_OK(dictionary_unifier_->Unify(*first_dictionary_));
471 }
472 auto out_dict_type = first_dictionary_->type();
473 std::shared_ptr<Buffer> transpose_map;
474
475 RETURN_NOT_OK(dictionary_unifier_->Unify(*arr_dict, &transpose_map));
476
477 auto transpose = reinterpret_cast<const int32_t*>(transpose_map->data());
478 auto in_array = arr.ToArray();
479 const auto& in_dict_array =
480 arrow::internal::checked_cast<const DictionaryArray&>(*in_array);
481 ARROW_ASSIGN_OR_RAISE(
482 auto tmp, in_dict_array.Transpose(arr.type->GetSharedPtr(),
483 in_dict_array.dictionary(), transpose));
484 return indices_kernel_->Append(*tmp->data());
485 }
486
487 return indices_kernel_->Append(arr);
488 }
489
490 Status Flush(ExecResult* out) override { return indices_kernel_->Flush(out); }
491

Callers

nothing calls this directly

Calls 9

ARROW_ASSIGN_OR_RAISEFunction · 0.50
MakeFunction · 0.50
ToArrayMethod · 0.45
dictionaryMethod · 0.45
EqualsMethod · 0.45
typeMethod · 0.45
UnifyMethod · 0.45
dataMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected