github-actions[bot] commented on code in PR #25493:
URL: https://github.com/apache/doris/pull/25493#discussion_r1360646012
##########
be/src/vec/common/hash_table/hash_map.h:
##########
@@ -193,10 +195,83 @@ 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);
+ next.resize(num_elem + 1, 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;
Review Comment:
warning: 7 is a magic number; consider replacing it with a named constant
[readability-magic-numbers]
```cpp
size_t expect_bucket_size = static_cast<size_t>(num_elem) +
(num_elem - 1) / 7;
^
```
##########
be/src/vec/common/hash_table/hash_map.h:
##########
@@ -193,10 +195,83 @@
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);
+ next.resize(num_elem + 1, 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(std::span<Key> keys) {
+ build_keys = keys;
+ const auto num_elem = keys.size();
+ for (size_t i = 1; i < num_elem; i++) {
+ uint32_t bucket_num = Base::hash(keys[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(Key* __restrict keys, const size_t* __restrict hash_values, int
probe_idx, int n,
+ std::vector<uint32_t>& probe_idxs, std::vector<int>& build_idxs)
{
+ auto matched_cnt = 0;
+ while (probe_idx < n && 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 < n && 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]