You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/03 10:07:20 UTC

[doris] branch branch-1.2-lts updated: [fix](scan) Avoid using incorrect cache code in ComparisonPredicate (#18341)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 13b055d296 [fix](scan) Avoid using incorrect cache code in ComparisonPredicate (#18341)
13b055d296 is described below

commit 13b055d296cd0350f7a03c2631077c166326b6cb
Author: Jerry Hu <mr...@gmail.com>
AuthorDate: Mon Apr 3 18:07:10 2023 +0800

    [fix](scan) Avoid using incorrect cache code in ComparisonPredicate (#18341)
---
 be/src/olap/comparison_predicate.h                 | 8 ++++++--
 be/src/olap/rowset/segment_v2/segment_iterator.cpp | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/comparison_predicate.h b/be/src/olap/comparison_predicate.h
index 599bbd50ab..6898eeb1c1 100644
--- a/be/src/olap/comparison_predicate.h
+++ b/be/src/olap/comparison_predicate.h
@@ -36,7 +36,9 @@ public:
               _value(value) {}
 
     void clone(ColumnPredicate** to) const override {
-        *to = new ComparisonPredicateBase(_column_id, _value, _opposite);
+        auto* cloned = new ComparisonPredicateBase(_column_id, _value, _opposite);
+        cloned->_cache_code_enabled = true;
+        *to = cloned;
     }
 
     bool need_to_clone() const override { return true; }
@@ -628,7 +630,8 @@ private:
 
     __attribute__((flatten)) int32_t _find_code_from_dictionary_column(
             const vectorized::ColumnDictI32& column) const {
-        if (UNLIKELY(_cached_code == _InvalidateCodeValue)) {
+        /// if _cache_code_enabled is false, always find the code from dict.
+        if (UNLIKELY(!_cache_code_enabled || _cached_code == _InvalidateCodeValue)) {
             _cached_code = _is_range() ? column.find_code_by_bound(_value, _is_greater(), _is_eq())
                                        : column.find_code(_value);
         }
@@ -643,6 +646,7 @@ private:
 
     static constexpr int32_t _InvalidateCodeValue = std::numeric_limits<int32_t>::max();
     mutable int32_t _cached_code;
+    bool _cache_code_enabled = false;
     T _value;
 };
 
diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index d9cac145c8..9fded3c31d 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -166,6 +166,7 @@ SegmentIterator::~SegmentIterator() {
 Status SegmentIterator::init(const StorageReadOptions& opts) {
     _opts = opts;
 
+    _col_predicates.clear();
     for (auto& predicate : opts.column_predicates) {
         if (predicate->need_to_clone()) {
             ColumnPredicate* cloned;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org