hqx871 commented on PR #21435:
URL: https://github.com/apache/doris/pull/21435#issuecomment-1619541478
> “For LRUHandle, all fields should be put ahead of key_data.” why? Is there
anything wrong if we keep the previous order? @hqx871
The LRUHandle is allocated using malloc and starting from field key_data is
for key data.
```
size_t handle_size = sizeof(LRUHandle) - 1 + key.size();
LRUHandle* e = reinterpret_cast<LRUHandle*>(malloc(handle_size));
e->value = value;
e->deleter = deleter;
e->charge = charge;
e->key_length = key.size();
e->total_size = (_type == LRUCacheType::SIZE ? handle_size + charge : 1);
DCHECK(_type == LRUCacheType::SIZE || bytes != -1) << " _type " << _type;
e->bytes = (_type == LRUCacheType::SIZE ? handle_size + charge :
handle_size + bytes);
e->hash = hash;
e->refs = 2; // one for the returned handle, one for LRUCache.
e->next = e->prev = nullptr;
e->in_cache = true;
e->priority = priority;
e->mem_tracker = tracker;
e->type = _type;
memcpy(e->key_data, key.data(), key.size());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]