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

Method GetOrInsert

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

Source from the content-addressed store, hash-verified

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