|
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
|
@@ -351,6 +371,11 @@ class HybridSet : public HybridSetBase {
|
351 | 371 | if constexpr (is_nullable) {
|
352 | 372 | null_map_data = null_map->data();
|
353 | 373 | }
|
| 374 | + |
| 375 | + if constexpr (IsFixedContainer<ContainerType>::value) { |
| 376 | + _set.check_size(); |
| 377 | + } |
| 378 | + |
354 | 379 | auto* __restrict result_data = results.data();
|
355 | 380 | for (size_t i = 0; i < rows; ++i) {
|
356 | 381 | if constexpr (!is_nullable && !is_negative) {
|
@@ -466,6 +491,11 @@ class StringSet : public HybridSetBase {
|
466 | 491 | if constexpr (is_nullable) {
|
467 | 492 | null_map_data = null_map->data();
|
468 | 493 | }
|
| 494 | + |
| 495 | + if constexpr (IsFixedContainer<ContainerType>::value) { |
| 496 | + _set.check_size(); |
| 497 | + } |
| 498 | + |
469 | 499 | auto* __restrict result_data = results.data();
|
470 | 500 | for (size_t i = 0; i < rows; ++i) {
|
471 | 501 | const auto& string_data = col.get_data_at(i).to_string();
|
@@ -596,6 +626,11 @@ class StringValueSet : public HybridSetBase {
|
596 | 626 | if constexpr (is_nullable) {
|
597 | 627 | null_map_data = null_map->data();
|
598 | 628 | }
|
| 629 | + |
| 630 | + if constexpr (IsFixedContainer<ContainerType>::value) { |
| 631 | + _set.check_size(); |
| 632 | + } |
| 633 | + |
599 | 634 | auto* __restrict result_data = results.data();
|
600 | 635 | for (size_t i = 0; i < rows; ++i) {
|
601 | 636 | uint32_t len = offset[i] - offset[i - 1];
|
|
0 commit comments