| 350 | : pool_(pool), value_type_(std::move(value_type)), memo_table_(pool) {} |
| 351 | |
| 352 | Status Unify(const Array& dictionary, std::shared_ptr<Buffer>* out) override { |
| 353 | if (dictionary.null_count() > 0) { |
| 354 | return Status::Invalid("Cannot yet unify dictionaries with nulls"); |
| 355 | } |
| 356 | if (!dictionary.type()->Equals(*value_type_)) { |
| 357 | return Status::Invalid("Dictionary type different from unifier: ", |
| 358 | dictionary.type()->ToString()); |
| 359 | } |
| 360 | const ArrayType& values = checked_cast<const ArrayType&>(dictionary); |
| 361 | if (out != nullptr) { |
| 362 | ARROW_ASSIGN_OR_RAISE(auto result, |
| 363 | AllocateBuffer(dictionary.length() * sizeof(int32_t), pool_)); |
| 364 | auto result_raw = reinterpret_cast<int32_t*>(result->mutable_data()); |
| 365 | for (int64_t i = 0; i < values.length(); ++i) { |
| 366 | RETURN_NOT_OK(memo_table_.GetOrInsert(values.GetView(i), &result_raw[i])); |
| 367 | } |
| 368 | *out = std::move(result); |
| 369 | } else { |
| 370 | for (int64_t i = 0; i < values.length(); ++i) { |
| 371 | int32_t unused_memo_index; |
| 372 | RETURN_NOT_OK(memo_table_.GetOrInsert(values.GetView(i), &unused_memo_index)); |
| 373 | } |
| 374 | } |
| 375 | return Status::OK(); |
| 376 | } |
| 377 | |
| 378 | Status Unify(const Array& dictionary) override { return Unify(dictionary, nullptr); } |
| 379 |
nothing calls this directly
no test coverage detected