github-actions[bot] commented on code in PR #25493: URL: https://github.com/apache/doris/pull/25493#discussion_r1361616411
########## be/src/vec/common/hash_table/hash_map.h: ########## @@ -193,10 +195,82 @@ class HashMapTable : public HashTable<Key, Cell, Hash, Grower, Allocator> { bool has_null_key_data() const { return false; } }; +template <typename Key, typename Cell, typename Hash = DefaultHash<Key>, + typename Grower = HashTableGrower<>, typename Allocator = HashTableAllocator> +class JoinHashMapTable : public HashMapTable<Key, Cell, Hash, Grower, Allocator> { +public: + using Self = JoinHashMapTable; + using Base = HashMapTable<Key, Cell, Hash, Grower, Allocator>; + + using key_type = Key; + using value_type = typename Cell::value_type; + using mapped_type = typename Cell::Mapped; + + using LookupResult = typename Base::LookupResult; + + using HashMapTable<Key, Cell, Hash, Grower, Allocator>::HashMapTable; + + void expanse_for_add_elem(size_t num_elem) { + bucket_size = calc_bucket_size(num_elem + 1); + first.resize(bucket_size, 0); + } + + static uint32_t calc_bucket_size(size_t num_elem) { + size_t expect_bucket_size = static_cast<size_t>(num_elem) + (num_elem - 1) / 7; + return phmap::priv::NormalizeCapacity(expect_bucket_size) + 1; + } + + void build(const Key* __restrict keys, const size_t* __restrict hash_values, int num_elem) { + build_keys = keys; + next.resize(num_elem); + for (size_t i = 1; i < num_elem; i++) { + uint32_t bucket_num = hash_values[i] & (bucket_size - 1); + next[i] = first[bucket_num]; + first[bucket_num] = i; + } + } + + uint32_t bucket_num(const Key& key) const { return Base::hash(key) & (bucket_size - 1); } + + LookupResult ALWAYS_INLINE find(Key key) { return Base::find(key); } + LookupResult ALWAYS_INLINE find(Key x, size_t hash_value) { return Base::find(x, hash_value); } + + auto find_batch(const Key* __restrict keys, const size_t* __restrict hash_values, int probe_idx, + int probe_rows, std::vector<uint32_t>& probe_idxs, + std::vector<int>& build_idxs) { + auto matched_cnt = 0; + while (probe_idx < probe_rows && matched_cnt < 4096) { Review Comment: warning: 4096 is a magic number; consider replacing it with a named constant [readability-magic-numbers] ```cpp while (probe_idx < probe_rows && matched_cnt < 4096) { ^ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org