This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 7d035486ad [Opt](vec) opt the fast execute logic to remove useless
function call (#16532)
7d035486ad is described below
commit 7d035486ad6739f9f40b48505733ed5333d3eaf6
Author: HappenLee <[email protected]>
AuthorDate: Thu Feb 9 14:12:40 2023 +0800
[Opt](vec) opt the fast execute logic to remove useless function call
(#16532)
---
be/src/vec/exprs/vectorized_fn_call.cpp | 10 ++++++----
be/src/vec/exprs/vectorized_fn_call.h | 1 +
be/src/vec/functions/function.h | 13 +++----------
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/be/src/vec/exprs/vectorized_fn_call.cpp
b/be/src/vec/exprs/vectorized_fn_call.cpp
index 2f9359a4ee..5fabfd0e70 100644
--- a/be/src/vec/exprs/vectorized_fn_call.cpp
+++ b/be/src/vec/exprs/vectorized_fn_call.cpp
@@ -63,6 +63,7 @@ doris::Status VectorizedFnCall::prepare(doris::RuntimeState*
state,
}
VExpr::register_function_context(state, context);
_expr_name = fmt::format("{}({})", _fn.name.function_name,
child_expr_name);
+ _can_fast_execute = _function->can_fast_execute();
return Status::OK();
}
@@ -93,10 +94,11 @@ doris::Status VectorizedFnCall::execute(VExprContext*
context, doris::vectorized
size_t num_columns_without_result = block->columns();
// prepare a column to save result
block->insert({nullptr, _data_type, _expr_name});
- if (_function->can_fast_execute()) {
- bool ok = fast_execute(context->fn_context(_fn_context_index), *block,
arguments,
- num_columns_without_result, block->rows());
- if (ok) {
+ if (_can_fast_execute) {
+ // if not find fast execute result column, means do not need check
fast execute again
+ _can_fast_execute =
fast_execute(context->fn_context(_fn_context_index), *block, arguments,
+ num_columns_without_result,
block->rows());
+ if (_can_fast_execute) {
*result_column_id = num_columns_without_result;
return Status::OK();
}
diff --git a/be/src/vec/exprs/vectorized_fn_call.h
b/be/src/vec/exprs/vectorized_fn_call.h
index 9434f02c94..c2fba08ccc 100644
--- a/be/src/vec/exprs/vectorized_fn_call.h
+++ b/be/src/vec/exprs/vectorized_fn_call.h
@@ -40,6 +40,7 @@ public:
private:
FunctionBasePtr _function;
+ bool _can_fast_execute = false;
std::string _expr_name;
};
} // namespace doris::vectorized
diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h
index 85e1f02394..2a770011b4 100644
--- a/be/src/vec/functions/function.h
+++ b/be/src/vec/functions/function.h
@@ -541,16 +541,9 @@ public:
bool is_deterministic() const override { return
function->is_deterministic(); }
bool can_fast_execute() const override {
- return function->get_name() == "eq" || function->get_name() == "ne" ||
- function->get_name() == "lt" || function->get_name() == "gt" ||
- function->get_name() == "le" || function->get_name() == "ge" ||
- function->get_name() == "match_any" || function->get_name() ==
"match_all" ||
- function->get_name() == "match_phrase" ||
- function->get_name() == "match_element_eq" ||
- function->get_name() == "match_element_lt" ||
- function->get_name() == "match_element_gt" ||
- function->get_name() == "match_element_le" ||
- function->get_name() == "match_element_ge";
+ auto function_name = function->get_name();
+ return function_name == "eq" || function_name == "ne" || function_name
== "lt" ||
+ function_name == "gt" || function_name == "le" || function_name
== "ge";
}
bool is_deterministic_in_scope_of_query() const override {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]