Comments (6)
ck_hs is better if you can derive the key from the object. For example,
struct poop {
int value;
char key[];
};
You can use container_of
like function to get from address of key to struct poop
container. You will get significantly better performance and let's difficult to use. ck_ht API was an experiment in "make it harder for developers to write non-performant hash table interaction", which ended up with something that most folks use wrong the first time.
You need to make sure:
- You are using consistent hash values, above looks suspect.
- Key length is less than CK_HT_KEY_LENGTH.
- Value of key is not 0 or ~0 (these are sentinels).
from ck.
If we run the loop again,
we will get remaining 49999 50633.
please find HashTable constructor below:
HashTable::HashTable(unsigned int a_ht_mode,Mode a_mode)
:mode_(a_mode)
{
ck_epoch_init(&epoch_ht);
ck_epoch_register(&epoch_ht, &epoch_wr);
common_srand48((long int)time(NULL));
if (ck_ht_init(&ht_,a_mode, ht_hash_wrapper, &allocator_, 8, common_lrand48())==false) {
perror("ck_ht_init");
exit(EXIT_FAILURE);
};
ck_spinlock_init(&writeLock_);
};
from ck.
@guijun It's easy to misuse ck_ht, unfortunately. Could you try ck_hs instead and report whether you see this problem?
It's hard for me to help you since I'm unsure how your C++ wrappers are interacting with things. Remember that ck_ht requires interaction with a ck_ht_entry object. ck_hs doesn't have this interface requirement, on the other hand.
from ck.
Hi, I'm sorry I don't know how to save k/v pair in ck_hs ...
And, please find wrapper below:
bool HashTable::Set(char* a_key, uint32_t a_keyLength, void* a_value)
{
ck_ht_hash_t hash{0};
ck_ht_entry_t entry;
ck_ht_hash(&hash,&ht_,a_key,a_keyLength);
ck_ht_entry_set(&entry,hash,a_key,a_keyLength,a_value);
switch(mode_)
{
case M_SPMC:
break;
case M_MPMC:
ck_spinlock_lock(&writeLock_);
break;
}
bool result=ck_ht_set_spmc(&ht_, hash, &entry);
switch(mode_)
{
case M_SPMC:
break;
case M_MPMC:
ck_spinlock_unlock(&writeLock_);
break;
}
if(result)
{
if(entry.key && entry.value)
{
int nothing=1;
}
else
{
int nothing=1;
}
if(eraseProc_)
{
eraseProc_((char*)ck_ht_entry_key(&entry),ck_ht_entry_key_length(&entry),ck_ht_entry_value(&entry));
};
}
else
{
int nothing=1;
}
return result;
};
from ck.
thanks . I'll try it asap
from ck.
@guijun Any updates on this? Otherwise, I'll close the ticket.
from ck.
Related Issues (20)
- which compiler version is okay to do the aarch64 cross compile? HOT 2
- ck_pr.h causes stringop-overread warning with GCC 11 HOT 1
- aff_iterate() fails on M1 macbooks
- custom configure script broken for cross-compilation HOT 2
- When is the next release of ConcurrencyKit? HOT 2
- How could we cross compile ck? HOT 5
- compilation: error: expected expression before 'struct' HOT 1
- Request: Add Support for Altering ABI Target When Building for riscv64 Platform HOT 1
- Compilation fails with -Werror=strict-aliasing HOT 3
- Missing man pages for newer fence types HOT 1
- MinGW64 (Git Bash) fails to parse ./configure generated directory names
- ck_ec test fails on 32-bit musl systems
- Can we get a stable 0.7.1 release? HOT 5
- When is the next stable release of ConcurrencyKit? HOT 2
- Makefile dependency errors
- Possible bug in ck_hp.c due to ck_hp_member_cache always returning NULL HOT 1
- patch to ck_sequence_write_begin & ck_sequence_write_end broke my code HOT 5
- Possible bug in `ck_rhs_t` on OOM. HOT 6
- site `http://concurrencykit.org/` is not accessible
- Question about ck_rhs_flush and memory ordering. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ck.