You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/23 09:24:52 UTC

[GitHub] [doris] Gabriel39 commented on a diff in pull request #10355: Improve performance like/not like filter through pushdown function to storage engine

Gabriel39 commented on code in PR #10355:
URL: https://github.com/apache/doris/pull/10355#discussion_r904728074


##########
be/src/vec/exec/volap_scan_node.cpp:
##########
@@ -729,6 +729,72 @@ Status VOlapScanNode::build_olap_filters() {
     return Status::OK();
 }
 
+Status VOlapScanNode::build_function_filters() {
+    for (int conj_idx = 0; conj_idx < _conjunct_ctxs.size(); ++conj_idx) {
+        ExprContext* ex_ctx = _conjunct_ctxs[conj_idx];
+        Expr* fn_expr = ex_ctx->root();
+        bool opposite = false;
+
+        if (TExprNodeType::COMPOUND_PRED == fn_expr->node_type())
+        {
+            if (TExprOpcode::COMPOUND_NOT == fn_expr->op())

Review Comment:
   combine these two conditions into one



##########
be/src/vec/exec/volap_scan_node.cpp:
##########
@@ -772,17 +838,22 @@ Status VOlapScanNode::start_scan(RuntimeState* state) {
     }
 
     VLOG_CRITICAL << "BuildOlapFilters";
-    // 3. Using ColumnValueRange to Build StorageEngine filters
+    // 3.1 Using ColumnValueRange to Build StorageEngine filters
     RETURN_IF_ERROR(build_olap_filters());
+    // 3.2 Function pushdown
+    if (config::enable_function_pushdown)
+        RETURN_IF_ERROR(build_function_filters());
 
     VLOG_CRITICAL << "BuildScanKey";
     // 4. Using `Key Column`'s ColumnValueRange to split ScanRange to several `Sub ScanRange`
     RETURN_IF_ERROR(build_scan_key());
 
     VLOG_CRITICAL << "Filter idle conjuncts";
-    // 5. Filter idle conjunct which already trans to olap filters
+    // 5.1 Filter idle conjunct which already trans to olap filters
     // this must be after build_scan_key, it will free the StringValue memory
     remove_pushed_conjuncts(state);
+    // 5.2 move the pushed function context
+    move_pushed_func_conjuncts(state);

Review Comment:
   why use a new function here? I think we should just use `like` function as a new predicate type which could be pushed down and just reuse `remove_pushed_conjuncts` to do this job.



##########
be/src/vec/exec/volap_scan_node.cpp:
##########
@@ -729,6 +729,72 @@ Status VOlapScanNode::build_olap_filters() {
     return Status::OK();
 }
 
+Status VOlapScanNode::build_function_filters() {
+    for (int conj_idx = 0; conj_idx < _conjunct_ctxs.size(); ++conj_idx) {
+        ExprContext* ex_ctx = _conjunct_ctxs[conj_idx];
+        Expr* fn_expr = ex_ctx->root();
+        bool opposite = false;
+
+        if (TExprNodeType::COMPOUND_PRED == fn_expr->node_type())
+        {
+            if (TExprOpcode::COMPOUND_NOT == fn_expr->op())
+            {
+                fn_expr = fn_expr->get_child(0);
+                opposite = true;
+            }
+        }
+
+        if (TExprNodeType::FUNCTION_CALL == fn_expr->node_type())
+        {
+            // currently only support like / not like
+            if ("like" == fn_expr->fn().name.function_name)

Review Comment:
   ditto



##########
be/src/vec/exec/volap_scan_node.cpp:
##########
@@ -729,6 +729,72 @@ Status VOlapScanNode::build_olap_filters() {
     return Status::OK();
 }
 
+Status VOlapScanNode::build_function_filters() {
+    for (int conj_idx = 0; conj_idx < _conjunct_ctxs.size(); ++conj_idx) {
+        ExprContext* ex_ctx = _conjunct_ctxs[conj_idx];
+        Expr* fn_expr = ex_ctx->root();
+        bool opposite = false;
+
+        if (TExprNodeType::COMPOUND_PRED == fn_expr->node_type())
+        {
+            if (TExprOpcode::COMPOUND_NOT == fn_expr->op())
+            {
+                fn_expr = fn_expr->get_child(0);
+                opposite = true;
+            }
+        }
+
+        if (TExprNodeType::FUNCTION_CALL == fn_expr->node_type())

Review Comment:
   Maybe you could make this if-block more concise.
   1. check if we could apply this rule
   2. compute child_idx for slot_ref
   3. use child_idx as slotref and 1 - child_idx as stringliteral.
   
   This process is very similar to other predicates



-- 
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-unsubscribe@doris.apache.org

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


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