You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/06/06 15:15:13 UTC

[doris] 11/36: [feature](profile)Add the filtering info of the in filter in profile #20321

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

kxiao pushed a commit to branch branch-2.0-beta
in repository https://gitbox.apache.org/repos/asf/doris.git

commit a368255baa1133047c46d64c48a635abfd8fb5fe
Author: Mryange <59...@users.noreply.github.com>
AuthorDate: Tue Jun 6 10:24:59 2023 +0800

    [feature](profile)Add the filtering info of the in filter in profile #20321
    
    image Currently, it is difficult to obtain the id of in filters,so, the some in filters's id is -1.
---
 be/src/exprs/hybrid_set.h                          |  3 +++
 be/src/exprs/runtime_filter.cpp                    |  3 +++
 be/src/olap/in_list_predicate.h                    | 15 ++++++++++-----
 be/src/olap/rowset/segment_v2/segment_iterator.cpp |  6 +-----
 be/src/vec/exec/scan/new_olap_scan_node.cpp        |  5 +----
 5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/be/src/exprs/hybrid_set.h b/be/src/exprs/hybrid_set.h
index 73508d56d2..fa7bd97176 100644
--- a/be/src/exprs/hybrid_set.h
+++ b/be/src/exprs/hybrid_set.h
@@ -222,6 +222,9 @@ public:
         LOG(FATAL) << "HybridSetBase not support find_batch_nullable_negative";
     }
 
+    void set_filter_id(int filter_id) { _filter_id = filter_id; }
+    int get_filter_id() const { return _filter_id; }
+    int _filter_id = -1;
     class IteratorBase {
     public:
         IteratorBase() = default;
diff --git a/be/src/exprs/runtime_filter.cpp b/be/src/exprs/runtime_filter.cpp
index 499c291ae5..ef8543e136 100644
--- a/be/src/exprs/runtime_filter.cpp
+++ b/be/src/exprs/runtime_filter.cpp
@@ -1069,6 +1069,9 @@ public:
         if (_context.bitmap_filter_func) {
             _context.bitmap_filter_func->set_filter_id(id);
         }
+        if (_context.hybrid_set) {
+            _context.hybrid_set->set_filter_id(id);
+        }
     }
 
 private:
diff --git a/be/src/olap/in_list_predicate.h b/be/src/olap/in_list_predicate.h
index 7751e02eb6..8af69efc66 100644
--- a/be/src/olap/in_list_predicate.h
+++ b/be/src/olap/in_list_predicate.h
@@ -260,6 +260,8 @@ public:
 
     uint16_t evaluate(const vectorized::IColumn& column, uint16_t* sel,
                       uint16_t size) const override {
+        int64_t new_size = 0;
+
         if (column.is_nullable()) {
             auto* nullable_col =
                     vectorized::check_and_get_column<vectorized::ColumnNullable>(column);
@@ -269,19 +271,22 @@ public:
             auto& nested_col = nullable_col->get_nested_column();
 
             if (_opposite) {
-                return _base_evaluate<true, true>(&nested_col, &null_map, sel, size);
+                new_size = _base_evaluate<true, true>(&nested_col, &null_map, sel, size);
             } else {
-                return _base_evaluate<true, false>(&nested_col, &null_map, sel, size);
+                new_size = _base_evaluate<true, false>(&nested_col, &null_map, sel, size);
             }
         } else {
             if (_opposite) {
-                return _base_evaluate<false, true>(&column, nullptr, sel, size);
+                new_size = _base_evaluate<false, true>(&column, nullptr, sel, size);
             } else {
-                return _base_evaluate<false, false>(&column, nullptr, sel, size);
+                new_size = _base_evaluate<false, false>(&column, nullptr, sel, size);
             }
         }
+        _evaluated_rows += size;
+        _passed_rows += new_size;
+        return new_size;
     }
-
+    int get_filter_id() const override { return _values->get_filter_id(); }
     template <bool is_and>
     void _evaluate_bit(const vectorized::IColumn& column, const uint16_t* sel, uint16_t size,
                        bool* flags) const {
diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index 8eed9410a9..284ae71f1a 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -1262,9 +1262,7 @@ Status SegmentIterator::_vec_init_lazy_materialization() {
             } else {
                 short_cir_pred_col_id_set.insert(cid);
                 _short_cir_eval_predicate.push_back(predicate);
-                if (predicate->get_filter_id() != -1) {
-                    _filter_info_id.push_back(predicate);
-                }
+                _filter_info_id.push_back(predicate);
             }
         }
 
@@ -1644,8 +1642,6 @@ uint16_t SegmentIterator::_evaluate_short_circuit_predicate(uint16_t* vec_sel_ro
     }
     _opts.stats->short_circuit_cond_input_rows += original_size;
     _opts.stats->rows_short_circuit_cond_filtered += original_size - selected_size;
-    _opts.stats->short_circuit_cond_input_rows += original_size;
-    _opts.stats->rows_short_circuit_cond_filtered += original_size - selected_size;
 
     // evaluate delete condition
     original_size = selected_size;
diff --git a/be/src/vec/exec/scan/new_olap_scan_node.cpp b/be/src/vec/exec/scan/new_olap_scan_node.cpp
index 3c3c272ff7..a5a18a97dd 100644
--- a/be/src/vec/exec/scan/new_olap_scan_node.cpp
+++ b/be/src/vec/exec/scan/new_olap_scan_node.cpp
@@ -645,9 +645,6 @@ bool NewOlapScanNode::_is_key_column(const std::string& key_name) {
 }
 
 void NewOlapScanNode::add_filter_info(int id, const PredicateFilterInfo& update_info) {
-    static std::vector<std::string> PredicateTypeName(20, "Unknow");
-    PredicateTypeName[static_cast<int>(PredicateType::BF)] = "BloomFilter";
-    PredicateTypeName[static_cast<int>(PredicateType::BITMAP_FILTER)] = "BitmapFilter";
     // update
     _filter_info[id].filtered_row += update_info.filtered_row;
     _filter_info[id].input_row += update_info.input_row;
@@ -657,7 +654,7 @@ void NewOlapScanNode::add_filter_info(int id, const PredicateFilterInfo& update_
     std::string filter_name = "RuntimeFilterInfo id ";
     filter_name += std::to_string(id);
     std::string info_str;
-    info_str += "type = " + PredicateTypeName[info.type] + ", ";
+    info_str += "type = " + type_to_string(static_cast<PredicateType>(info.type)) + ", ";
     info_str += "input = " + std::to_string(info.input_row) + ", ";
     info_str += "filtered = " + std::to_string(info.filtered_row);
     info_str = "[" + info_str + "]";


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