Coverage Report

Created: 2026-04-10 16:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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
43
class Block;
44
class VExprContext;
45
46
class VectorizedFnCall : public VExpr {
47
    ENABLE_FACTORY_CREATOR(VectorizedFnCall);
48
49
public:
50
#ifdef BE_TEST
51
    VectorizedFnCall() = default;
52
#endif
53
    VectorizedFnCall(const TExprNode& node);
54
55
    Status execute_column(VExprContext* context, const Block* block, Selector* selector,
56
                          size_t count, ColumnPtr& result_column) const override;
57
    Status execute_runtime_filter(VExprContext* context, const Block* block,
58
                                  const uint8_t* __restrict filter, size_t count,
59
                                  ColumnPtr& result_column, ColumnPtr* arg_column) const override;
60
    Status evaluate_inverted_index(VExprContext* context, uint32_t segment_num_rows) override;
61
    Status prepare(RuntimeState* state, const RowDescriptor& desc, VExprContext* context) override;
62
    Status open(RuntimeState* state, VExprContext* context,
63
                FunctionContext::FunctionStateScope scope) override;
64
    void close(VExprContext* context, FunctionContext::FunctionStateScope scope) override;
65
    const std::string& expr_name() const override;
66
    std::string function_name() const;
67
    std::string debug_string() const override;
68
    double execute_cost() const override;
69
726k
    bool is_blockable() const override {
70
726k
        return _function->is_blockable() ||
71
726k
               std::any_of(_children.begin(), _children.end(),
72
1.35M
                           [](VExprSPtr child) { return child->is_blockable(); });
73
726k
    }
74
1.94M
    bool is_constant() const override {
75
1.94M
        if (!_function->is_use_default_implementation_for_constants() ||
76
            // udf function with no argument, can't sure it's must return const column
77
1.94M
            (_fn.binary_type == TFunctionBinaryType::JAVA_UDF && _children.empty())) {
78
262k
            return false;
79
262k
        }
80
1.68M
        return VExpr::is_constant();
81
1.94M
    }
82
    static std::string debug_string(const std::vector<VectorizedFnCall*>& exprs);
83
84
    bool can_push_down_to_index() const override;
85
    bool equals(const VExpr& other) override;
86
87
    size_t estimate_memory(const size_t rows) override;
88
89
    Status evaluate_ann_range_search(
90
            const segment_v2::AnnRangeSearchRuntime& runtime,
91
            const std::vector<std::unique_ptr<segment_v2::IndexIterator>>& cid_to_index_iterators,
92
            const std::vector<ColumnId>& idx_to_cid,
93
            const std::vector<std::unique_ptr<segment_v2::ColumnIterator>>& column_iterators,
94
            roaring::Roaring& row_bitmap, segment_v2::AnnIndexStats& ann_index_stats) override;
95
96
    void prepare_ann_range_search(const doris::VectorSearchUserParams& params,
97
                                  segment_v2::AnnRangeSearchRuntime& runtime,
98
                                  bool& suitable_for_ann_index) override;
99
100
protected:
101
    FunctionBasePtr _function;
102
    std::string _expr_name;
103
    std::string _function_name;
104
105
private:
106
    Status _do_execute(VExprContext* context, const Block* block, Selector* selector, size_t count,
107
                       ColumnPtr& result_column, ColumnPtr* arg_column) const;
108
};
109
110
} // namespace doris