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

Method Allocate

be/src/util/cache/lirs-cache.cc:865–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

863}
864
865HandleBase* LIRSCacheShard::Allocate(Slice key, uint32_t hash, int val_len,
866 size_t charge) {
867 DCHECK(initialized_);
868 int key_len = key.size();
869 DCHECK_GE(key_len, 0);
870 DCHECK_GE(val_len, 0);
871 DCHECK_GT(charge, 0);
872 if (charge == 0 || charge > protected_capacity_) {
873 return nullptr;
874 }
875 int key_len_padded = KUDU_ALIGN_UP(key_len, sizeof(void*));
876 uint8_t* buf = new uint8_t[sizeof(LIRSHandle)
877 + key_len_padded + val_len]; // the kv_data VLA data
878 int calc_charge =
879 (charge == Cache::kAutomaticCharge) ? kudu::kudu_malloc_usable_size(buf) : charge;
880 uint8_t* kv_ptr = buf + sizeof(LIRSHandle);
881 LIRSHandle* handle = new (buf) LIRSHandle(kv_ptr, key, hash, val_len,
882 calc_charge);
883 return handle;
884}
885
886void LIRSCacheShard::Free(HandleBase* handle) {
887 DCHECK(initialized_);

Callers

nothing calls this directly

Calls 2

kudu_malloc_usable_sizeFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected