MCPcopy Create free account
hub / github.com/apache/impala / Insert

Method Insert

be/src/util/cache/cache-test.h:76–87  ·  view source on GitHub ↗

Insert a key with the give value and charge. Return whether the insert was successful.

Source from the content-addressed store, hash-verified

74 // Insert a key with the give value and charge. Return whether the insert was
75 // successful.
76 bool Insert(int key, int value, int charge = 1) {
77 std::string key_str = EncodeInt(key);
78 std::string val_str = EncodeInt(value);
79 auto handle(cache_->Allocate(key_str, val_str.size(), charge));
80 // This can be null if Allocate rejects something with this charge.
81 if (handle == nullptr) return false;
82 memcpy(cache_->MutableValue(&handle), val_str.data(), val_str.size());
83 auto inserted_handle(cache_->Insert(std::move(handle), this));
84 // Insert can fail and return nullptr
85 if (inserted_handle == nullptr) return false;
86 return true;
87 }
88
89 void Erase(int key) {
90 cache_->Erase(EncodeInt(key));

Callers

nothing calls this directly

Calls 6

moveFunction · 0.85
EncodeIntFunction · 0.70
AllocateMethod · 0.45
sizeMethod · 0.45
MutableValueMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected