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

Method GetOrInsert

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

Source from the content-addressed store, hash-verified

439
440 template <typename Value, typename Func1, typename Func2>
441 Status GetOrInsert(Value&& v, Func1&& on_found, Func2&& on_not_found,
442 int32_t* out_memo_index) {
443 const Scalar value(std::forward<Value>(v));
444 auto cmp_func = [value](const Payload* payload) -> bool {
445 return ScalarHelper<Scalar, 0>::CompareScalars(value, payload->value);
446 };
447 hash_t h = ComputeHash(value);
448 auto p = hash_table_.Lookup(h, cmp_func);
449 int32_t memo_index;
450 if (p.second) {
451 memo_index = p.first->payload.memo_index;
452 on_found(memo_index);
453 } else {
454 memo_index = size();
455 RETURN_NOT_OK(hash_table_.Insert(p.first, h, {value, memo_index}));
456 on_not_found(memo_index);
457 }
458 *out_memo_index = memo_index;
459 return Status::OK();
460 }
461
462 template <typename Value>
463 Status GetOrInsert(Value&& value, int32_t* out_memo_index) {

Callers 3

MergeTableMethod · 0.95
AssertGetOrInsertFunction · 0.45
TESTFunction · 0.45

Calls 5

GetOrInsertFunction · 0.85
sizeFunction · 0.50
OKFunction · 0.50
LookupMethod · 0.45
InsertMethod · 0.45

Tested by 2

AssertGetOrInsertFunction · 0.36
TESTFunction · 0.36