Skip to content

Commit

Permalink
[Chore](hash-table) remove some unused code of PartitionedHashMap (ap…
Browse files Browse the repository at this point in the history
…ache#43215)

remove some unused code of PartitionedHashMap
  • Loading branch information
BiteTheDDDDt authored Nov 5, 2024
1 parent 9d45269 commit 17df7d5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 698 deletions.
3 changes: 0 additions & 3 deletions be/src/vec/common/hash_table/hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ template <typename Key, typename Mapped, typename Hash = DefaultHash<Key>,
typename Grower = HashTableGrower<>, typename Allocator = HashTableAllocator>
using HashMap = HashMapTable<Key, HashMapCell<Key, Mapped, Hash>, Hash, Grower, Allocator>;

template <typename Key, typename Mapped, typename Hash = DefaultHash<Key>>
using NormalHashMap = HashMapTable<Key, HashMapCell<Key, Mapped, Hash>, Hash>;

template <typename Key, typename Hash = DefaultHash<Key>>
using JoinHashMap = JoinHashTable<Key, Hash>;

Expand Down
1 change: 0 additions & 1 deletion be/src/vec/common/hash_table/hash_map_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "vec/common/arena.h"
#include "vec/common/assert_cast.h"
#include "vec/common/columns_hashing.h"
#include "vec/common/hash_table/partitioned_hash_map.h"
#include "vec/common/hash_table/string_hash_map.h"
#include "vec/common/string_ref.h"
#include "vec/common/typeid_cast.h"
Expand Down
45 changes: 8 additions & 37 deletions be/src/vec/common/hash_table/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,28 +419,12 @@ class HashTable : private boost::noncopyable,
Cell* buf = nullptr; /// A piece of memory for all elements except the element with zero key.
Grower grower;
int64_t _resize_timer_ns;
// the bucket count threshold above which it's converted to partioned hash table
// > 0: enable convert dynamically
// 0: convert is disabled
int _partitioned_threshold = 0;
// if need resize and bucket count after resize will be >= _partitioned_threshold,
// this flag is set to true, and resize does not actually happen,
// PartitionedHashTable will convert this hash table to partitioned hash table
bool _need_partition = false;

//factor that will trigger growing the hash table on insert.
static constexpr float MAX_BUCKET_OCCUPANCY_FRACTION = 0.5f;

mutable size_t collisions = 0;

void set_partitioned_threshold(int threshold) { _partitioned_threshold = threshold; }

bool check_if_need_partition(size_t bucket_count) {
return _partitioned_threshold > 0 && bucket_count >= _partitioned_threshold;
}

bool need_partition() { return _need_partition; }

/// Find a cell with the same key or an empty cell, starting from the specified position and further along the collision resolution chain.
size_t ALWAYS_INLINE find_cell(const Key& x, size_t hash_value, size_t place_value) const {
while (!buf[place_value].is_zero(*this) &&
Expand Down Expand Up @@ -609,8 +593,6 @@ class HashTable : private boost::noncopyable,
std::swap(buf, rhs.buf);
std::swap(m_size, rhs.m_size);
std::swap(grower, rhs.grower);
std::swap(_need_partition, rhs._need_partition);
std::swap(_partitioned_threshold, rhs._partitioned_threshold);

Hash::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
Allocator::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
Expand Down Expand Up @@ -740,12 +722,10 @@ class HashTable : private boost::noncopyable,
throw;
}

if (LIKELY(!_need_partition)) {
// The hash table was rehashed, so we have to re-find the key.
size_t new_place = find_cell(key, hash_value, grower.place(hash_value));
assert(!buf[new_place].is_zero(*this));
it = &buf[new_place];
}
// The hash table was rehashed, so we have to re-find the key.
size_t new_place = find_cell(key, hash_value, grower.place(hash_value));
assert(!buf[new_place].is_zero(*this));
it = &buf[new_place];
}
}

Expand Down Expand Up @@ -776,12 +756,10 @@ class HashTable : private boost::noncopyable,
throw;
}

if (LIKELY(!_need_partition)) {
// The hash table was rehashed, so we have to re-find the key.
size_t new_place = find_cell(key, hash_value, grower.place(hash_value));
assert(!buf[new_place].is_zero(*this));
it = &buf[new_place];
}
// The hash table was rehashed, so we have to re-find the key.
size_t new_place = find_cell(key, hash_value, grower.place(hash_value));
assert(!buf[new_place].is_zero(*this));
it = &buf[new_place];
}
}

Expand Down Expand Up @@ -1060,13 +1038,6 @@ class HashTable : private boost::noncopyable,
} else
new_grower.increase_size();

// new bucket count exceed partitioned hash table bucket count threshold,
// don't resize and set need partition flag
if (check_if_need_partition(new_grower.buf_size())) {
_need_partition = true;
return;
}

/// Expand the space.
buf = reinterpret_cast<Cell*>(Allocator::realloc(buf, get_buffer_size_in_bytes(),
new_grower.buf_size() * sizeof(Cell)));
Expand Down
60 changes: 0 additions & 60 deletions be/src/vec/common/hash_table/partitioned_hash_map.h

This file was deleted.

Loading

0 comments on commit 17df7d5

Please sign in to comment.