From afeac4419f82bed14b797401b294fb456dcc3ea7 Mon Sep 17 00:00:00 2001 From: zhangstar333 <87313068+zhangstar333@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:30:40 +0800 Subject: [PATCH] [Bug](node) fix partition sort node forget handle some type of key in hashmap (#22037) * [enhancement](repeat) add filter in repeat node in BE * update --- be/src/vec/exec/vpartition_sort_node.h | 130 ++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/be/src/vec/exec/vpartition_sort_node.h b/be/src/vec/exec/vpartition_sort_node.h index 45b44da81e..65384dc1c5 100644 --- a/be/src/vec/exec/vpartition_sort_node.h +++ b/be/src/vec/exec/vpartition_sort_node.h @@ -26,6 +26,7 @@ #include "exec/exec_node.h" #include "vec/columns/column.h" #include "vec/common/columns_hashing.h" +#include "vec/common/hash_table/fixed_hash_map.h" #include "vec/common/hash_table/hash.h" #include "vec/common/hash_table/ph_hash_map.h" #include "vec/common/hash_table/string_hash_map.h" @@ -83,8 +84,13 @@ public: using PartitionDataPtr = PartitionBlocks*; using PartitionDataWithStringKey = PHHashMap>; using PartitionDataWithShortStringKey = StringHashMap; +using PartitionDataWithUInt8Key = + FixedImplicitZeroHashMapWithCalculatedSize; +using PartitionDataWithUInt16Key = FixedImplicitZeroHashMap; using PartitionDataWithUInt32Key = PHHashMap>; - +using PartitionDataWithUInt64Key = PHHashMap>; +using PartitionDataWithUInt128Key = PHHashMap>; +using PartitionDataWithUInt256Key = PHHashMap>; template struct PartitionMethodSerialized { using Data = TData; @@ -249,11 +255,48 @@ struct PartitionMethodSingleNullableColumn : public SingleColumnMethod { using State = ColumnsHashing::HashMethodSingleLowNullableColumn; }; +template +struct PartitionMethodKeysFixed { + using Data = TData; + using Key = typename Data::key_type; + using Mapped = typename Data::mapped_type; + using Iterator = typename Data::iterator; + static constexpr bool has_nullable_keys = has_nullable_keys_; + + Data data; + Iterator iterator; + PartitionMethodKeysFixed() = default; + + template + PartitionMethodKeysFixed(const Other& other) : data(other.data) {} + + using State = ColumnsHashing::HashMethodKeysFixed; +}; + using PartitionedMethodVariants = std::variant, + PartitionMethodOneNumber, + PartitionMethodOneNumber, PartitionMethodOneNumber, + PartitionMethodOneNumber, + PartitionMethodOneNumber, + PartitionMethodSingleNullableColumn>>, + PartitionMethodSingleNullableColumn>>, PartitionMethodSingleNullableColumn>>, + PartitionMethodSingleNullableColumn>>, + PartitionMethodSingleNullableColumn>>, + PartitionMethodKeysFixed, + PartitionMethodKeysFixed, + PartitionMethodKeysFixed, + PartitionMethodKeysFixed, + PartitionMethodKeysFixed, + PartitionMethodKeysFixed, PartitionMethodStringNoCache, PartitionMethodSingleNullableColumn>>>; @@ -283,11 +326,34 @@ struct PartitionedHashMapVariants { void init(Type type, bool is_nullable = false) { _type = type; switch (_type) { - case Type::serialized: + case Type::serialized: { _partition_method_variant .emplace>(); break; - case Type::int32_key: + } + case Type::int8_key: { + if (is_nullable) { + _partition_method_variant + .emplace>>>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::int16_key: { + if (is_nullable) { + _partition_method_variant + .emplace>>>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::int32_key: { if (is_nullable) { _partition_method_variant .emplace>(); } break; - case Type::string_key: + } + case Type::int64_key: { + if (is_nullable) { + _partition_method_variant + .emplace>>>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::int128_key: { + if (is_nullable) { + _partition_method_variant + .emplace>>>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::int64_keys: { + if (is_nullable) { + _partition_method_variant + .emplace>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::int128_keys: { + if (is_nullable) { + _partition_method_variant + .emplace>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::int256_keys: { + if (is_nullable) { + _partition_method_variant + .emplace>(); + } else { + _partition_method_variant + .emplace>(); + } + break; + } + case Type::string_key: { if (is_nullable) { _partition_method_variant .emplace>(); } break; + } default: - DCHECK(false) << "Do not have a rigth partition by data type"; + DCHECK(false) << "Do not have a rigth partition by data type: "; } } };