tencent / libwxfreq Goto Github PK
View Code? Open in Web Editor NEWlibwxfreq is a generic high performance frequency limitation library
License: Other
libwxfreq is a generic high performance frequency limitation library
License: Other
问题在如下注释:
`int MultiHashBase<Key, Value>::GetValueForWrite(const KeyType &input_key,
ValueType *&value) {
int ret = enMultiHashBucketFull;
ValueType * read_value_ptr;
ret = GetValueForRead(input_key, read_value_ptr);
if (ret == enMultiHashOK) {
value = read_value_ptr;
AfterFindWriteItem(*value);
return ret;
}
size_t offset = 0;
unsigned int find_level = 0;
ret = enMultiHashBucketFull;
size_t hash_key = HashKey(input_key);
for (find_level = 0; find_level < max_level_; find_level++) {
size_t index = hash_key % size_meta_[find_level];
KeyType* key_in_mem =
reinterpret_cast<KeyType >(shm_mem_base_ + offset + (item_size_ * index));
ValueType value_in_mem = reinterpret_cast<ValueType *>(
reinterpret_cast<char *>(key_in_mem) + sizeof(KeyType));
uint32_t timestamp = 0;
if (IsEmpty(*key_in_mem, *value_in_mem) == true) {
if (EmptyOccupy(input_key, *key_in_mem) == true) {
memset(reinterpret_cast<void *>(value_in_mem), 0 , sizeof(ValueType));
ret = enMultiHashOK;
value = value_in_mem;
break;
}
continue;
//不能占据位置时,continue会跳到下一层的level, 但offset没有更新计算, 这个continue会不会有问题?
} else if (IsExpired(*key_in_mem, *value_in_mem, ×tamp) == true) {
if (ExpiredOccupy(input_key, *key_in_mem, *value_in_mem, ×tamp) == true) {
memset(reinterpret_cast<void *>(value_in_mem), 0 , sizeof(ValueType));
ret = enMultiHashOK;
value = value_in_mem;
break;
}
continue;
//不能占据位置时,continue会跳到下一层的level, 但offset没有更新计算, 这个continue会不会有问题?
}
offset += size_meta_[find_level] * item_size_;
}
if (ret == enMultiHashOK) {
gLog("[%s][%d]: level %d hash %llu\n", FILE, LINE,
find_level, hash_key);
} else {
gLog("[%s][%d]: not found hash %llu\n", FILE, LINE, hash_key);
}
return ret;
}`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.