be/src/exprs/vectorized_fn_call.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | #include <gen_cpp/Types_types.h> |
20 | | |
21 | | #include <string> |
22 | | #include <vector> |
23 | | |
24 | | #include "common/status.h" |
25 | | #include "core/block/column_numbers.h" |
26 | | #include "exprs/function/function.h" |
27 | | #include "exprs/function_context.h" |
28 | | #include "exprs/vexpr.h" |
29 | | #include "exprs/vexpr_context.h" |
30 | | #include "exprs/vliteral.h" |
31 | | #include "exprs/vslot_ref.h" |
32 | | #include "runtime/runtime_state.h" |
33 | | #include "storage/index/ann/ann_range_search_runtime.h" |
34 | | |
35 | | namespace doris { |
36 | | class RowDescriptor; |
37 | | class RuntimeState; |
38 | | class TExprNode; |
39 | | } // namespace doris |
40 | | |
41 | | namespace doris { |
42 | | #include "common/compile_check_begin.h" |
43 | | |
44 | | class Block; |
45 | | class VExprContext; |
46 | | |
47 | | class VectorizedFnCall : public VExpr { |
48 | | ENABLE_FACTORY_CREATOR(VectorizedFnCall); |
49 | | |
50 | | public: |
51 | | #ifdef BE_TEST |
52 | | VectorizedFnCall() = default; |
53 | | #endif |
54 | | VectorizedFnCall(const TExprNode& node); |
55 | | |
56 | | Status execute_column(VExprContext* context, const Block* block, Selector* selector, |
57 | | size_t count, ColumnPtr& result_column) const override; |
58 | | Status execute_runtime_filter(VExprContext* context, const Block* block, |
59 | | const uint8_t* __restrict filter, size_t count, |
60 | | ColumnPtr& result_column, ColumnPtr* arg_column) const override; |
61 | | Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override; |
62 | | Status prepare(RuntimeState* state, const RowDescriptor& desc, VExprContext* context) override; |
63 | | Status open(RuntimeState* state, VExprContext* context, |
64 | | FunctionContext::FunctionStateScope scope) override; |
65 | | void close(VExprContext* context, FunctionContext::FunctionStateScope scope) override; |
66 | | const std::string& expr_name() const override; |
67 | | std::string function_name() const; |
68 | | std::string debug_string() const override; |
69 | | double execute_cost() const override; |
70 | 750k | bool is_blockable() const override { |
71 | 750k | return _function->is_blockable() || |
72 | 750k | std::any_of(_children.begin(), _children.end(), |
73 | 1.41M | [](VExprSPtr child) { return child->is_blockable(); }); |
74 | 750k | } |
75 | 2.07M | bool is_constant() const override { |
76 | 2.07M | if (!_function->is_use_default_implementation_for_constants() || |
77 | | // udf function with no argument, can't sure it's must return const column |
78 | 2.07M | (_fn.binary_type == TFunctionBinaryType::JAVA_UDF && _children.empty())) { |
79 | 281k | return false; |
80 | 281k | } |
81 | 1.79M | return VExpr::is_constant(); |
82 | 2.07M | } |
83 | | static std::string debug_string(const std::vector<VectorizedFnCall*>& exprs); |
84 | | |
85 | | bool can_push_down_to_index() const override; |
86 | | bool equals(const VExpr& other) override; |
87 | | |
88 | | size_t estimate_memory(const size_t rows) override; |
89 | | |
90 | | Status evaluate_ann_range_search( |
91 | | const segment_v2::AnnRangeSearchRuntime& runtime, |
92 | | const std::vector<std::unique_ptr<segment_v2::IndexIterator>>& cid_to_index_iterators, |
93 | | const std::vector<ColumnId>& idx_to_cid, |
94 | | const std::vector<std::unique_ptr<segment_v2::ColumnIterator>>& column_iterators, |
95 | | roaring::Roaring& row_bitmap, segment_v2::AnnIndexStats& ann_index_stats) override; |
96 | | |
97 | | void prepare_ann_range_search(const doris::VectorSearchUserParams& params, |
98 | | segment_v2::AnnRangeSearchRuntime& runtime, |
99 | | bool& suitable_for_ann_index) override; |
100 | | |
101 | | protected: |
102 | | FunctionBasePtr _function; |
103 | | std::string _expr_name; |
104 | | std::string _function_name; |
105 | | |
106 | | private: |
107 | | Status _do_execute(VExprContext* context, const Block* block, Selector* selector, size_t count, |
108 | | ColumnPtr& result_column, ColumnPtr* arg_column) const; |
109 | | }; |
110 | | |
111 | | #include "common/compile_check_end.h" |
112 | | } // namespace doris |