airborne12 commented on code in PR #32620:
URL: https://github.com/apache/doris/pull/32620#discussion_r1572313810


##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -1210,6 +1227,34 @@ Status SegmentIterator::_apply_inverted_index() {
         }
     }
 
+    // support expr to evaluate inverted index
+    std::unordered_map<ColumnId, std::pair<vectorized::NameAndTypePair, 
InvertedIndexIterator*>>
+            iter_map;
+
+    for (auto col_id : _common_expr_columns) {
+        if (_check_apply_by_inverted_index(col_id)) {
+            iter_map[col_id] = std::make_pair(_storage_name_and_type[col_id],
+                                              
_inverted_index_iterators[col_id].get());
+        }
+    }
+    for (auto expr_ctx : _common_expr_ctxs_push_down) {
+        // _inverted_index_iterators has all column ids which has inverted 
index
+        // _common_expr_columns has all column ids from 
_common_expr_ctxs_push_down
+        // if current bitmap is already empty just return
+        if (_row_bitmap.isEmpty()) {
+            break;
+        }
+        std::shared_ptr<roaring::Roaring> result_bitmap = 
std::make_shared<roaring::Roaring>();
+        if (Status st = expr_ctx->eval_inverted_index(iter_map, num_rows(), 
result_bitmap.get());
+            !st.ok() && st.code() != ErrorCode::NOT_IMPLEMENTED_ERROR) {
+            LOG(WARNING) << "failed to evaluate inverted index for expr_ctx"
+                         << expr_ctx->root()->debug_string() << ", error msg: 
" << st.to_string();
+        } else {
+            // every single result of expr_ctx must be `and` collection 
relationship
+            _row_bitmap &= *result_bitmap;
+        }
+    }
+

Review Comment:
   after expr was evaluated in index , it will be evaluated again later in 
common expr processing phase?



-- 
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]

Reply via email to