HappenLee commented on code in PR #13581:
URL: https://github.com/apache/doris/pull/13581#discussion_r1017510139
##########
be/src/olap/in_list_predicate.h:
##########
@@ -101,24 +102,78 @@ class InListPredicateBase : public ColumnPredicate {
} else {
tmp = convert(condition);
}
- _values.insert(tmp);
- if (tmp > _max_value) {
- _max_value = tmp;
- }
- if (tmp < _min_value) {
- _min_value = tmp;
+ _values->insert(tmp);
+ _update_min_max(tmp);
+ }
+ }
+
+ InListPredicateBase(uint32_t column_id, const
std::shared_ptr<HybridSetBase>& hybrid_set,
+ size_t char_length = 0)
+ : ColumnPredicate(column_id, false),
+ _min_value(type_limit<T>::max()),
+ _max_value(type_limit<T>::min()) {
+ using HybridSetType = std::conditional_t<is_string_type(Type),
StringSet, HybridSet<Type>>;
+
+ CHECK(hybrid_set != nullptr);
+
+ if constexpr (is_string_type(Type) || Type == TYPE_DECIMALV2 ||
is_date_type(Type)) {
+ _values = new phmap::flat_hash_set<T>();
+ auto values = ((HybridSetType*)hybrid_set.get())->get_inner_set();
+
+ if constexpr (is_string_type(Type)) {
+ for (auto& value : *values) {
+ StringValue sv = {value.data(), int(value.size())};
+ if constexpr (Type == TYPE_CHAR) {
+ _temp_datas.push_back("");
+ _temp_datas.back().resize(std::max(char_length,
value.size()));
+ memcpy(_temp_datas.back().data(), value.data(),
value.size());
+ sv = {_temp_datas.back().data(),
int(_temp_datas.back().size())};
+ }
+ _values->insert(sv);
+ }
+ } else if constexpr (Type == TYPE_DECIMALV2) {
+ for (auto& value : *values) {
+ _values->insert({value.int_value(), value.frac_value()});
+ }
+ } else if constexpr (Type == TYPE_DATE) {
+ for (auto& value : *values) {
+ _values->insert(value.to_olap_date());
+ }
+ } else if constexpr (Type == TYPE_DATETIME) {
+ for (auto& value : *values) {
+ _values->insert(value.to_olap_datetime());
+ }
+ } else {
+ for (auto& value : *values) {
Review Comment:
only ` is_string_type(Type) || Type == TYPE_DECIMALV2 || is_date_type(Type)`
which case will be here ? maybe need DCHECK?
##########
be/src/olap/in_list_predicate.h:
##########
@@ -101,24 +102,78 @@ class InListPredicateBase : public ColumnPredicate {
} else {
tmp = convert(condition);
}
- _values.insert(tmp);
- if (tmp > _max_value) {
- _max_value = tmp;
- }
- if (tmp < _min_value) {
- _min_value = tmp;
+ _values->insert(tmp);
+ _update_min_max(tmp);
+ }
+ }
+
+ InListPredicateBase(uint32_t column_id, const
std::shared_ptr<HybridSetBase>& hybrid_set,
+ size_t char_length = 0)
+ : ColumnPredicate(column_id, false),
+ _min_value(type_limit<T>::max()),
+ _max_value(type_limit<T>::min()) {
+ using HybridSetType = std::conditional_t<is_string_type(Type),
StringSet, HybridSet<Type>>;
+
+ CHECK(hybrid_set != nullptr);
+
+ if constexpr (is_string_type(Type) || Type == TYPE_DECIMALV2 ||
is_date_type(Type)) {
+ _values = new phmap::flat_hash_set<T>();
+ auto values = ((HybridSetType*)hybrid_set.get())->get_inner_set();
+
+ if constexpr (is_string_type(Type)) {
+ for (auto& value : *values) {
+ StringValue sv = {value.data(), int(value.size())};
+ if constexpr (Type == TYPE_CHAR) {
+ _temp_datas.push_back("");
+ _temp_datas.back().resize(std::max(char_length,
value.size()));
Review Comment:
resize can make sure the new len is filled by "\0" ?
##########
be/src/exprs/in_predicate.cpp:
##########
@@ -35,13 +33,17 @@ InPredicate::InPredicate(const TExprNode& node)
_null_in_set(false),
_hybrid_set() {}
-InPredicate::~InPredicate() {}
+InPredicate::~InPredicate() {
+ if (_should_delete) {
Review Comment:
really we need `should_delete` ? use _hybrid_set == nullptr or just use
unique_ptr?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]