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


##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -2836,125 +2425,47 @@ Status 
SegmentIterator::current_block_row_locations(std::vector<RowLocation>* bl
     return Status::OK();
 }
 
-void SegmentIterator::_calculate_pred_in_remaining_conjunct_root(
-        const vectorized::VExprSPtr& expr) {
-    if (expr == nullptr) {
-        return;
-    }
-
-    if (expr->fn().name.function_name == "multi_match") {
-        return;
-    }
-
-    auto& children = expr->children();
-    for (int i = 0; i < children.size(); ++i) {
-        _calculate_pred_in_remaining_conjunct_root(children[i]);
-    }
-
-    auto node_type = expr->node_type();
-    if (node_type == TExprNodeType::SLOT_REF) {
-        auto slot_expr = 
std::dynamic_pointer_cast<doris::vectorized::VSlotRef>(expr);
-        if (_column_predicate_info->column_name.empty()) {
-            _column_predicate_info->column_name = expr->expr_name();
-            _column_predicate_info->column_id = slot_expr->column_id();
-        } else {
-            // If column name already exists, create a new ColumnPredicateInfo
-            // if expr is columnA > columnB, then column name will exist, in 
this situation, we need to add it to _column_pred_in_remaining_vconjunct
-            auto new_column_pred_info = 
std::make_shared<ColumnPredicateInfo>();
-            new_column_pred_info->column_name = expr->expr_name();
-            new_column_pred_info->column_id = slot_expr->column_id();
-            
_column_pred_in_remaining_vconjunct[new_column_pred_info->column_name].push_back(
-                    *new_column_pred_info);
-        }
-    } else if (_is_literal_node(node_type)) {
-        auto v_literal_expr = static_cast<const 
doris::vectorized::VLiteral*>(expr.get());
-        _column_predicate_info->query_values.insert(v_literal_expr->value());
-    } else if (node_type == TExprNodeType::NULL_LITERAL) {
-        if (!_column_predicate_info->column_name.empty()) {
-            auto v_literal_expr = static_cast<const 
doris::vectorized::VLiteral*>(expr.get());
-            
_column_predicate_info->query_values.insert(v_literal_expr->value());
-        }
-    } else {
-        if (node_type == TExprNodeType::MATCH_PRED) {
-            _column_predicate_info->query_op = "match";
-        } else if (node_type == TExprNodeType::IN_PRED) {
-            if (expr->op() == TExprOpcode::type::FILTER_IN) {
-                _column_predicate_info->query_op = "in";
-            } else {
-                _column_predicate_info->query_op = "not_in";
-            }
-        } else if (node_type != TExprNodeType::COMPOUND_PRED) {
-            _column_predicate_info->query_op = expr->fn().name.function_name;
-        }
-
-        if (!_column_predicate_info->is_empty()) {
-            
_column_pred_in_remaining_vconjunct[_column_predicate_info->column_name].push_back(
-                    *_column_predicate_info);
-            _column_predicate_info.reset(new ColumnPredicateInfo());
-        }
+Status SegmentIterator::_construct_compound_expr_context() {
+    auto inverted_index_context = 
std::make_shared<vectorized::InvertedIndexContext>(
+            _schema->column_ids(), _inverted_index_iterators, 
_storage_name_and_type,
+            _common_expr_inverted_index_status);
+    for (const auto& expr_ctx : _opts.common_expr_ctxs_push_down) {
+        vectorized::VExprContextSPtr context;
+        RETURN_IF_ERROR(expr_ctx->clone(_opts.runtime_state, context));
+        context->set_inverted_index_context(inverted_index_context);
+        _common_expr_ctxs_push_down.emplace_back(context);
     }
+    return Status::OK();
 }
 
-void SegmentIterator::_calculate_func_in_remaining_conjunct_root() {
-    auto hash = [](const vectorized::VExprSPtr& expr) -> std::size_t {
-        return std::hash<std::string>()(expr->expr_name());
-    };
-    auto equal = [](const vectorized::VExprSPtr& lhs, const 
vectorized::VExprSPtr& rhs) -> bool {
-        return lhs->equals(*rhs);
-    };
-
-    uint32_t next_id = 0;
-    std::unordered_map<vectorized::VExprSPtr, uint32_t, decltype(hash), 
decltype(equal)> unique_map(
-            0, hash, equal);
-
-    auto gen_func_unique_id = [&unique_map, &next_id](const 
vectorized::VExprSPtr& expr) {
-        auto it = unique_map.find(expr);
-        if (it != unique_map.end()) {
-            return it->second;
-        } else {
-            unique_map[expr] = ++next_id;
-            return next_id;
-        }
-    };
-
+void SegmentIterator::_calculate_expr_in_remaining_conjunct_root() {
     for (const auto& root_expr_ctx : _common_expr_ctxs_push_down) {
         const auto& root_expr = root_expr_ctx->root();
         if (root_expr == nullptr) {
             continue;
         }
 
-        std::stack<std::pair<vectorized::VExprSPtr, bool>> stack;
-        stack.emplace(root_expr, false);
+        std::stack<vectorized::VExprSPtr> stack;
+        stack.emplace(root_expr);
 
         while (!stack.empty()) {
-            const auto& [expr, has_compound_pred] = stack.top();
+            const auto& expr = stack.top();
             stack.pop();
 
-            bool current_has_compound_pred =
-                    has_compound_pred || (expr->node_type() == 
TExprNodeType::COMPOUND_PRED);
-
-            if (expr->fn().name.function_name == "multi_match") {
-                expr->set_index_unique_id(gen_func_unique_id(expr));
-                if (current_has_compound_pred) {
-                    compound_func_exprs.emplace_back(expr);
-                } else {
-                    no_compound_func_exprs.emplace_back(expr);
-                }
-
-                for (int32_t i = expr->get_num_children() - 1; i >= 0; i--) {
-                    auto child_expr = expr->get_child(i);
-                    if (child_expr->node_type() == 
TExprNodeType::type::SLOT_REF) {
-                        std::string result_sign = 
BeConsts::BLOCK_TEMP_COLUMN_PREFIX +
-                                                  
std::to_string(expr->index_unique_id());
-                        
_func_name_to_result_sign[child_expr->expr_name()].push_back(result_sign);
+            if (vectorized::VExpr::is_directly_action_on_a_slot(*expr)) {
+                for (const auto& child : expr->children()) {
+                    if (child->is_slot_ref()) {

Review Comment:
   Need to be that.



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to