[Chore](hash-table) remove unused code about HashTableTraits (#26202)

remove unused code about HashTableTraits
This commit is contained in:
Pxl
2023-11-01 21:36:50 +08:00
committed by GitHub
parent 1018f8918c
commit d7ea4d31fb
7 changed files with 19 additions and 73 deletions

View File

@ -20,6 +20,7 @@
#include <type_traits>
#include <utility>
#include "common/compiler_util.h"
#include "runtime/descriptors.h"
#include "util/stack_util.h"
#include "vec/columns/column_nullable.h"
@ -85,6 +86,7 @@ struct MethodBase {
hash_values[k] = hash_table->hash(keys[k]);
}
}
void init_hash_values(size_t num_rows) {
hash_values.resize(num_rows);
for (size_t k = 0; k < num_rows; ++k) {
@ -93,21 +95,22 @@ struct MethodBase {
}
template <bool read>
void prefetch(int current) {
if (LIKELY(current + HASH_MAP_PREFETCH_DIST < hash_values.size())) {
hash_table->template prefetch<read>(keys[current + HASH_MAP_PREFETCH_DIST],
hash_values[current + HASH_MAP_PREFETCH_DIST]);
ALWAYS_INLINE void prefetch(size_t i) {
if (LIKELY(i + HASH_MAP_PREFETCH_DIST < hash_values.size())) {
hash_table->template prefetch<read>(keys[i + HASH_MAP_PREFETCH_DIST],
hash_values[i + HASH_MAP_PREFETCH_DIST]);
}
}
template <typename State>
auto find(State& state, size_t i) {
ALWAYS_INLINE auto find(State& state, size_t i) {
prefetch<true>(i);
return state.find_key_with_hash(*hash_table, hash_values[i], keys[i]);
}
template <typename State, typename F, typename FF>
auto& lazy_emplace(State& state, size_t i, F&& creator, FF&& creator_for_null_key) {
ALWAYS_INLINE auto& lazy_emplace(State& state, size_t i, F&& creator,
FF&& creator_for_null_key) {
prefetch<false>(i);
return state.lazy_emplace_key(*hash_table, i, keys[i], hash_values[i], creator,
creator_for_null_key);

View File

@ -1,26 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// This file is copied from
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/HashTable/HashTable.h
// and modified by Doris
#pragma once
template <typename T>
struct HashTableTraits {
static constexpr bool is_phmap = false;
};

View File

@ -55,18 +55,5 @@ template <typename Key, typename Mapped, typename Hash = DefaultHash<Key>>
using PartitionedHashMap =
PartitionedHashMapTable<HashMap<Key, Mapped, Hash, PartitionedHashTableGrower<>>>;
template <typename Key, typename Mapped, typename Hash = DefaultHash<Key>>
using PHPartitionedHashMap = PartitionedHashMapTable<PHHashMap<Key, Mapped, Hash, true>>;
template <typename Key, typename Mapped, typename Hash = DefaultHash<Key>>
using PHNormalHashMap = PHHashMap<Key, Mapped, Hash, false>;
template <typename Key, typename Mapped, typename Hash>
struct HashTableTraits<PHPartitionedHashMap<Key, Mapped, Hash>> {
static constexpr bool is_phmap = true;
};
template <template <typename> class Derived, typename Key, typename Mapped, typename Hash>
struct HashTableTraits<Derived<PHPartitionedHashMap<Key, Mapped, Hash>>> {
static constexpr bool is_phmap = true;
};

View File

@ -20,7 +20,6 @@
#pragma once
#include "vec/common/hash_table/hash_table.h"
#include "vec/common/hash_table/hash_table_utils.h"
/** Partitioned hash table.
* Represents 16 (or 1ULL << BITS_FOR_SUB_TABLE) small hash tables (sub table count of the first level).
@ -539,26 +538,17 @@ private:
auto it = level0_sub_table.begin();
if constexpr (HashTableTraits<Impl>::is_phmap) {
for (; it != level0_sub_table.end(); ++it) {
size_t hash_value = level0_sub_table.hash(it.get_first());
size_t sub_table_idx = get_sub_table_from_hash(hash_value);
level1_sub_tables[sub_table_idx].insert(it.get_first(), hash_value,
it.get_second());
}
} else {
/// It is assumed that the zero key (stored separately) is first in iteration order.
if (it != level0_sub_table.end() && it.get_ptr()->is_zero(level0_sub_table)) {
insert(it->get_value());
++it;
}
/// It is assumed that the zero key (stored separately) is first in iteration order.
if (it != level0_sub_table.end() && it.get_ptr()->is_zero(level0_sub_table)) {
insert(it->get_value());
++it;
}
for (; it != level0_sub_table.end(); ++it) {
const auto* cell = it.get_ptr();
size_t hash_value = cell->get_hash(level0_sub_table);
size_t sub_table_idx = get_sub_table_from_hash(hash_value);
level1_sub_tables[sub_table_idx].insert_unique_non_zero(cell, hash_value);
}
for (; it != level0_sub_table.end(); ++it) {
const auto* cell = it.get_ptr();
size_t hash_value = cell->get_hash(level0_sub_table);
size_t sub_table_idx = get_sub_table_from_hash(hash_value);
level1_sub_tables[sub_table_idx].insert_unique_non_zero(cell, hash_value);
}
level0_sub_table.clear_and_shrink();

View File

@ -24,7 +24,6 @@
#include "vec/aggregate_functions/aggregate_function.h"
#include "vec/common/hash_table/hash.h"
#include "vec/common/hash_table/hash_table_utils.h"
#include "vec/common/hash_table/phmap_fwd_decl.h"
template <typename Key, typename Mapped>
@ -270,8 +269,3 @@ private:
// PartitionedHashTable will convert this hash table to partitioned hash table
bool _need_partition;
};
template <typename Key, typename Mapped, typename Hash, bool PartitionedHashTable>
struct HashTableTraits<PHHashMap<Key, Mapped, Hash, PartitionedHashTable>> {
static constexpr bool is_phmap = true;
};

View File

@ -24,7 +24,6 @@
#include <variant>
#include "vec/common/hash_table/hash.h"
#include "vec/common/hash_table/hash_table_utils.h"
using StringKey8 = doris::vectorized::UInt64;
using StringKey16 = doris::vectorized::UInt128;

View File

@ -41,7 +41,6 @@
#include "vec/aggregate_functions/aggregate_function.h"
#include "vec/common/hash_table/hash.h"
#include "vec/common/hash_table/hash_map_context_creator.h"
#include "vec/common/hash_table/hash_table_utils.h"
#include "vec/common/hash_table/partitioned_hash_map.h"
#include "vec/common/hash_table/string_hash_table.h"
#include "vec/common/string_buffer.hpp"