|
17 | 17 |
|
18 | 18 | #pragma once
|
19 | 19 |
|
| 20 | +#include <glog/logging.h> |
| 21 | + |
| 22 | +#include <type_traits> |
| 23 | + |
| 24 | +#include "common/exception.h" |
20 | 25 | #include "common/object_pool.h"
|
| 26 | +#include "common/status.h" |
21 | 27 | #include "exprs/runtime_filter.h"
|
22 | 28 | #include "runtime/decimalv2_value.h"
|
23 | 29 | #include "runtime/define_primitive_type.h"
|
@@ -60,8 +66,16 @@ class FixedContainer {
|
60 | 66 | }
|
61 | 67 | }
|
62 | 68 |
|
| 69 | + void check_size() { |
| 70 | + if (N != _size) { |
| 71 | + throw doris::Exception(ErrorCode::INTERNAL_ERROR, |
| 72 | + "invalid size of FixedContainer<{}>: {}", N, _size); |
| 73 | + } |
| 74 | + } |
| 75 | + |
63 | 76 | // Use '|' instead of '||' has better performance by test.
|
64 | 77 | ALWAYS_INLINE bool find(const T& value) const {
|
| 78 | + DCHECK_EQ(N, _size); |
65 | 79 | if constexpr (N == 0) {
|
66 | 80 | return false;
|
67 | 81 | }
|
@@ -144,6 +158,12 @@ class FixedContainer {
|
144 | 158 | size_t _size {};
|
145 | 159 | };
|
146 | 160 |
|
| 161 | +template <typename T> |
| 162 | +struct IsFixedContainer : std::false_type {}; |
| 163 | + |
| 164 | +template <typename T, size_t N> |
| 165 | +struct IsFixedContainer<FixedContainer<T, N>> : std::true_type {}; |
| 166 | + |
147 | 167 | /**
|
148 | 168 | * Dynamic Container uses phmap::flat_hash_set.
|
149 | 169 | * @tparam T Element Type
|
@@ -354,6 +374,11 @@ class HybridSet : public HybridSetBase {
|
354 | 374 | if constexpr (is_nullable) {
|
355 | 375 | null_map_data = null_map->data();
|
356 | 376 | }
|
| 377 | + |
| 378 | + if constexpr (IsFixedContainer<ContainerType>::value) { |
| 379 | + _set.check_size(); |
| 380 | + } |
| 381 | + |
357 | 382 | auto* __restrict result_data = results.data();
|
358 | 383 | for (size_t i = 0; i < rows; ++i) {
|
359 | 384 | if constexpr (!is_nullable && !is_negative) {
|
@@ -507,6 +532,11 @@ class StringSet : public HybridSetBase {
|
507 | 532 | if constexpr (is_nullable) {
|
508 | 533 | null_map_data = null_map->data();
|
509 | 534 | }
|
| 535 | + |
| 536 | + if constexpr (IsFixedContainer<ContainerType>::value) { |
| 537 | + _set.check_size(); |
| 538 | + } |
| 539 | + |
510 | 540 | auto* __restrict result_data = results.data();
|
511 | 541 | for (size_t i = 0; i < rows; ++i) {
|
512 | 542 | const auto& string_data = col.get_data_at(i).to_string();
|
@@ -675,6 +705,11 @@ class StringValueSet : public HybridSetBase {
|
675 | 705 | if constexpr (is_nullable) {
|
676 | 706 | null_map_data = null_map->data();
|
677 | 707 | }
|
| 708 | + |
| 709 | + if constexpr (IsFixedContainer<ContainerType>::value) { |
| 710 | + _set.check_size(); |
| 711 | + } |
| 712 | + |
678 | 713 | auto* __restrict result_data = results.data();
|
679 | 714 | for (size_t i = 0; i < rows; ++i) {
|
680 | 715 | uint32_t len = offset[i] - offset[i - 1];
|
|
0 commit comments