ExecExprVisitor.h 5.4 KB
Newer Older
F
FluorineDog 已提交
1 2 3 4 5 6 7 8 9 10 11
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License

N
neza2017 已提交
12 13 14 15
#pragma once
// Generated File
// DO NOT EDIT
#include <optional>
16
#include <boost/variant.hpp>
17
#include <type_traits>
F
FluorineDog 已提交
18 19
#include <utility>
#include <deque>
20
#include "segcore/SegmentGrowingImpl.h"
G
GuoRentong 已提交
21
#include "query/ExprImpl.h"
N
neza2017 已提交
22
#include "ExprVisitor.h"
23
#include "ExecPlanNodeVisitor.h"
N
neza2017 已提交
24 25

namespace milvus::query {
26 27 28 29

void
AppendOneChunk(BitsetType& result, const FixedVector<bool>& chunk_res);

N
neza2017 已提交
30
class ExecExprVisitor : public ExprVisitor {
N
neza2017 已提交
31 32
 public:
    void
F
FluorineDog 已提交
33
    visit(LogicalUnaryExpr& expr) override;
N
neza2017 已提交
34 35

    void
F
FluorineDog 已提交
36
    visit(LogicalBinaryExpr& expr) override;
N
neza2017 已提交
37 38 39 40 41

    void
    visit(TermExpr& expr) override;

    void
42 43
    visit(UnaryRangeExpr& expr) override;

44 45 46
    void
    visit(BinaryArithOpEvalRangeExpr& expr) override;

47 48
    void
    visit(BinaryRangeExpr& expr) override;
N
neza2017 已提交
49

50 51 52
    void
    visit(CompareExpr& expr) override;

53 54 55
    void
    visit(ExistsExpr& expr) override;

N
neza2017 已提交
56
 public:
Y
yah01 已提交
57 58 59
    ExecExprVisitor(const segcore::SegmentInternalInterface& segment,
                    int64_t row_count,
                    Timestamp timestamp)
60 61 62 63 64 65 66 67 68 69 70 71 72 73
        : segment_(segment),
          row_count_(row_count),
          timestamp_(timestamp),
          plan_visitor_(nullptr) {
    }

    ExecExprVisitor(const segcore::SegmentInternalInterface& segment,
                    ExecPlanNodeVisitor* plan_visitor,
                    int64_t row_count,
                    Timestamp timestamp)
        : segment_(segment),
          plan_visitor_(plan_visitor),
          row_count_(row_count),
          timestamp_(timestamp) {
N
neza2017 已提交
74
    }
75 76

    BitsetType
N
neza2017 已提交
77
    call_child(Expr& expr) {
78
        Assert(!bitset_opt_.has_value());
N
neza2017 已提交
79
        expr.accept(*this);
80 81 82
        Assert(bitset_opt_.has_value());
        auto res = std::move(bitset_opt_);
        bitset_opt_ = std::nullopt;
83
        return std::move(res.value());
N
neza2017 已提交
84 85
    }

G
GuoRentong 已提交
86
 public:
F
FluorineDog 已提交
87
    template <typename T, typename IndexFunc, typename ElementFunc>
G
GuoRentong 已提交
88
    auto
Y
yah01 已提交
89 90 91
    ExecRangeVisitorImpl(FieldId field_id,
                         IndexFunc func,
                         ElementFunc element_func) -> BitsetType;
92

93
    template <typename T, typename IndexFunc, typename ElementFunc>
94
    auto
Y
yah01 已提交
95 96 97
    ExecDataRangeVisitorImpl(FieldId field_id,
                             IndexFunc index_func,
                             ElementFunc element_func) -> BitsetType;
98

99 100 101 102
    template <typename T>
    auto
    ExecUnaryRangeVisitorDispatcherImpl(UnaryRangeExpr& expr_raw) -> BitsetType;

103 104
    template <typename T>
    auto
105
    ExecUnaryRangeVisitorDispatcher(UnaryRangeExpr& expr_raw) -> BitsetType;
G
GuoRentong 已提交
106

107 108 109 110
    template <typename ExprValueType>
    auto
    ExecUnaryRangeVisitorDispatcherJson(UnaryRangeExpr& expr_raw) -> BitsetType;

111 112 113 114 115
    template <typename ExprValueType>
    auto
    ExecBinaryArithOpEvalRangeVisitorDispatcherJson(
        BinaryArithOpEvalRangeExpr& expr_raw) -> BitsetType;

116 117
    template <typename T>
    auto
Y
yah01 已提交
118 119
    ExecBinaryArithOpEvalRangeVisitorDispatcher(
        BinaryArithOpEvalRangeExpr& expr_raw) -> BitsetType;
120

121 122 123 124 125
    template <typename ExprValueType>
    auto
    ExecBinaryRangeVisitorDispatcherJson(BinaryRangeExpr& expr_raw)
        -> BitsetType;

G
GuoRentong 已提交
126 127
    template <typename T>
    auto
128
    ExecBinaryRangeVisitorDispatcher(BinaryRangeExpr& expr_raw) -> BitsetType;
G
GuoRentong 已提交
129

S
sunby 已提交
130 131
    template <typename T>
    auto
132
    ExecTermVisitorImpl(TermExpr& expr_raw) -> BitsetType;
S
sunby 已提交
133

134 135 136 137
    template <typename T>
    auto
    ExecTermVisitorImplTemplate(TermExpr& expr_raw) -> BitsetType;

138 139 140 141 142 143 144 145
    template <typename ExprValueType>
    auto
    ExecTermJsonVariableInField(TermExpr& expr_raw) -> BitsetType;

    template <typename ExprValueType>
    auto
    ExecTermJsonFieldInVariable(TermExpr& expr_raw) -> BitsetType;

146 147 148 149
    template <typename ExprValueType>
    auto
    ExecTermVisitorImplTemplateJson(TermExpr& expr_raw) -> BitsetType;

150 151
    template <typename CmpFunc>
    auto
Y
yah01 已提交
152 153
    ExecCompareExprDispatcher(CompareExpr& expr, CmpFunc cmp_func)
        -> BitsetType;
154

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    template <typename CmpFunc>
    BitsetType
    ExecCompareExprDispatcherForNonIndexedSegment(CompareExpr& expr,
                                                  CmpFunc cmp_func);

    // This function only used to compare sealed segment
    // which has only one chunk.
    template <typename T, typename U, typename CmpFunc>
    TargetBitmap
    ExecCompareRightType(const T* left_raw_data,
                         const FieldId& right_field_id,
                         const int64_t current_chunk_id,
                         CmpFunc cmp_func);

    template <typename T, typename CmpFunc>
    BitsetType
    ExecCompareLeftType(const FieldId& left_field_id,
                        const FieldId& right_field_id,
                        const DataType& right_field_type,
                        CmpFunc cmp_func);

N
neza2017 已提交
176
 private:
177
    const segcore::SegmentInternalInterface& segment_;
F
FluorineDog 已提交
178
    Timestamp timestamp_;
179 180 181
    int64_t row_count_;

    BitsetTypeOpt bitset_opt_;
182
    ExecPlanNodeVisitor* plan_visitor_;
N
neza2017 已提交
183 184
};
}  // namespace milvus::query