| 580 | |
| 581 | template <typename Func1, typename Func2> |
| 582 | Status GetOrInsert(const Scalar value, Func1&& on_found, Func2&& on_not_found, |
| 583 | int32_t* out_memo_index) { |
| 584 | auto value_index = AsIndex(value); |
| 585 | auto memo_index = value_to_index_[value_index]; |
| 586 | if (memo_index == kKeyNotFound) { |
| 587 | memo_index = static_cast<int32_t>(index_to_value_.size()); |
| 588 | index_to_value_.push_back(value); |
| 589 | value_to_index_[value_index] = memo_index; |
| 590 | ARROW_DCHECK_LT(memo_index, cardinality + 1); |
| 591 | on_not_found(memo_index); |
| 592 | } else { |
| 593 | on_found(memo_index); |
| 594 | } |
| 595 | *out_memo_index = memo_index; |
| 596 | return Status::OK(); |
| 597 | } |
| 598 | |
| 599 | Status GetOrInsert(const Scalar value, int32_t* out_memo_index) { |
| 600 | return GetOrInsert(value, [](int32_t i) {}, [](int32_t i) {}, out_memo_index); |
no test coverage detected