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

Method GetOrInsert

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

Source from the content-addressed store, hash-verified

689
690 template <typename Func1, typename Func2>
691 Status GetOrInsert(const void* data, builder_offset_type length, Func1&& on_found,
692 Func2&& on_not_found, int32_t* out_memo_index) {
693 hash_t h = ComputeStringHash<0>(data, length);
694 auto p = Lookup(h, data, length);
695 int32_t memo_index;
696 if (p.second) {
697 memo_index = p.first->payload.memo_index;
698 on_found(memo_index);
699 } else {
700 memo_index = size();
701 // Insert string value
702 RETURN_NOT_OK(binary_builder_.Append(static_cast<const char*>(data), length));
703 // Insert hash entry
704 RETURN_NOT_OK(
705 hash_table_.Insert(const_cast<HashTableEntry*>(p.first), h, {memo_index}));
706
707 on_not_found(memo_index);
708 }
709 *out_memo_index = memo_index;
710 return Status::OK();
711 }
712
713 template <typename Func1, typename Func2>
714 Status GetOrInsert(std::string_view value, Func1&& on_found, Func2&& on_not_found,

Callers 1

MergeTableMethod · 0.95

Calls 7

GetOrInsertFunction · 0.85
sizeFunction · 0.50
OKFunction · 0.50
AppendMethod · 0.45
InsertMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected