github-actions[bot] commented on code in PR #17629:
URL: https://github.com/apache/doris/pull/17629#discussion_r1135163292
##########
be/src/olap/comparison_predicate.h:
##########
@@ -65,35 +65,41 @@ class ComparisonPredicateBase : public ColumnPredicate {
return Status::OK();
}
auto column_desc = schema.column(_column_id);
+ column_desc->type();
std::string column_name = column_desc->name();
- InvertedIndexQueryType query_type;
+ InvertedIndexQuery<Type> query(column_desc->type_info());
switch (PT) {
- case PredicateType::EQ:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
+ case PredicateType::GT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_THAN_QUERY,
_value));
Review Comment:
warning: no matching member function for call to 'add_value'
[clang-diagnostic-error]
```cpp
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_THAN_QUERY,
_value));
^
```
**be/src/common/status.h:507:** expanded from macro 'RETURN_IF_ERROR'
```cpp
Status _status_ = (stmt); \
^
```
**be/src/olap/comparison_predicate.h:33:** in instantiation of member
function 'doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::evaluate' requested here
```cpp
ComparisonPredicateBase(uint32_t column_id, const T& value, bool
opposite = false)
^
```
**be/src/olap/predicate_creator.h:145:** in instantiation of member function
'doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::ComparisonPredicateBase' requested here
```cpp
return new ComparisonPredicateBase<Type, PT>(index,
_convert(conditions), opposite);
^
```
**be/src/olap/predicate_creator.h:136:** in instantiation of member function
'doris::CustomPredicateCreator<doris::TYPE_DECIMALV2, doris::PredicateType::EQ,
std::basic_string<char>>::create' requested here
```cpp
CustomPredicateCreator(const std::function<CppType(const std::string&
condition)>& convert)
^
```
**/usr/include/c++/11/bits/unique_ptr.h:961:** in instantiation of member
function 'doris::CustomPredicateCreator<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ, std::basic_string<char>>::CustomPredicateCreator'
requested here
```cpp
{ return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
^
```
**be/src/olap/predicate_creator.h:178:** in instantiation of function
template specialization
'std::make_unique<doris::CustomPredicateCreator<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ, std::basic_string<char>>, (lambda at
/github/workspace/be/src/olap/predicate_creator.h:180:17)>' requested here
```cpp
return std::make_unique<CustomPredicateCreator<TYPE_DECIMALV2, PT,
ConditionType>>(
^
```
**be/src/olap/predicate_creator.h:241:** in instantiation of function
template specialization 'doris::get_creator<doris::PredicateType::EQ,
std::basic_string<char>>' requested here
```cpp
return get_creator<PT, ConditionType>(column.type())
^
```
**be/src/olap/predicate_creator.h:250:** in instantiation of function
template specialization 'doris::create_predicate<doris::PredicateType::EQ,
std::basic_string<char>>' requested here
```cpp
return create_predicate<PT, std::string>(column, index, condition,
opposite, pool);
^
```
**be/src/olap/predicate_creator.h:295:** in instantiation of function
template specialization
'doris::create_comparison_predicate<doris::PredicateType::EQ>' requested here
```cpp
create = create_comparison_predicate<PredicateType::EQ>;
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:166:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to 'const
doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::CppType' (aka
'const doris::DecimalV2Value') for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, const CppType& value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:167:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to
'doris::PredicateParams *' for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, PredicateParams* params);
^
```
##########
be/src/olap/comparison_predicate.h:
##########
@@ -65,35 +65,41 @@
return Status::OK();
}
auto column_desc = schema.column(_column_id);
+ column_desc->type();
std::string column_name = column_desc->name();
- InvertedIndexQueryType query_type;
+ InvertedIndexQuery<Type> query(column_desc->type_info());
switch (PT) {
- case PredicateType::EQ:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
+ case PredicateType::GT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_THAN_QUERY,
_value));
break;
- case PredicateType::NE:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
- break;
- case PredicateType::LT:
- query_type = InvertedIndexQueryType::LESS_THAN_QUERY;
+ }
+ case PredicateType::LT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_THAN_QUERY, _value));
Review Comment:
warning: no matching member function for call to 'add_value'
[clang-diagnostic-error]
```cpp
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_THAN_QUERY, _value));
^
```
**be/src/common/status.h:507:** expanded from macro 'RETURN_IF_ERROR'
```cpp
Status _status_ = (stmt); \
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:166:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to 'const
doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::CppType' (aka
'const doris::DecimalV2Value') for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, const CppType& value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:167:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to
'doris::PredicateParams *' for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, PredicateParams* params);
^
```
##########
be/src/olap/comparison_predicate.h:
##########
@@ -65,35 +65,41 @@
return Status::OK();
}
auto column_desc = schema.column(_column_id);
+ column_desc->type();
std::string column_name = column_desc->name();
- InvertedIndexQueryType query_type;
+ InvertedIndexQuery<Type> query(column_desc->type_info());
switch (PT) {
- case PredicateType::EQ:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
+ case PredicateType::GT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_THAN_QUERY,
_value));
break;
- case PredicateType::NE:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
- break;
- case PredicateType::LT:
- query_type = InvertedIndexQueryType::LESS_THAN_QUERY;
+ }
+ case PredicateType::LT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_THAN_QUERY, _value));
break;
- case PredicateType::LE:
- query_type = InvertedIndexQueryType::LESS_EQUAL_QUERY;
+ }
+ case PredicateType::GE: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_EQUAL_QUERY,
_value));
Review Comment:
warning: no matching member function for call to 'add_value'
[clang-diagnostic-error]
```cpp
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_EQUAL_QUERY,
_value));
^
```
**be/src/common/status.h:507:** expanded from macro 'RETURN_IF_ERROR'
```cpp
Status _status_ = (stmt); \
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:166:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to 'const
doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::CppType' (aka
'const doris::DecimalV2Value') for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, const CppType& value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:167:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to
'doris::PredicateParams *' for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, PredicateParams* params);
^
```
##########
be/src/olap/comparison_predicate.h:
##########
@@ -65,35 +65,41 @@
return Status::OK();
}
auto column_desc = schema.column(_column_id);
+ column_desc->type();
std::string column_name = column_desc->name();
- InvertedIndexQueryType query_type;
+ InvertedIndexQuery<Type> query(column_desc->type_info());
switch (PT) {
- case PredicateType::EQ:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
+ case PredicateType::GT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_THAN_QUERY,
_value));
break;
- case PredicateType::NE:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
- break;
- case PredicateType::LT:
- query_type = InvertedIndexQueryType::LESS_THAN_QUERY;
+ }
+ case PredicateType::LT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_THAN_QUERY, _value));
break;
- case PredicateType::LE:
- query_type = InvertedIndexQueryType::LESS_EQUAL_QUERY;
+ }
+ case PredicateType::GE: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_EQUAL_QUERY,
_value));
break;
- case PredicateType::GT:
- query_type = InvertedIndexQueryType::GREATER_THAN_QUERY;
+ }
+ case PredicateType::LE: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_EQUAL_QUERY,
_value));
break;
- case PredicateType::GE:
- query_type = InvertedIndexQueryType::GREATER_EQUAL_QUERY;
+ }
+ case PredicateType::NE:
+ case PredicateType::EQ: {
+ RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::EQUAL_QUERY,
_value));
Review Comment:
warning: no matching member function for call to 'add_value'
[clang-diagnostic-error]
```cpp
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::EQUAL_QUERY, _value));
^
```
**be/src/common/status.h:507:** expanded from macro 'RETURN_IF_ERROR'
```cpp
Status _status_ = (stmt); \
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:166:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to 'const
doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::CppType' (aka
'const doris::DecimalV2Value') for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, const CppType& value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:167:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to
'doris::PredicateParams *' for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, PredicateParams* params);
^
```
##########
be/src/olap/comparison_predicate.h:
##########
@@ -65,35 +65,41 @@
return Status::OK();
}
auto column_desc = schema.column(_column_id);
+ column_desc->type();
std::string column_name = column_desc->name();
- InvertedIndexQueryType query_type;
+ InvertedIndexQuery<Type> query(column_desc->type_info());
switch (PT) {
- case PredicateType::EQ:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
+ case PredicateType::GT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_THAN_QUERY,
_value));
break;
- case PredicateType::NE:
- query_type = InvertedIndexQueryType::EQUAL_QUERY;
- break;
- case PredicateType::LT:
- query_type = InvertedIndexQueryType::LESS_THAN_QUERY;
+ }
+ case PredicateType::LT: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_THAN_QUERY, _value));
break;
- case PredicateType::LE:
- query_type = InvertedIndexQueryType::LESS_EQUAL_QUERY;
+ }
+ case PredicateType::GE: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::GREATER_EQUAL_QUERY,
_value));
break;
- case PredicateType::GT:
- query_type = InvertedIndexQueryType::GREATER_THAN_QUERY;
+ }
+ case PredicateType::LE: {
+
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_EQUAL_QUERY,
_value));
Review Comment:
warning: no matching member function for call to 'add_value'
[clang-diagnostic-error]
```cpp
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::LESS_EQUAL_QUERY,
_value));
^
```
**be/src/common/status.h:507:** expanded from macro 'RETURN_IF_ERROR'
```cpp
Status _status_ = (stmt); \
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:166:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to 'const
doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::CppType' (aka
'const doris::DecimalV2Value') for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, const CppType& value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:167:** candidate
function not viable: no known conversion from 'const
doris::ComparisonPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::EQ>::T' (aka 'const doris::decimal12_t') to
'doris::PredicateParams *' for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, PredicateParams* params);
^
```
##########
be/src/olap/rowset/segment_v2/inverted_index_query.cpp:
##########
@@ -0,0 +1,246 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/segment_v2/inverted_index_query.h"
+
+#include "olap/column_predicate.h"
+#include "olap/key_coder.h"
+#include "olap/utils.h"
+#include "util/time.h"
+
+namespace doris {
+namespace segment_v2 {
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op, const
CppType& value) {
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError("Add value failed! Unsupported
InvertedIndexQueryOp {}",
+ op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op,
PredicateParams* params) {
+ CppType value;
+ from_string(params->value, value, params->precision, params->scale);
+
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ //_low_value_str = value_str;
+ // NOTE:full_encode_ascending will append encoded data to the
end of buffer.
+ // so we need to clear buffer first.
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError(
+ "Add value string fail! Unsupported InvertedIndexQueryOp
{}", op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_VARCHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_CHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_STRING>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::from_string(const std::string& str_value,
CppType& value,
+ int precision, int scale) {
+ StringParser::ParseResult result;
+ if constexpr (Type == TYPE_TINYINT || Type == TYPE_SMALLINT || Type ==
TYPE_INT ||
+ Type == TYPE_BIGINT || Type == TYPE_LARGEINT) {
+ std::from_chars(str_value.data(), str_value.data() + str_value.size(),
value);
+ } else if constexpr (Type == TYPE_FLOAT) {
+ value = std::stof(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DOUBLE) {
+ value = std::stod(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DATE) {
+ value = timestamp_from_date(str_value);
+ } else if constexpr (Type == TYPE_DATEV2) {
+ value = timestamp_from_date_v2(str_value);
+ } else if constexpr (Type == TYPE_DATETIME) {
+ value = timestamp_from_datetime(str_value);
+ } else if constexpr (Type == TYPE_DATETIMEV2) {
+ value = timestamp_from_datetime_v2(str_value);
+ } else if constexpr (Type == TYPE_CHAR || Type == TYPE_VARCHAR || Type ==
TYPE_STRING) {
+ value = str_value;
+ } else if constexpr (Type == TYPE_BOOLEAN) {
+ value = StringParser::string_to_bool(str_value.c_str(),
str_value.size(), &result);
+ } else if constexpr (Type == TYPE_DECIMALV2) {
+ decimal12_t tmp = {precision, scale};
+ value.from_string(str_value);
+ value = tmp;
Review Comment:
warning: no viable overloaded '=' [clang-diagnostic-error]
```cpp
value = tmp;
^
```
**be/src/runtime/decimalv2_value.h:49:** candidate function (the implicit
copy assignment operator) not viable: no known conversion from
'doris::decimal12_t' to 'const doris::DecimalV2Value' for 1st argument
```cpp
class DecimalV2Value {
^
```
**be/src/runtime/decimalv2_value.h:49:** candidate function (the implicit
move assignment operator) not viable: no known conversion from
'doris::decimal12_t' to 'doris::DecimalV2Value' for 1st argument
```cpp
class DecimalV2Value {
^
```
##########
be/src/olap/rowset/segment_v2/inverted_index_query.cpp:
##########
@@ -0,0 +1,246 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/segment_v2/inverted_index_query.h"
+
+#include "olap/column_predicate.h"
+#include "olap/key_coder.h"
+#include "olap/utils.h"
+#include "util/time.h"
+
+namespace doris {
+namespace segment_v2 {
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op, const
CppType& value) {
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError("Add value failed! Unsupported
InvertedIndexQueryOp {}",
+ op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op,
PredicateParams* params) {
+ CppType value;
+ from_string(params->value, value, params->precision, params->scale);
+
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ //_low_value_str = value_str;
+ // NOTE:full_encode_ascending will append encoded data to the
end of buffer.
+ // so we need to clear buffer first.
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError(
+ "Add value string fail! Unsupported InvertedIndexQueryOp
{}", op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_VARCHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_CHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_STRING>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::from_string(const std::string& str_value,
CppType& value,
+ int precision, int scale) {
+ StringParser::ParseResult result;
+ if constexpr (Type == TYPE_TINYINT || Type == TYPE_SMALLINT || Type ==
TYPE_INT ||
+ Type == TYPE_BIGINT || Type == TYPE_LARGEINT) {
+ std::from_chars(str_value.data(), str_value.data() + str_value.size(),
value);
+ } else if constexpr (Type == TYPE_FLOAT) {
+ value = std::stof(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DOUBLE) {
+ value = std::stod(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DATE) {
+ value = timestamp_from_date(str_value);
+ } else if constexpr (Type == TYPE_DATEV2) {
+ value = timestamp_from_date_v2(str_value);
Review Comment:
warning: no viable overloaded '=' [clang-diagnostic-error]
```cpp
value = timestamp_from_date_v2(str_value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.cpp:233:** in
instantiation of member function
'doris::segment_v2::InvertedIndexQuery<doris::TYPE_DATEV2>::from_string'
requested here
```cpp
template class InvertedIndexQuery<TYPE_DATEV2>;
^
```
**be/src/vec/runtime/vdatetime_value.h:1014:** candidate function not
viable: no known conversion from 'uint32_t' (aka 'unsigned int') to 'const
DateV2Value<doris::vectorized::DateV2ValueType>' for 1st argument
```cpp
DateV2Value<T>& operator=(const DateV2Value<T>& other) {
^
```
**be/src/vec/runtime/vdatetime_value.h:1019:** candidate function not
viable: no known conversion from 'uint32_t' (aka 'unsigned int') to
'DateV2Value<doris::vectorized::DateV2ValueType> &' for 1st argument
```cpp
DateV2Value<T>& operator=(DateV2Value<T>& other) {
^
```
##########
be/src/olap/in_list_predicate.h:
##########
@@ -206,13 +206,15 @@ class InListPredicateBase : public ColumnPredicate {
auto column_desc = schema.column(_column_id);
std::string column_name = column_desc->name();
roaring::Roaring indices;
- for (auto value : *_values) {
- InvertedIndexQueryType query_type =
InvertedIndexQueryType::EQUAL_QUERY;
- roaring::Roaring index;
- RETURN_IF_ERROR(iterator->read_from_inverted_index(column_name,
&value, query_type,
- num_rows,
&index));
- indices |= index;
+
+ InvertedIndexQuery<Type> query(column_desc->type_info());
+
+ for (auto& value : *_values) {
+ RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::EQUAL_QUERY,
value));
Review Comment:
warning: no matching member function for call to 'add_value'
[clang-diagnostic-error]
```cpp
RETURN_IF_ERROR(query.add_value(InvertedIndexQueryOp::EQUAL_QUERY, value));
^
```
**be/src/common/status.h:507:** expanded from macro 'RETURN_IF_ERROR'
```cpp
Status _status_ = (stmt); \
^
```
**be/src/olap/in_list_predicate.h:82:** in instantiation of member function
'doris::InListPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::IN_LIST>::evaluate' requested here
```cpp
InListPredicateBase(uint32_t column_id, const ConditionType& conditions,
^
```
**be/src/olap/predicate_creator.h:142:** in instantiation of function
template specialization 'doris::InListPredicateBase<doris::TYPE_DECIMALV2,
doris::PredicateType::IN_LIST>::InListPredicateBase<std::vector<std::basic_string<char>>,
std::function<doris::decimal12_t (const std::basic_string<char> &)>>'
requested here
```cpp
return new InListPredicateBase<Type, PT>(index, conditions,
_convert, opposite);
^
```
**be/src/olap/predicate_creator.h:136:** in instantiation of member function
'doris::CustomPredicateCreator<doris::TYPE_DECIMALV2,
doris::PredicateType::IN_LIST, std::vector<std::basic_string<char>>>::create'
requested here
```cpp
CustomPredicateCreator(const std::function<CppType(const std::string&
condition)>& convert)
^
```
**/usr/include/c++/11/bits/unique_ptr.h:961:** in instantiation of member
function 'doris::CustomPredicateCreator<doris::TYPE_DECIMALV2,
doris::PredicateType::IN_LIST,
std::vector<std::basic_string<char>>>::CustomPredicateCreator' requested here
```cpp
{ return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
^
```
**be/src/olap/predicate_creator.h:178:** in instantiation of function
template specialization
'std::make_unique<doris::CustomPredicateCreator<doris::TYPE_DECIMALV2,
doris::PredicateType::IN_LIST, std::vector<std::basic_string<char>>>, (lambda
at /github/workspace/be/src/olap/predicate_creator.h:180:17)>' requested here
```cpp
return std::make_unique<CustomPredicateCreator<TYPE_DECIMALV2, PT,
ConditionType>>(
^
```
**be/src/olap/predicate_creator.h:241:** in instantiation of function
template specialization 'doris::get_creator<doris::PredicateType::IN_LIST,
std::vector<std::basic_string<char>>>' requested here
```cpp
return get_creator<PT, ConditionType>(column.type())
^
```
**be/src/olap/predicate_creator.h:258:** in instantiation of function
template specialization 'doris::create_predicate<doris::PredicateType::IN_LIST,
std::vector<std::basic_string<char>>>' requested here
```cpp
return create_predicate<PT, std::vector<std::string>>(column, index,
conditions, opposite,
^
```
**be/src/olap/predicate_creator.h:286:** in instantiation of function
template specialization
'doris::create_list_predicate<doris::PredicateType::IN_LIST>' requested here
```cpp
create = create_list_predicate<PredicateType::IN_LIST>;
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:166:** candidate
function not viable: no known conversion from 'const doris::decimal12_t' to
'const doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::CppType'
(aka 'const doris::DecimalV2Value') for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, const CppType& value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.h:167:** candidate
function not viable: no known conversion from 'const doris::decimal12_t' to
'doris::PredicateParams *' for 2nd argument
```cpp
Status add_value(InvertedIndexQueryOp op, PredicateParams* params);
^
```
##########
be/src/olap/rowset/segment_v2/inverted_index_query.cpp:
##########
@@ -0,0 +1,246 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/segment_v2/inverted_index_query.h"
+
+#include "olap/column_predicate.h"
+#include "olap/key_coder.h"
+#include "olap/utils.h"
+#include "util/time.h"
+
+namespace doris {
+namespace segment_v2 {
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op, const
CppType& value) {
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError("Add value failed! Unsupported
InvertedIndexQueryOp {}",
+ op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op,
PredicateParams* params) {
+ CppType value;
+ from_string(params->value, value, params->precision, params->scale);
+
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ //_low_value_str = value_str;
+ // NOTE:full_encode_ascending will append encoded data to the
end of buffer.
+ // so we need to clear buffer first.
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError(
+ "Add value string fail! Unsupported InvertedIndexQueryOp
{}", op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_VARCHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_CHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_STRING>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::from_string(const std::string& str_value,
CppType& value,
+ int precision, int scale) {
+ StringParser::ParseResult result;
+ if constexpr (Type == TYPE_TINYINT || Type == TYPE_SMALLINT || Type ==
TYPE_INT ||
+ Type == TYPE_BIGINT || Type == TYPE_LARGEINT) {
+ std::from_chars(str_value.data(), str_value.data() + str_value.size(),
value);
+ } else if constexpr (Type == TYPE_FLOAT) {
+ value = std::stof(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DOUBLE) {
+ value = std::stod(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DATE) {
+ value = timestamp_from_date(str_value);
Review Comment:
warning: no viable overloaded '=' [clang-diagnostic-error]
```cpp
value = timestamp_from_date(str_value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.cpp:234:** in
instantiation of member function
'doris::segment_v2::InvertedIndexQuery<doris::TYPE_DATE>::from_string'
requested here
```cpp
template class InvertedIndexQuery<TYPE_DATE>;
^
```
**be/src/runtime/datetime_value.h:163:** candidate function (the implicit
copy assignment operator) not viable: no known conversion from 'uint32_t' (aka
'unsigned int') to 'const doris::DateTimeValue' for 1st argument
```cpp
class DateTimeValue {
^
```
**be/src/runtime/datetime_value.h:163:** candidate function (the implicit
move assignment operator) not viable: no known conversion from 'uint32_t' (aka
'unsigned int') to 'doris::DateTimeValue' for 1st argument
```cpp
class DateTimeValue {
^
```
##########
be/src/olap/rowset/segment_v2/inverted_index_query.cpp:
##########
@@ -0,0 +1,246 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/segment_v2/inverted_index_query.h"
+
+#include "olap/column_predicate.h"
+#include "olap/key_coder.h"
+#include "olap/utils.h"
+#include "util/time.h"
+
+namespace doris {
+namespace segment_v2 {
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op, const
CppType& value) {
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError("Add value failed! Unsupported
InvertedIndexQueryOp {}",
+ op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op,
PredicateParams* params) {
+ CppType value;
+ from_string(params->value, value, params->precision, params->scale);
+
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ //_low_value_str = value_str;
+ // NOTE:full_encode_ascending will append encoded data to the
end of buffer.
+ // so we need to clear buffer first.
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError(
+ "Add value string fail! Unsupported InvertedIndexQueryOp
{}", op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_VARCHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_CHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_STRING>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::from_string(const std::string& str_value,
CppType& value,
+ int precision, int scale) {
+ StringParser::ParseResult result;
+ if constexpr (Type == TYPE_TINYINT || Type == TYPE_SMALLINT || Type ==
TYPE_INT ||
+ Type == TYPE_BIGINT || Type == TYPE_LARGEINT) {
+ std::from_chars(str_value.data(), str_value.data() + str_value.size(),
value);
+ } else if constexpr (Type == TYPE_FLOAT) {
+ value = std::stof(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DOUBLE) {
+ value = std::stod(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DATE) {
+ value = timestamp_from_date(str_value);
+ } else if constexpr (Type == TYPE_DATEV2) {
+ value = timestamp_from_date_v2(str_value);
+ } else if constexpr (Type == TYPE_DATETIME) {
+ value = timestamp_from_datetime(str_value);
+ } else if constexpr (Type == TYPE_DATETIMEV2) {
+ value = timestamp_from_datetime_v2(str_value);
Review Comment:
warning: no viable overloaded '=' [clang-diagnostic-error]
```cpp
value = timestamp_from_datetime_v2(str_value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.cpp:236:** in
instantiation of member function
'doris::segment_v2::InvertedIndexQuery<doris::TYPE_DATETIMEV2>::from_string'
requested here
```cpp
template class InvertedIndexQuery<TYPE_DATETIMEV2>;
^
```
**be/src/vec/runtime/vdatetime_value.h:1014:** candidate function not
viable: no known conversion from 'uint64_t' (aka 'unsigned long') to 'const
DateV2Value<doris::vectorized::DateTimeV2ValueType>' for 1st argument
```cpp
DateV2Value<T>& operator=(const DateV2Value<T>& other) {
^
```
**be/src/vec/runtime/vdatetime_value.h:1019:** candidate function not
viable: no known conversion from 'uint64_t' (aka 'unsigned long') to
'DateV2Value<doris::vectorized::DateTimeV2ValueType> &' for 1st argument
```cpp
DateV2Value<T>& operator=(DateV2Value<T>& other) {
^
```
##########
be/src/olap/rowset/segment_v2/inverted_index_query.cpp:
##########
@@ -0,0 +1,246 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/segment_v2/inverted_index_query.h"
+
+#include "olap/column_predicate.h"
+#include "olap/key_coder.h"
+#include "olap/utils.h"
+#include "util/time.h"
+
+namespace doris {
+namespace segment_v2 {
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op, const
CppType& value) {
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError("Add value failed! Unsupported
InvertedIndexQueryOp {}",
+ op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op,
PredicateParams* params) {
+ CppType value;
+ from_string(params->value, value, params->precision, params->scale);
+
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ //_low_value_str = value_str;
+ // NOTE:full_encode_ascending will append encoded data to the
end of buffer.
+ // so we need to clear buffer first.
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError(
+ "Add value string fail! Unsupported InvertedIndexQueryOp
{}", op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_VARCHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_CHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_STRING>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::from_string(const std::string& str_value,
CppType& value,
+ int precision, int scale) {
+ StringParser::ParseResult result;
+ if constexpr (Type == TYPE_TINYINT || Type == TYPE_SMALLINT || Type ==
TYPE_INT ||
+ Type == TYPE_BIGINT || Type == TYPE_LARGEINT) {
+ std::from_chars(str_value.data(), str_value.data() + str_value.size(),
value);
+ } else if constexpr (Type == TYPE_FLOAT) {
+ value = std::stof(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DOUBLE) {
+ value = std::stod(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DATE) {
+ value = timestamp_from_date(str_value);
+ } else if constexpr (Type == TYPE_DATEV2) {
+ value = timestamp_from_date_v2(str_value);
+ } else if constexpr (Type == TYPE_DATETIME) {
+ value = timestamp_from_datetime(str_value);
+ } else if constexpr (Type == TYPE_DATETIMEV2) {
+ value = timestamp_from_datetime_v2(str_value);
+ } else if constexpr (Type == TYPE_CHAR || Type == TYPE_VARCHAR || Type ==
TYPE_STRING) {
+ value = str_value;
+ } else if constexpr (Type == TYPE_BOOLEAN) {
+ value = StringParser::string_to_bool(str_value.c_str(),
str_value.size(), &result);
+ } else if constexpr (Type == TYPE_DECIMALV2) {
+ decimal12_t tmp = {precision, scale};
+ value.from_string(str_value);
Review Comment:
warning: no member named 'from_string' in 'doris::DecimalV2Value'
[clang-diagnostic-error]
```cpp
value.from_string(str_value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.cpp:232:** in
instantiation of member function
'doris::segment_v2::InvertedIndexQuery<doris::TYPE_DECIMALV2>::from_string'
requested here
```cpp
template class InvertedIndexQuery<TYPE_DECIMALV2>;
^
```
##########
be/src/olap/rowset/segment_v2/inverted_index_query.cpp:
##########
@@ -0,0 +1,246 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/segment_v2/inverted_index_query.h"
+
+#include "olap/column_predicate.h"
+#include "olap/key_coder.h"
+#include "olap/utils.h"
+#include "util/time.h"
+
+namespace doris {
+namespace segment_v2 {
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op, const
CppType& value) {
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError("Add value failed! Unsupported
InvertedIndexQueryOp {}",
+ op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::add_value(InvertedIndexQueryOp op,
PredicateParams* params) {
+ CppType value;
+ from_string(params->value, value, params->precision, params->scale);
+
+ if (is_match_query(op) || is_equal_query(op)) {
+ return add_fixed_value(op, value);
+ }
+ if (_high_value > _low_value) {
+ switch (op) {
+ case InvertedIndexQueryOp::GREATER_THAN_QUERY: {
+ if (value >= _low_value) {
+ _low_value = value;
+ //_low_value_str = value_str;
+ // NOTE:full_encode_ascending will append encoded data to the
end of buffer.
+ // so we need to clear buffer first.
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::GREATER_EQUAL_QUERY: {
+ if (value > _low_value) {
+ _low_value = value;
+ _low_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_low_value_encoded);
+ _low_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_THAN_QUERY: {
+ if (value <= _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ case InvertedIndexQueryOp::LESS_EQUAL_QUERY: {
+ if (value < _high_value) {
+ _high_value = value;
+ _high_value_encoded.clear();
+ _value_key_coder->full_encode_ascending(&value,
&_high_value_encoded);
+ _high_op = op;
+ }
+ break;
+ }
+
+ default: {
+ return Status::InternalError(
+ "Add value string fail! Unsupported InvertedIndexQueryOp
{}", op);
+ }
+ }
+ }
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_VARCHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_CHAR>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <>
+Status
InvertedIndexQuery<PrimitiveType::TYPE_STRING>::add_fixed_value(InvertedIndexQueryOp
op,
+ const
CppType& value) {
+ _fixed_values.insert(value);
+
+ _high_value = value;
+ _low_value = value;
+ _high_op = op;
+ _low_op = op;
+
+ return Status::OK();
+}
+
+template <PrimitiveType Type>
+Status InvertedIndexQuery<Type>::from_string(const std::string& str_value,
CppType& value,
+ int precision, int scale) {
+ StringParser::ParseResult result;
+ if constexpr (Type == TYPE_TINYINT || Type == TYPE_SMALLINT || Type ==
TYPE_INT ||
+ Type == TYPE_BIGINT || Type == TYPE_LARGEINT) {
+ std::from_chars(str_value.data(), str_value.data() + str_value.size(),
value);
+ } else if constexpr (Type == TYPE_FLOAT) {
+ value = std::stof(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DOUBLE) {
+ value = std::stod(str_value, nullptr);
+ } else if constexpr (Type == TYPE_DATE) {
+ value = timestamp_from_date(str_value);
+ } else if constexpr (Type == TYPE_DATEV2) {
+ value = timestamp_from_date_v2(str_value);
+ } else if constexpr (Type == TYPE_DATETIME) {
+ value = timestamp_from_datetime(str_value);
Review Comment:
warning: no viable overloaded '=' [clang-diagnostic-error]
```cpp
value = timestamp_from_datetime(str_value);
^
```
**be/src/olap/rowset/segment_v2/inverted_index_query.cpp:235:** in
instantiation of member function
'doris::segment_v2::InvertedIndexQuery<doris::TYPE_DATETIME>::from_string'
requested here
```cpp
template class InvertedIndexQuery<TYPE_DATETIME>;
^
```
**be/src/runtime/datetime_value.h:163:** candidate function (the implicit
copy assignment operator) not viable: no known conversion from 'uint64_t' (aka
'unsigned long') to 'const doris::DateTimeValue' for 1st argument
```cpp
class DateTimeValue {
^
```
**be/src/runtime/datetime_value.h:163:** candidate function (the implicit
move assignment operator) not viable: no known conversion from 'uint64_t' (aka
'unsigned long') to 'doris::DateTimeValue' for 1st argument
```cpp
class DateTimeValue {
^
```
--
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]