csun5285 commented on code in PR #38908: URL: https://github.com/apache/doris/pull/38908#discussion_r1717909734
########## be/src/olap/rowset/segment_v2/segment_iterator.cpp: ########## @@ -2836,125 +2401,46 @@ 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() { + 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_iterators(_inverted_index_iterators_by_col_name); + context->set_storage_name_and_type(_storage_name_and_type_by_col_name); + context->set_inverted_index_expr_status(_common_expr_inverted_index_status); + _common_expr_ctxs_push_down.emplace_back(context); } + return Status::OK(); } Review Comment: for (const auto& child : expr->children()) { if (child->is_slot_ref()) { auto* column_slot_ref = assert_cast<vectorized::VSlotRef*>(child.get()); _common_expr_inverted_index_status[column_slot_ref->expr_name()] [expr.get()] = false; } else if (!child->children().empty()) { stack.emplace(children[i]); } } ########## be/src/olap/rowset/segment_v2/segment_iterator.cpp: ########## @@ -2836,125 +2401,46 @@ 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() { + 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_iterators(_inverted_index_iterators_by_col_name); + context->set_storage_name_and_type(_storage_name_and_type_by_col_name); + context->set_inverted_index_expr_status(_common_expr_inverted_index_status); + _common_expr_ctxs_push_down.emplace_back(context); } + return Status::OK(); } Review Comment: for (const auto& child : expr->children()) { if (child->is_slot_ref()) { auto* column_slot_ref = assert_cast<vectorized::VSlotRef*>(child.get()); _common_expr_inverted_index_status[column_slot_ref->expr_name()] [expr.get()] = false; } else if (!child->children().empty()) { stack.emplace(children[i]); } } -- 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