be/src/exec/common/hash_table/hash_map.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | // This file is copied from |
18 | | // https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/HashTable/HashMap.h |
19 | | // and modified by Doris |
20 | | |
21 | | #pragma once |
22 | | |
23 | | #include "exec/common/hash_table/hash.h" |
24 | | #include "exec/common/hash_table/hash_table.h" |
25 | | |
26 | | namespace doris { |
27 | | /** NOTE HashMap could only be used for memmoveable (position independent) types. |
28 | | * Example: std::string is not position independent in libstdc++ with C++11 ABI or in libc++. |
29 | | * Also, key in hash table must be of type, that zero bytes is compared equals to zero key. |
30 | | */ |
31 | | |
32 | | struct NoInitTag {}; |
33 | | |
34 | | /// A pair that does not initialize the elements, if not needed. |
35 | | template <typename First, typename Second> |
36 | | struct PairNoInit { |
37 | | First first; |
38 | | Second second; |
39 | | |
40 | 294 | PairNoInit() {}_ZN5doris10PairNoInitINS_9StringRefEjEC2Ev Line | Count | Source | 40 | 268 | PairNoInit() {} |
_ZN5doris10PairNoInitINS_9StringRefEPcEC2Ev Line | Count | Source | 40 | 22 | PairNoInit() {} |
_ZN5doris10PairNoInitINS_9StringRefEPNS_15PartitionBlocksEEC2Ev Line | Count | Source | 40 | 4 | PairNoInit() {} |
|
41 | | |
42 | | template <typename First_> |
43 | | PairNoInit(First_&& first_, NoInitTag) : first(std::forward<First_>(first_)) {} |
44 | | |
45 | | template <typename First_, typename Second_> |
46 | | PairNoInit(First_&& first_, Second_&& second_) |
47 | 2.88k | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {}_ZN5doris10PairNoInitINS_9StringRefEjEC2IRKS1_RKjEEOT_OT0_ Line | Count | Source | 47 | 52 | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
_ZN5doris10PairNoInitIN4wide7integerILm128EjEEjEC2IRKS3_RKjEEOT_OT0_ Line | Count | Source | 47 | 7 | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
_ZN5doris10PairNoInitINS_9StringRefEPcEC2IRKS1_RKS2_EEOT_OT0_ Line | Count | Source | 47 | 3 | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
Unexecuted instantiation: _ZN5doris10PairNoInitIN4wide7integerILm128EjEEPcEC2IRKS3_RKS4_EEOT_OT0_ Unexecuted instantiation: _ZN5doris10PairNoInitINS_9StringRefEPNS_15PartitionBlocksEEC2IRKS1_RKS3_EEOT_OT0_ Unexecuted instantiation: _ZN5doris10PairNoInitIN4wide7integerILm128EjEEPNS_15PartitionBlocksEEC2IRKS3_RKS5_EEOT_OT0_ _ZN5doris10PairNoInitItjEC2IRKtRKjEEOT_OT0_ Line | Count | Source | 47 | 2.81k | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
Unexecuted instantiation: _ZN5doris10PairNoInitIjjEC2IRKjS4_EEOT_OT0_ Unexecuted instantiation: _ZN5doris10PairNoInitImjEC2IRKmRKjEEOT_OT0_ _ZN5doris10PairNoInitItPcEC2IRKtRKS1_EEOT_OT0_ Line | Count | Source | 47 | 2 | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
_ZN5doris10PairNoInitIjPcEC2IRKjRKS1_EEOT_OT0_ Line | Count | Source | 47 | 3 | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
_ZN5doris10PairNoInitImPcEC2IRKmRKS1_EEOT_OT0_ Line | Count | Source | 47 | 4 | : first(std::forward<First_>(first_)), second(std::forward<Second_>(second_)) {} |
Unexecuted instantiation: _ZN5doris10PairNoInitItPNS_15PartitionBlocksEEC2IRKtRKS2_EEOT_OT0_ Unexecuted instantiation: _ZN5doris10PairNoInitIjPNS_15PartitionBlocksEEC2IRKjRKS2_EEOT_OT0_ Unexecuted instantiation: _ZN5doris10PairNoInitImPNS_15PartitionBlocksEEC2IRKmRKS2_EEOT_OT0_ |
48 | | }; |
49 | | |
50 | | template <typename Key, typename TMapped, typename Hash, typename TState = HashTableNoState> |
51 | | struct HashMapCell { |
52 | | using Mapped = TMapped; |
53 | | using State = TState; |
54 | | |
55 | | using value_type = PairNoInit<Key, Mapped>; |
56 | | using mapped_type = Mapped; |
57 | | using key_type = Key; |
58 | | |
59 | | value_type value; |
60 | | |
61 | 294 | HashMapCell() = default; _ZN5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateEC2Ev Line | Count | Source | 61 | 268 | HashMapCell() = default; |
_ZN5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateEC2Ev Line | Count | Source | 61 | 22 | HashMapCell() = default; |
_ZN5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateEC2Ev Line | Count | Source | 61 | 4 | HashMapCell() = default; |
|
62 | | HashMapCell(const Key& key_, const State&) : value(key_, NoInitTag()) {} |
63 | 2.88k | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {}_ZN5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateEC2ERKS1_RKj Line | Count | Source | 63 | 52 | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
_ZN5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateEC2ERKtRKj Line | Count | Source | 63 | 2.81k | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
Unexecuted instantiation: _ZN5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateEC2ERKjS5_ Unexecuted instantiation: _ZN5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateEC2ERKmRKj _ZN5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateEC2ERKS3_RKj Line | Count | Source | 63 | 7 | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
_ZN5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateEC2ERKS1_RKS2_ Line | Count | Source | 63 | 3 | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
_ZN5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateEC2ERKtRKS1_ Line | Count | Source | 63 | 2 | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
_ZN5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateEC2ERKjRKS1_ Line | Count | Source | 63 | 3 | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
_ZN5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateEC2ERKmRKS1_ Line | Count | Source | 63 | 4 | HashMapCell(const Key& key_, const Mapped& mapped_) : value(key_, mapped_) {} |
Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateEC2ERKS3_RKS4_ Unexecuted instantiation: _ZN5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateEC2ERKS1_RKS3_ Unexecuted instantiation: _ZN5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateEC2ERKtRKS2_ Unexecuted instantiation: _ZN5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateEC2ERKjRKS2_ Unexecuted instantiation: _ZN5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateEC2ERKmRKS2_ Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateEC2ERKS3_RKS5_ |
64 | | HashMapCell(const value_type& value_, const State&) : value(value_) {} |
65 | | |
66 | 7 | const Key& get_first() const { return value.first; } |
67 | 2.90k | Mapped& get_second() { return value.second; }_ZN5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 10 | Mapped& get_second() { return value.second; } |
_ZN5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 2 | Mapped& get_second() { return value.second; } |
_ZN5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 7 | Mapped& get_second() { return value.second; } |
_ZN5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 10 | Mapped& get_second() { return value.second; } |
Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE10get_secondEv _ZN5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 52 | Mapped& get_second() { return value.second; } |
_ZN5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 2.81k | Mapped& get_second() { return value.second; } |
Unexecuted instantiation: _ZN5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE10get_secondEv Unexecuted instantiation: _ZN5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE10get_secondEv _ZN5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 67 | 7 | Mapped& get_second() { return value.second; } |
Unexecuted instantiation: _ZN5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10get_secondEv Unexecuted instantiation: _ZN5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10get_secondEv Unexecuted instantiation: _ZN5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10get_secondEv Unexecuted instantiation: _ZN5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10get_secondEv Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10get_secondEv |
68 | 8 | const Mapped& get_second() const { return value.second; }_ZNK5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 68 | 6 | const Mapped& get_second() const { return value.second; } |
_ZNK5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE10get_secondEv Line | Count | Source | 68 | 2 | const Mapped& get_second() const { return value.second; } |
Unexecuted instantiation: _ZNK5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE10get_secondEv Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE10get_secondEv |
69 | | |
70 | 2.02k | const value_type& get_value() const { return value; }Unexecuted instantiation: _ZNK5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateE9get_valueEv _ZNK5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE9get_valueEv Line | Count | Source | 70 | 2.02k | const value_type& get_value() const { return value; } |
Unexecuted instantiation: _ZNK5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE9get_valueEv Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE9get_valueEv |
71 | | |
72 | | static const Key& get_key(const value_type& value) { return value.first; } |
73 | 4.31k | Mapped& get_mapped() { return value.second; }_ZN5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateE10get_mappedEv Line | Count | Source | 73 | 78 | Mapped& get_mapped() { return value.second; } |
_ZN5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE10get_mappedEv Line | Count | Source | 73 | 4.22k | Mapped& get_mapped() { return value.second; } |
Unexecuted instantiation: _ZN5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE10get_mappedEv Unexecuted instantiation: _ZN5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE10get_mappedEv _ZN5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateE10get_mappedEv Line | Count | Source | 73 | 11 | Mapped& get_mapped() { return value.second; } |
_ZN5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE10get_mappedEv Line | Count | Source | 73 | 1 | Mapped& get_mapped() { return value.second; } |
Unexecuted instantiation: _ZN5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE10get_mappedEv _ZN5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE10get_mappedEv Line | Count | Source | 73 | 2 | Mapped& get_mapped() { return value.second; } |
_ZN5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE10get_mappedEv Line | Count | Source | 73 | 4 | Mapped& get_mapped() { return value.second; } |
Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE10get_mappedEv |
74 | | const Mapped& get_mapped() const { return value.second; } |
75 | | |
76 | | bool key_equals(const Key& key_) const { return value.first == key_; } |
77 | | bool key_equals(const Key& key_, size_t /*hash_*/) const { return value.first == key_; } |
78 | 4.68k | bool key_equals(const Key& key_, size_t /*hash_*/, const State& /*state*/) const { |
79 | 4.68k | return value.first == key_; |
80 | 4.68k | } _ZNK5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE10key_equalsERKtmRKS2_ Line | Count | Source | 78 | 4.66k | bool key_equals(const Key& key_, size_t /*hash_*/, const State& /*state*/) const { | 79 | 4.66k | return value.first == key_; | 80 | 4.66k | } |
Unexecuted instantiation: _ZNK5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE10key_equalsERKjmRKS2_ Unexecuted instantiation: _ZNK5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE10key_equalsERKmmRKS2_ _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateE10key_equalsERKS3_mRKS5_ Line | Count | Source | 78 | 11 | bool key_equals(const Key& key_, size_t /*hash_*/, const State& /*state*/) const { | 79 | 11 | return value.first == key_; | 80 | 11 | } |
_ZNK5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE10key_equalsERKtmRKS3_ Line | Count | Source | 78 | 1 | bool key_equals(const Key& key_, size_t /*hash_*/, const State& /*state*/) const { | 79 | 1 | return value.first == key_; | 80 | 1 | } |
_ZNK5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE10key_equalsERKjmRKS3_ Line | Count | Source | 78 | 2 | bool key_equals(const Key& key_, size_t /*hash_*/, const State& /*state*/) const { | 79 | 2 | return value.first == key_; | 80 | 2 | } |
_ZNK5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE10key_equalsERKmmRKS3_ Line | Count | Source | 78 | 4 | bool key_equals(const Key& key_, size_t /*hash_*/, const State& /*state*/) const { | 79 | 4 | return value.first == key_; | 80 | 4 | } |
Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE10key_equalsERKS3_mRKS6_ Unexecuted instantiation: _ZNK5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10key_equalsERKtmRKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10key_equalsERKjmRKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10key_equalsERKmmRKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10key_equalsERKS3_mRKS7_ |
81 | | |
82 | 4.85k | void set_hash(size_t /*hash_value*/) {}_ZN5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 82 | 4.84k | void set_hash(size_t /*hash_value*/) {} |
Unexecuted instantiation: _ZN5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE8set_hashEm Unexecuted instantiation: _ZN5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE8set_hashEm _ZN5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 82 | 7 | void set_hash(size_t /*hash_value*/) {} |
_ZN5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 82 | 2 | void set_hash(size_t /*hash_value*/) {} |
_ZN5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 82 | 3 | void set_hash(size_t /*hash_value*/) {} |
_ZN5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 82 | 4 | void set_hash(size_t /*hash_value*/) {} |
Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE8set_hashEm Unexecuted instantiation: _ZN5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_hashEm Unexecuted instantiation: _ZN5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_hashEm Unexecuted instantiation: _ZN5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_hashEm Unexecuted instantiation: _ZN5doris11HashMapCellIN4wide7integerILm128EjEEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_hashEm |
83 | 3.61k | size_t get_hash(const Hash& hash) const { return hash(value.first); }_ZNK5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE8get_hashERKS1_ Line | Count | Source | 83 | 3.61k | size_t get_hash(const Hash& hash) const { return hash(value.first); } |
Unexecuted instantiation: _ZNK5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE8get_hashERKS1_ Unexecuted instantiation: _ZNK5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE8get_hashERKS1_ Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEj19StringHashTableHash16HashTableNoStateE8get_hashERKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE8get_hashERKS2_ Unexecuted instantiation: _ZNK5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE8get_hashERKS2_ Unexecuted instantiation: _ZNK5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE8get_hashERKS2_ Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPc19StringHashTableHash16HashTableNoStateE8get_hashERKS5_ Unexecuted instantiation: _ZNK5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8get_hashERKS3_ Unexecuted instantiation: _ZNK5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8get_hashERKS3_ Unexecuted instantiation: _ZNK5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8get_hashERKS3_ Unexecuted instantiation: _ZNK5doris11HashMapCellIN4wide7integerILm128EjEEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8get_hashERKS6_ |
84 | | |
85 | 29.8k | bool is_zero(const State& state) const { return is_zero(value.first, state); }_ZNK5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE7is_zeroERKS2_ Line | Count | Source | 85 | 25.6k | bool is_zero(const State& state) const { return is_zero(value.first, state); } |
Unexecuted instantiation: _ZNK5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE7is_zeroERKS2_ Unexecuted instantiation: _ZNK5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE7is_zeroERKS2_ _ZNK5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateE7is_zeroERKS3_ Line | Count | Source | 85 | 262 | bool is_zero(const State& state) const { return is_zero(value.first, state); } |
_ZNK5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE7is_zeroERKS3_ Line | Count | Source | 85 | 104 | bool is_zero(const State& state) const { return is_zero(value.first, state); } |
_ZNK5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE7is_zeroERKS3_ Line | Count | Source | 85 | 1.29k | bool is_zero(const State& state) const { return is_zero(value.first, state); } |
_ZNK5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE7is_zeroERKS3_ Line | Count | Source | 85 | 1.30k | bool is_zero(const State& state) const { return is_zero(value.first, state); } |
_ZNK5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE7is_zeroERKS4_ Line | Count | Source | 85 | 1.29k | bool is_zero(const State& state) const { return is_zero(value.first, state); } |
Unexecuted instantiation: _ZNK5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKS4_ Unexecuted instantiation: _ZNK5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKS5_ |
86 | 34.2k | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); }_ZN5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE7is_zeroERKtRKS2_ Line | Count | Source | 86 | 29.8k | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); } |
Unexecuted instantiation: _ZN5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE7is_zeroERKjRKS2_ Unexecuted instantiation: _ZN5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE7is_zeroERKmRKS2_ _ZN5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateE7is_zeroERKS1_RKS3_ Line | Count | Source | 86 | 341 | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); } |
_ZN5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE7is_zeroERKtRKS3_ Line | Count | Source | 86 | 104 | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); } |
_ZN5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE7is_zeroERKjRKS3_ Line | Count | Source | 86 | 1.29k | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); } |
_ZN5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE7is_zeroERKmRKS3_ Line | Count | Source | 86 | 1.30k | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); } |
_ZN5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE7is_zeroERKS1_RKS4_ Line | Count | Source | 86 | 1.29k | static bool is_zero(const Key& key, const State& /*state*/) { return ZeroTraits::check(key); } |
Unexecuted instantiation: _ZN5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKtRKS4_ Unexecuted instantiation: _ZN5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKjRKS4_ Unexecuted instantiation: _ZN5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKmRKS4_ Unexecuted instantiation: _ZN5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE7is_zeroERKS1_RKS5_ |
87 | | |
88 | | /// Set the key value to zero. |
89 | 2.02k | void set_zero() { ZeroTraits::set(value.first); }_ZN5doris11HashMapCellItj19StringHashTableHash16HashTableNoStateE8set_zeroEv Line | Count | Source | 89 | 2.02k | void set_zero() { ZeroTraits::set(value.first); } |
Unexecuted instantiation: _ZN5doris11HashMapCellIjj19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellImj19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellINS_9StringRefEj19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellItPc19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellIjPc19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellImPc19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellItPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellIjPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellImPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_zeroEv Unexecuted instantiation: _ZN5doris11HashMapCellINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_zeroEv |
90 | | |
91 | | /// Do I need to store the zero key separately (that is, can a zero key be inserted into the hash table). |
92 | | static constexpr bool need_zero_value_storage = true; |
93 | | |
94 | | void set_mapped(const value_type& value_) { value.second = value_.second; } |
95 | | }; |
96 | | |
97 | | template <typename Key, typename Mapped, typename Hash, typename State> |
98 | | ALWAYS_INLINE inline auto lookup_result_get_key(HashMapCell<Key, Mapped, Hash, State>* cell) { |
99 | | return &cell->get_first(); |
100 | | } |
101 | | |
102 | | template <typename Key, typename Mapped, typename Hash, typename State> |
103 | | ALWAYS_INLINE inline auto lookup_result_get_mapped(HashMapCell<Key, Mapped, Hash, State>* cell) { |
104 | | return &cell->get_second(); |
105 | | } |
106 | | |
107 | | template <typename Key, typename TMapped, typename Hash, typename TState = HashTableNoState> |
108 | | struct HashMapCellWithSavedHash : public HashMapCell<Key, TMapped, Hash, TState> { |
109 | | using Base = HashMapCell<Key, TMapped, Hash, TState>; |
110 | | |
111 | | size_t saved_hash; |
112 | | |
113 | | using Base::Base; |
114 | | |
115 | | bool key_equals(const Key& key_) const { return this->value.first == key_; } |
116 | 79 | bool key_equals(const Key& key_, size_t hash_) const { |
117 | 79 | return saved_hash == hash_ && this->value.first == key_; |
118 | 79 | } _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEj19StringHashTableHash16HashTableNoStateE10key_equalsERKS1_m Line | Count | Source | 116 | 78 | bool key_equals(const Key& key_, size_t hash_) const { | 117 | 78 | return saved_hash == hash_ && this->value.first == key_; | 118 | 78 | } |
_ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE10key_equalsERKS1_m Line | Count | Source | 116 | 1 | bool key_equals(const Key& key_, size_t hash_) const { | 117 | 1 | return saved_hash == hash_ && this->value.first == key_; | 118 | 1 | } |
Unexecuted instantiation: _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10key_equalsERKS1_m |
119 | 79 | bool key_equals(const Key& key_, size_t hash_, const typename Base::State&) const { |
120 | 79 | return key_equals(key_, hash_); |
121 | 79 | } _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEj19StringHashTableHash16HashTableNoStateE10key_equalsERKS1_mRKS3_ Line | Count | Source | 119 | 78 | bool key_equals(const Key& key_, size_t hash_, const typename Base::State&) const { | 120 | 78 | return key_equals(key_, hash_); | 121 | 78 | } |
_ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE10key_equalsERKS1_mRKS4_ Line | Count | Source | 119 | 1 | bool key_equals(const Key& key_, size_t hash_, const typename Base::State&) const { | 120 | 1 | return key_equals(key_, hash_); | 121 | 1 | } |
Unexecuted instantiation: _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE10key_equalsERKS1_mRKS5_ |
122 | | |
123 | 55 | void set_hash(size_t hash_value) { saved_hash = hash_value; }_ZN5doris24HashMapCellWithSavedHashINS_9StringRefEj19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 123 | 52 | void set_hash(size_t hash_value) { saved_hash = hash_value; } |
_ZN5doris24HashMapCellWithSavedHashINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE8set_hashEm Line | Count | Source | 123 | 3 | void set_hash(size_t hash_value) { saved_hash = hash_value; } |
Unexecuted instantiation: _ZN5doris24HashMapCellWithSavedHashINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8set_hashEm |
124 | 0 | size_t get_hash(const Hash& /*hash_function*/) const { return saved_hash; }Unexecuted instantiation: _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEj19StringHashTableHash16HashTableNoStateE8get_hashERKS2_ Unexecuted instantiation: _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEPc19StringHashTableHash16HashTableNoStateE8get_hashERKS3_ Unexecuted instantiation: _ZNK5doris24HashMapCellWithSavedHashINS_9StringRefEPNS_15PartitionBlocksE19StringHashTableHash16HashTableNoStateE8get_hashERKS4_ |
125 | | }; |
126 | | |
127 | | template <typename Key, typename Mapped, typename Hash, typename State> |
128 | | ALWAYS_INLINE inline auto lookup_result_get_key( |
129 | | HashMapCellWithSavedHash<Key, Mapped, Hash, State>* cell) { |
130 | | return &cell->get_first(); |
131 | | } |
132 | | |
133 | | template <typename Key, typename Mapped, typename Hash, typename State> |
134 | | ALWAYS_INLINE inline auto lookup_result_get_mapped( |
135 | | HashMapCellWithSavedHash<Key, Mapped, Hash, State>* cell) { |
136 | | return &cell->get_second(); |
137 | | } |
138 | | |
139 | | template <typename Key, typename Cell, typename Hash = DefaultHash<Key>, |
140 | | typename Grower = HashTableGrower<>, typename Allocator = Allocator<true, true> > |
141 | | class HashMapTable : public HashTable<Key, Cell, Hash, Grower, Allocator> { |
142 | | public: |
143 | | using Self = HashMapTable; |
144 | | using Base = HashTable<Key, Cell, Hash, Grower, Allocator>; |
145 | | |
146 | | using key_type = Key; |
147 | | using value_type = typename Cell::value_type; |
148 | | using mapped_type = typename Cell::Mapped; |
149 | | |
150 | | using LookupResult = typename Base::LookupResult; |
151 | | |
152 | | using HashTable<Key, Cell, Hash, Grower, Allocator>::HashTable; |
153 | | |
154 | | /// Call func(Mapped &) for each hash map element. |
155 | | template <typename Func> |
156 | | void for_each_mapped(Func&& func) { |
157 | | for (auto& v : *this) func(v.get_second()); |
158 | | } |
159 | | |
160 | | mapped_type& ALWAYS_INLINE operator[](Key x) { |
161 | | typename HashMapTable::LookupResult it; |
162 | | bool inserted; |
163 | | this->emplace(x, it, inserted); |
164 | | |
165 | | /** It may seem that initialization is not necessary for POD-types (or __has_trivial_constructor), |
166 | | * since the hash table memory is initially initialized with zeros. |
167 | | * But, in fact, an empty cell may not be initialized with zeros in the following cases: |
168 | | * - ZeroValueStorage (it only zeros the key); |
169 | | * - after resizing and moving a part of the cells to the new half of the hash table, the old cells also have only the key to zero. |
170 | | * |
171 | | * On performance, there is almost always no difference, due to the fact that it->second is usually assigned immediately |
172 | | * after calling `operator[]`, and since `operator[]` is inlined, the compiler removes unnecessary initialization. |
173 | | * |
174 | | * Sometimes due to initialization, the performance even grows. This occurs in code like `++map[key]`. |
175 | | * When we do the initialization, for new cells, it's enough to make `store 1` right away. |
176 | | * And if we did not initialize, then even though there was zero in the cell, |
177 | | * the compiler can not guess about this, and generates the `load`, `increment`, `store` code. |
178 | | */ |
179 | | if (inserted) new (lookup_result_get_mapped(it)) mapped_type(); |
180 | | |
181 | | return *lookup_result_get_mapped(it); |
182 | | } |
183 | | |
184 | | template <typename MappedType> |
185 | | char* get_null_key_data() { |
186 | | return nullptr; |
187 | | } |
188 | | bool has_null_key_data() const { return false; } |
189 | | }; |
190 | | |
191 | | } // namespace doris |