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

Method GetOrInsert

cpp/src/arrow/util/hashing.h:582–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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);

Callers 1

MergeTableMethod · 0.95

Calls 4

GetOrInsertFunction · 0.85
push_backMethod · 0.80
OKFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected