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

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

commit c99d35a49b17794fae07bbe255607cc054b43e8e
Author: Pxl <pxl...@qq.com>
AuthorDate: Thu Dec 1 13:07:12 2022 +0800

    [Enhancement](profile)  enhance column predicates display on profile 
(#14664)
---
 be/src/olap/bitmap_filter_predicate.h            |  2 +-
 be/src/olap/bloom_filter_predicate.h             |  2 +-
 be/src/olap/column_predicate.h                   |  4 +-
 be/src/olap/comparison_predicate.h               |  5 +--
 be/src/olap/in_list_predicate.h                  |  5 +--
 be/src/olap/like_column_predicate.h              |  2 +-
 be/src/olap/null_predicate.h                     |  2 +-
 be/src/olap/rowset/segment_v2/segment_iterator.h | 50 +++++++++++-------------
 be/src/vec/exec/scan/new_olap_scanner.cpp        |  6 +--
 be/src/vec/exec/scan/new_olap_scanner.h          |  5 ---
 10 files changed, 34 insertions(+), 49 deletions(-)

diff --git a/be/src/olap/bitmap_filter_predicate.h 
b/be/src/olap/bitmap_filter_predicate.h
index 053cdb748d..9bf444b889 100644
--- a/be/src/olap/bitmap_filter_predicate.h
+++ b/be/src/olap/bitmap_filter_predicate.h
@@ -100,7 +100,7 @@ private:
         return new_size;
     }
 
-    std::string _debug_string() override {
+    std::string _debug_string() const override {
         return "BitmapFilterColumnPredicate(" + type_to_string(T) + ")";
     }
 
diff --git a/be/src/olap/bloom_filter_predicate.h 
b/be/src/olap/bloom_filter_predicate.h
index d9d6a964f3..efa00a5930 100644
--- a/be/src/olap/bloom_filter_predicate.h
+++ b/be/src/olap/bloom_filter_predicate.h
@@ -120,7 +120,7 @@ private:
         return new_size;
     }
 
-    std::string _debug_string() override {
+    std::string _debug_string() const override {
         std::string info = "BloomFilterColumnPredicate(" + type_to_string(T) + 
")";
         return info;
     }
diff --git a/be/src/olap/column_predicate.h b/be/src/olap/column_predicate.h
index 7e1981cc86..9cdd22860f 100644
--- a/be/src/olap/column_predicate.h
+++ b/be/src/olap/column_predicate.h
@@ -166,13 +166,13 @@ public:
     }
     uint32_t column_id() const { return _column_id; }
 
-    virtual std::string debug_string() {
+    virtual std::string debug_string() const {
         return _debug_string() + ", column_id=" + std::to_string(_column_id) +
                ", opposite=" + (_opposite ? "true" : "false");
     }
 
 protected:
-    virtual std::string _debug_string() = 0;
+    virtual std::string _debug_string() const = 0;
 
     uint32_t _column_id;
     // TODO: the value is only in delete condition, better be template value
diff --git a/be/src/olap/comparison_predicate.h 
b/be/src/olap/comparison_predicate.h
index 95be483206..909f638813 100644
--- a/be/src/olap/comparison_predicate.h
+++ b/be/src/olap/comparison_predicate.h
@@ -601,7 +601,7 @@ private:
         }
     }
 
-    std::string _debug_string() override {
+    std::string _debug_string() const override {
         std::string info =
                 "ComparisonPredicateBase(" + type_to_string(Type) + ", " + 
type_to_string(PT) + ")";
         return info;
@@ -611,7 +611,4 @@ private:
     static constexpr PrimitiveType EvalType = (Type == TYPE_CHAR ? TYPE_STRING 
: Type);
 };
 
-template <PrimitiveType Type, PredicateType PT>
-constexpr PrimitiveType ComparisonPredicateBase<Type, PT>::EvalType;
-
 } //namespace doris
diff --git a/be/src/olap/in_list_predicate.h b/be/src/olap/in_list_predicate.h
index 1a9fac9dcd..503aa340b0 100644
--- a/be/src/olap/in_list_predicate.h
+++ b/be/src/olap/in_list_predicate.h
@@ -609,7 +609,7 @@ private:
         }
     }
 
-    std::string _debug_string() override {
+    std::string _debug_string() const override {
         std::string info =
                 "InListPredicateBase(" + type_to_string(Type) + ", " + 
type_to_string(PT) + ")";
         return info;
@@ -636,7 +636,4 @@ private:
     std::list<std::string> _temp_datas;
 };
 
-template <PrimitiveType Type, PredicateType PT>
-constexpr PrimitiveType InListPredicateBase<Type, PT>::EvalType;
-
 } //namespace doris
diff --git a/be/src/olap/like_column_predicate.h 
b/be/src/olap/like_column_predicate.h
index 85f30b5ab4..7a7e8be2cd 100644
--- a/be/src/olap/like_column_predicate.h
+++ b/be/src/olap/like_column_predicate.h
@@ -144,7 +144,7 @@ private:
         }
     }
 
-    std::string _debug_string() override {
+    std::string _debug_string() const override {
         std::string info = "LikeColumnPredicate";
         return info;
     }
diff --git a/be/src/olap/null_predicate.h b/be/src/olap/null_predicate.h
index 7155036bce..3910151f68 100644
--- a/be/src/olap/null_predicate.h
+++ b/be/src/olap/null_predicate.h
@@ -81,7 +81,7 @@ public:
     void evaluate_vec(const vectorized::IColumn& column, uint16_t size, bool* 
flags) const override;
 
 private:
-    std::string _debug_string() override {
+    std::string _debug_string() const override {
         std::string info = "NullPredicate(" + std::string(_is_null ? "is_null" 
: "not_null") + ")";
         return info;
     }
diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.h 
b/be/src/olap/rowset/segment_v2/segment_iterator.h
index 5a7a35773d..09dbc0db9c 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.h
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.h
@@ -66,37 +66,34 @@ public:
     uint64_t data_id() const override { return _segment->id(); }
 
     bool update_profile(RuntimeProfile* profile) override {
-        if (_short_cir_eval_predicate.empty() && 
_pre_eval_block_predicate.empty()) {
-            if (_col_predicates.empty()) {
-                return false;
-            }
-
-            std::string info;
-            for (auto pred : _col_predicates) {
-                info += "\n" + pred->debug_string();
-            }
-            profile->add_info_string("ColumnPredicates", info);
-        } else {
-            if (!_short_cir_eval_predicate.empty()) {
-                std::string info;
-                for (auto pred : _short_cir_eval_predicate) {
-                    info += "\n" + pred->debug_string();
-                }
-                profile->add_info_string("Short Circuit ColumnPredicates", 
info);
-            }
-            if (!_pre_eval_block_predicate.empty()) {
-                std::string info;
-                for (auto pred : _pre_eval_block_predicate) {
-                    info += "\n" + pred->debug_string();
-                }
-                profile->add_info_string("Pre Evaluate Block 
ColumnPredicates", info);
-            }
+        bool updated = false;
+        updated |= _update_profile(profile, _short_cir_eval_predicate, 
"ShortCircuitPredicates");
+        updated |= _update_profile(profile, _pre_eval_block_predicate, 
"PreEvaluatePredicates");
+
+        if (_opts.delete_condition_predicates != nullptr) {
+            std::set<const ColumnPredicate*> delete_predicate_set;
+            
_opts.delete_condition_predicates->get_all_column_predicate(delete_predicate_set);
+            updated |= _update_profile(profile, delete_predicate_set, 
"DeleteConditionPredicates");
         }
 
-        return true;
+        return updated;
     }
 
 private:
+    template <typename Container>
+    bool _update_profile(RuntimeProfile* profile, const Container& predicates,
+                         const std::string& title) {
+        if (predicates.empty()) {
+            return false;
+        }
+        std::string info;
+        for (auto pred : predicates) {
+            info += "\n" + pred->debug_string();
+        }
+        profile->add_info_string(title, info);
+        return true;
+    }
+
     Status _init(bool is_vec = false);
 
     Status _init_return_column_iterators();
@@ -170,7 +167,6 @@ private:
 
     void _update_max_row(const vectorized::Block* block);
 
-private:
     class BitmapRangeIterator;
     class BackwardBitmapRangeIterator;
 
diff --git a/be/src/vec/exec/scan/new_olap_scanner.cpp 
b/be/src/vec/exec/scan/new_olap_scanner.cpp
index 224affa4bc..fe1a010df4 100644
--- a/be/src/vec/exec/scan/new_olap_scanner.cpp
+++ b/be/src/vec/exec/scan/new_olap_scanner.cpp
@@ -309,13 +309,13 @@ Status NewOlapScanner::_init_return_columns() {
 }
 
 Status NewOlapScanner::_get_block_impl(RuntimeState* state, Block* block, 
bool* eof) {
-    if (!_profile_updated) {
-        _profile_updated = _tablet_reader->update_profile(_profile);
-    }
     // Read one block from block reader
     // ATTN: Here we need to let the _get_block_impl method guarantee the 
semantics of the interface,
     // that is, eof can be set to true only when the returned block is empty.
     RETURN_IF_ERROR(_tablet_reader->next_block_with_aggregation(block, 
nullptr, nullptr, eof));
+    if (!_profile_updated) {
+        _profile_updated = _tablet_reader->update_profile(_profile);
+    }
     if (block->rows() > 0) {
         *eof = false;
     }
diff --git a/be/src/vec/exec/scan/new_olap_scanner.h 
b/be/src/vec/exec/scan/new_olap_scanner.h
index e07f38ea2b..5f253ea93f 100644
--- a/be/src/vec/exec/scan/new_olap_scanner.h
+++ b/be/src/vec/exec/scan/new_olap_scanner.h
@@ -18,10 +18,7 @@
 #pragma once
 
 #include "exec/olap_utils.h"
-#include "exprs/bitmapfilter_predicate.h"
-#include "exprs/bloomfilter_predicate.h"
 #include "exprs/function_filter.h"
-#include "exprs/hybrid_set.h"
 #include "olap/reader.h"
 #include "util/runtime_profile.h"
 #include "vec/exec/scan/vscanner.h"
@@ -45,7 +42,6 @@ public:
 
     Status close(RuntimeState* state) override;
 
-public:
     Status prepare(const TPaloScanRange& scan_range, const 
std::vector<OlapScanRange*>& key_ranges,
                    VExprContext** vconjunct_ctx_ptr, const 
std::vector<TCondition>& filters,
                    const FilterPredicates& filter_predicates,
@@ -67,7 +63,6 @@ private:
 
     Status _init_return_columns();
 
-private:
     bool _aggregation;
     bool _need_agg_finalize;
 


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

Reply via email to