General Hashtable optimization

Perfect Hash tabel initial implementation
Table caching
Bug fixesw
This commit is contained in:
2023-05-22 21:53:54 +08:00
parent d0f0b4fc56
commit f9205dc2a6
4 changed files with 115 additions and 26 deletions
+4 -2
View File
@@ -162,7 +162,9 @@ struct PerfectHashTable {
// }
template <typename ... Types, template <typename> class VT>
void construct(VT<Types>&... args) {
// std::enable_if_t<std::is_same_v<ValueType, bool>, void>
void
construct(VT<Types>&... args) { // construct a hash set
((this->n_cols = args.size), ...);
static_assert(
(sizeof...(Types) < PerfectHashingThreshold) &&
@@ -198,6 +200,6 @@ struct PerfectHashTable {
// problem: random memory access
}
// delete[] hash_values;
free(hash_values);
free(hash_values); // dispatch to gc
}
};
+9 -2
View File
@@ -505,9 +505,16 @@ public:
ht_base = static_cast<uint32_t *>(calloc(sz, sizeof(uint32_t)));
}
template<typename... Keys_t>
inline void hashtable_push_all(Keys_t& ... keys, uint32_t len) {
for(uint32_t i = 0; i < len; ++i)
reversemap[i] = ankerl::unordered_dense::set<Key, Hash>::hashtable_push(keys[i]...);
for(uint32_t i = 0; i < len; ++i)
++ht_base[reversemap[i]];
}
inline void hashtable_push(Key&& k, uint32_t i){
reversemap[i] = ankerl::unordered_dense::set<Key, Hash>::hashtable_push(std::move(k));
++ht_base[reversemap[i]];
reversemap[i] = ankerl::unordered_dense::set<Key, Hash>::hashtable_push(k);
++ht_base[reversemap[i]]; // do this seperately?
}
auto ht_postproc(uint32_t sz) {