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