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

utils/hash/murmur2_hash.hpp compiler error #9

Closed xanderdunn closed 3 years ago

xanderdunn commented 3 years ago

Ubuntu 18.04. clang++ 12.0.1.

In my project I add #include "utils/hash/murmur2_hash.hpp" and I see this error at compile time:

/home/xander/dev/my_model/../growt/utils/hash/murmur2_hash.hpp:75:31: error: member reference base
type 'const long' is not a structure or union
        return MurmurHash64A(k.data(), k.size(), seed);
                             ~^~~~~
/home/xander/dev/my_model/../growt/data-structures/base_linear.hpp:245:63: note: in instantiation o
f function template specialization 'utils_tm::hash_tm::murmur2_hash::operator()<long>' requested here
    inline size_type h    (const key_type & k) const { return _hash(k); }
                                                              ^
/home/xander/dev/my_model/../growt/data-structures/base_linear.hpp:1189:23: note: in instantiation
of member function 'growt::base_linear<growt::base_linear_config<growt::complex_slot<long, std::shared_
ptr<ccmydata::MyBook>, true>, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllocator
<char, 128>, false, false, false>>::h' requested here
    size_type htemp = h(k);
                      ^
/home/xander/dev/my_model/../growt/data-structures/base_linear.hpp:1071:24: note: in instantiation
of member function 'growt::base_linear<growt::base_linear_config<growt::complex_slot<long, std::shared_
ptr<ccmydata::MyBook>, true>, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllocator
<char, 128>, false, false, false>>::insert_unsafe' requested here
                target.insert_unsafe(curr);
                       ^
/home/xander/dev/my_model/../growt/data-structures/strategies/estrat_async.hpp:294:22: note: in ins
tantiation of member function 'growt::base_linear<growt::base_linear_config<growt::complex_slot<long, s
td::shared_ptr<ccmydata::MyBook>, true>, utils_tm::hash_tm::murmur2_hash, growt::GenericAlign
edAllocator<char, 128>, false, false, false>>::migrate' requested here
        n += source->migrate(*target, temp,
                     ^
/home/xander/dev/my_model/../growt/data-structures/strategies/estrat_async.hpp:269:5: note: in inst
antiation of member function 'growt::estrat_async<growt::migration_table_data<growt::migration_table<gr
owt::base_linear<growt::base_linear_config<growt::complex_slot<long, std::shared_ptr<ccmydata::MyBook>, true>, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllocator<char, 128>, false, fa
lse, false>>, workerstrat, exclstrat>>>::local_data_type::blockwise_migrate' requested here
    blockwise_migrate(curr, next);//,

The error is similar when I compile with g++ 10.3.0:

In file included from /home/xander/dev/my_model/../growt/utils/default_hash.hpp:41,                                 from /home/xander/dev/my_model/../growt/data-structures/base_linear.hpp:24,
                 from /home/xander/dev/my_model/../growt/data-structures/table_config.hpp:15,                       from /home/xander/dev/my_model/pymydata/pymydata/MyWebsocketClient.h:21,
                 from /home/xander/dev/my_model/pymydata/pymydata/DataFeed.cc:11:          /home/xander/dev/my_model/../growt/utils/hash/murmur2_hash.hpp: In instantiation of ‘uint64_t util$
_tm::hash_tm::murmur2_hash::operator()(const Type&) const [with Type = long int; uint64_t = long unsig$ed int]’:
/home/xander/dev/my_model/../growt/data-structures/base_linear.hpp:245:68:   required from ‘growt:$
base_linear<Config>::size_type growt::base_linear<Config>::h(const key_type&) const [with Config = gro$
t::base_linear_config<growt::complex_slot<long int, std::shared_ptr<ccmydata::MyBook>, true,
tbb::scalable_allocator<void> >, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllocator<char,
128>, false, false, false>; growt::base_linear<Config>::size_type = long unsigned int; growt::base_lin$
ar<Config>::key_type = long int]’
/home/xander/dev/my_model/../growt/data-structures/base_linear.hpp:825:23:   required from ‘growt:$
base_linear<Config>::iterator growt::base_linear<Config>::find(const key_type&) [with Config = growt::$
ase_linear_config<growt::complex_slot<long int, std::shared_ptr<ccmydata::MyBook>, true, tbb$
:scalable_allocator<void> >, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllocator<char, 128$
, false, false, false>; growt::base_linear<Config>::iterator = growt::base_linear_iterator<growt::base$
linear<growt::base_linear_config<growt::complex_slot<long int, std::shared_ptr<ccmydata::MyB$
ok>, true, tbb::scalable_allocator<void> >, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllo$
ator<char, 128>, false, false, false> >, false>; growt::base_linear<Config>::key_type = long int]’
/home/xander/dev/my_model/../growt/data-structures/migration_table.hpp:818:103:   required from ‘g$
owt::migration_table_handle< <template-parameter-1-1> >::iterator growt::migration_table_handle< <temp$
ate-parameter-1-1> >::find(const key_type&) [with migration_table_data = growt::migration_table_data<g$
owt::migration_table<growt::base_linear<growt::base_linear_config<growt::complex_slot<long int, std::s$
ared_ptr<ccmydata::MyBook>, true, tbb::scalable_allocator<void> >, utils_tm::hash_tm::murmur$
_hash, growt::GenericAlignedAllocator<char, 128>, false, false, false> >, growt::table_config<long int$
 std::shared_ptr<ccmydata::MyBook>, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAl$
ocator<char, 128>, hmod::growable, hmod::deletion>::workerstrat, growt::table_config<long int, std::sh$
red_ptr<ccmydata::MyBook>, utils_tm::hash_tm::murmur2_hash, growt::GenericAlignedAllocator<c$
ar, 128>, hmod::growable, hmod::deletion>::exclstrat> >; growt::migration_table_handle< <template-para$
eter-1-1> >::iterator = growt::migration_table_iterator<growt::migration_table_handle<growt::migration$
table_data<growt::migration_table<growt::base_linear<growt::base_linear_config<growt::complex_slot<lon$
 int, std::shared_ptr<ccmydata::MyBook>, true, tbb::scalable_allocator<void> >, utils_tm::ha$
h_tm::murmur2_hash, growt::GenericAlignedAllocator<char, 128>, false, false, false> >, growt::table_co$
fig<long int, std::shared_ptr<ccmydata::MyBook>, utils_tm::hash_tm::murmur2_hash, growt::Gene
ricAlignedAllocator<char, 128>, hmod::growable, hmod::deletion>::workerstrat, growt::table_config<long
int, std::shared_ptr<ccmydata::MyBook>, utils_tm::hash_tm::murmur2_hash, growt::GenericAligne
dAllocator<char, 128>, hmod::growable, hmod::deletion>::exclstrat> > >, false>; growt::migration_table_
handle< <template-parameter-1-1> >::key_type = long int]’
/home/xander/dev/my_model/pymydata/pymydata/MyWebsocketClient.h:105:32:   required from he
re
/home/xander/dev/my_model/../growt/utils/hash/murmur2_hash.hpp:75:32: error: request for member ‘da
ta’ in ‘k’, which is of non-class type ‘const long int’
   75 |         return MurmurHash64A(k.data(), k.size(), seed);
      |                              ~~^~~~
/home/xander/dev/my_model/../growt/utils/hash/murmur2_hash.hpp:75:42: error: request for member ‘si
ze’ in ‘k’, which is of non-class type ‘const long int’
   75 |         return MurmurHash64A(k.data(), k.size(), seed);
      |                                        ~~^~~~
TooBiased commented 3 years ago

Yes, the hash function objects in my utils library handle two cases of input-key-types. uint64_t and different variants of std::string (types with a .data() and .size() functions).

If you use any other type of key, you should implement your own hasher. I think the structure of the provided hashers should help you with your own implementations. I might at some point write a different adapter that is a little more general, but at the moment I don't have much time. You could try to use std::hash<...>, but the randomization capabilities might be bad.

xanderdunn commented 3 years ago

Thanks for the information