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

Method GetOrInsert

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

Source from the content-addressed store, hash-verified

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