| 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 |
nothing calls this directly
no test coverage detected