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

airborne pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new c43ed5f9e21 [Fix](inverted index) fix profile metrics for inverted 
index after refactor #40324 (#40583)
c43ed5f9e21 is described below

commit c43ed5f9e216f184c69e58e42292dc4f972dc33f
Author: airborne12 <airborn...@gmail.com>
AuthorDate: Tue Sep 10 14:13:06 2024 +0800

    [Fix](inverted index) fix profile metrics for inverted index after refactor 
#40324 (#40583)
    
    cherry pick from #40324
---
 be/src/olap/rowset/segment_v2/segment_iterator.cpp | 64 +++++++++++-----------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp 
b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
index d83ec7deffd..288a5df19ff 100644
--- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp
@@ -514,35 +514,41 @@ Status 
SegmentIterator::_get_row_ranges_by_column_conditions() {
     }
 
     RETURN_IF_ERROR(_apply_bitmap_index());
-    RETURN_IF_ERROR(_apply_inverted_index());
-    RETURN_IF_ERROR(_apply_index_expr());
-    size_t input_rows = _row_bitmap.cardinality();
-    for (auto it = _common_expr_ctxs_push_down.begin(); it != 
_common_expr_ctxs_push_down.end();) {
-        if ((*it)->all_expr_inverted_index_evaluated()) {
-            const auto* result =
-                    
(*it)->get_inverted_index_context()->get_inverted_index_result_for_expr(
-                            (*it)->root().get());
-            if (result != nullptr) {
-                _row_bitmap &= *result->get_data_bitmap();
-                auto root = (*it)->root();
-                auto iter_find = std::find(_remaining_conjunct_roots.begin(),
-                                           _remaining_conjunct_roots.end(), 
root);
-                if (iter_find != _remaining_conjunct_roots.end()) {
-                    _remaining_conjunct_roots.erase(iter_find);
+    {
+        if (_opts.runtime_state &&
+            _opts.runtime_state->query_options().enable_inverted_index_query) {
+            SCOPED_RAW_TIMER(&_opts.stats->inverted_index_filter_timer);
+            size_t input_rows = _row_bitmap.cardinality();
+            RETURN_IF_ERROR(_apply_inverted_index());
+            RETURN_IF_ERROR(_apply_index_expr());
+            for (auto it = _common_expr_ctxs_push_down.begin();
+                 it != _common_expr_ctxs_push_down.end();) {
+                if ((*it)->all_expr_inverted_index_evaluated()) {
+                    const auto* result =
+                            
(*it)->get_inverted_index_context()->get_inverted_index_result_for_expr(
+                                    (*it)->root().get());
+                    if (result != nullptr) {
+                        _row_bitmap &= *result->get_data_bitmap();
+                        auto root = (*it)->root();
+                        auto iter_find = 
std::find(_remaining_conjunct_roots.begin(),
+                                                   
_remaining_conjunct_roots.end(), root);
+                        if (iter_find != _remaining_conjunct_roots.end()) {
+                            _remaining_conjunct_roots.erase(iter_find);
+                        }
+                        it = _common_expr_ctxs_push_down.erase(it);
+                    }
+                } else {
+                    ++it;
                 }
-                it = _common_expr_ctxs_push_down.erase(it);
             }
-        } else {
-            ++it;
-        }
-    }
-
-    _opts.stats->rows_inverted_index_filtered += (input_rows - 
_row_bitmap.cardinality());
-    for (auto cid : _schema->column_ids()) {
-        bool result_true = 
_check_all_conditions_passed_inverted_index_for_column(cid);
+            _opts.stats->rows_inverted_index_filtered += (input_rows - 
_row_bitmap.cardinality());
+            for (auto cid : _schema->column_ids()) {
+                bool result_true = 
_check_all_conditions_passed_inverted_index_for_column(cid);
 
-        if (result_true) {
-            _need_read_data_indices[cid] = false;
+                if (result_true) {
+                    _need_read_data_indices[cid] = false;
+                }
+            }
         }
     }
     if (!_row_bitmap.isEmpty() &&
@@ -972,11 +978,6 @@ bool 
SegmentIterator::_is_target_expr_match_predicate(const vectorized::VExprSPt
 }
 
 Status SegmentIterator::_apply_inverted_index() {
-    SCOPED_RAW_TIMER(&_opts.stats->inverted_index_filter_timer);
-    if (_opts.runtime_state && 
!_opts.runtime_state->query_options().enable_inverted_index_query) {
-        return Status::OK();
-    }
-    size_t input_rows = _row_bitmap.cardinality();
     std::vector<ColumnPredicate*> remaining_predicates;
     std::set<const ColumnPredicate*> no_need_to_pass_column_predicate_set;
 
@@ -994,7 +995,6 @@ Status SegmentIterator::_apply_inverted_index() {
     }
 
     _col_predicates = std::move(remaining_predicates);
-    _opts.stats->rows_inverted_index_filtered += (input_rows - 
_row_bitmap.cardinality());
     return Status::OK();
 }
 


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

Reply via email to