TooBiased / growt

This is a header only library offering a variety of dynamically growing concurrent hash tables. That all work by dynamically migrating the current table once it gets too full.
Other
107 stars 13 forks source link

find not working for 0 value and above 0xfffffffffffffff (15 bytes) #11

Open eligbr opened 3 years ago

eligbr commented 3 years ago

Hi, I am using

template<typename KeyType, typename ValueStorage>
using GrowtConcurrentHashtable = typename growt::table_config<KeyType, ValueStorage,
                                                              utils_tm::hash_tm::crc_hash, growt::AlignedAllocator<>,
                                                              hmod::growable>::table_type;

With KeyType=uint64_t ValueStorage=int8_t

When I insert value 0 or value above 0xfffffffffffffff and right after I call find with the value I get that the value is not present. I could not find the root cause for this, any idea what is wrong?

Thanks

TooBiased commented 3 years ago

Hi, yes indeed, 0 is always considered to be the empty key. The same should be true for 2^63 -1 (which is the deletion tombstone). However, large numbers should not be a problem as long as the most significant bit is not set, in the variant you are using that bit is used to mark migrated elements.

Can you try adding hmod::sync, this removes the need for a marking bit (and it should make 2^64-1 the new deletion tombstone).

eligbr commented 3 years ago

Thanks Tobias! So I understand that I should do some transformation on the values (adding +1 for example) and limit the range in order to work with 0 value.