Coverage Report

Created: 2026-11-05 20:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_sequence_match.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
// This file is copied from
19
// https://github.com/ClickHouse/ClickHouse/blob/master/AggregateFunctionSequenceMatch.h
20
// and modified by Doris
21
22
#pragma once
23
24
#include <string.h>
25
26
#include <algorithm>
27
#include <bitset>
28
#include <boost/iterator/iterator_facade.hpp>
29
#include <cctype>
30
#include <cstdint>
31
#include <functional>
32
#include <iterator>
33
#include <memory>
34
#include <stack>
35
#include <string>
36
#include <tuple>
37
#include <utility>
38
#include <vector>
39
40
#include "common/exception.h"
41
#include "common/logging.h"
42
#include "core/assert_cast.h"
43
#include "core/column/column_string.h"
44
#include "core/column/column_vector.h"
45
#include "core/data_type/data_type_number.h"
46
#include "core/pod_array_fwd.h"
47
#include "core/string_ref.h"
48
#include "core/types.h"
49
#include "exprs/aggregate/aggregate_function.h"
50
#include "util/string_parser.hpp"
51
52
namespace doris {
53
class Arena;
54
class BufferReadable;
55
class BufferWritable;
56
class IColumn;
57
} // namespace doris
58
59
namespace doris {
60
61
template <template <typename> class Comparator>
62
struct ComparePairFirst final {
63
    template <typename T1, typename T2>
64
103M
    bool operator()(const std::pair<T1, T2>& lhs, const std::pair<T1, T2>& rhs) const {
65
103M
        return Comparator<T1> {}(lhs.first, rhs.first);
66
103M
    }
_ZNK5doris16ComparePairFirstISt4lessEclINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEEEbRKSt4pairIT_T0_ESE_
Line
Count
Source
64
103M
    bool operator()(const std::pair<T1, T2>& lhs, const std::pair<T1, T2>& rhs) const {
65
103M
        return Comparator<T1> {}(lhs.first, rhs.first);
66
103M
    }
Unexecuted instantiation: _ZNK5doris16ComparePairFirstISt4lessEclINS_16TimeStampNsValueESt6bitsetILm32EEEEbRKSt4pairIT_T0_ESC_
Unexecuted instantiation: _ZNK5doris16ComparePairFirstISt4lessEclINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEEEbRKSt4pairIT_T0_ESE_
Unexecuted instantiation: _ZNK5doris16ComparePairFirstISt4lessEclINS_16TimestampTzValueESt6bitsetILm32EEEEbRKSt4pairIT_T0_ESC_
67
};
68
69
static constexpr size_t MAX_EVENTS = 32;
70
71
/// Max number of iterations to match the pattern against a sequence; exceeding it is an error.
72
constexpr auto sequence_match_max_iterations = 1000000l;
73
74
template <PrimitiveType T, typename Derived>
75
struct AggregateFunctionSequenceMatchData final {
76
    using Timestamp = typename PrimitiveTypeTraits<T>::CppType;
77
    using Events = std::bitset<MAX_EVENTS>;
78
    using TimestampEvents = std::pair<Timestamp, Events>;
79
    using Comparator = ComparePairFirst<std::less>;
80
81
463
    AggregateFunctionSequenceMatchData() { reset(); }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEEC2Ev
Line
Count
Source
81
233
    AggregateFunctionSequenceMatchData() { reset(); }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEEC2Ev
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEEC2Ev
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEEC2Ev
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEEC2Ev
Line
Count
Source
81
230
    AggregateFunctionSequenceMatchData() { reset(); }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEEC2Ev
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEEC2Ev
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEEC2Ev
82
83
public:
84
61
    const std::string get_pattern() const { return pattern; }
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE11get_patternB5cxx11Ev
Line
Count
Source
84
31
    const std::string get_pattern() const { return pattern; }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE11get_patternB5cxx11Ev
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE11get_patternB5cxx11Ev
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE11get_patternB5cxx11Ev
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE11get_patternB5cxx11Ev
Line
Count
Source
84
30
    const std::string get_pattern() const { return pattern; }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE11get_patternB5cxx11Ev
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE11get_patternB5cxx11Ev
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE11get_patternB5cxx11Ev
85
86
146
    size_t get_arg_count() const { return arg_count; }
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE13get_arg_countEv
Line
Count
Source
86
74
    size_t get_arg_count() const { return arg_count; }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE13get_arg_countEv
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE13get_arg_countEv
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE13get_arg_countEv
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE13get_arg_countEv
Line
Count
Source
86
72
    size_t get_arg_count() const { return arg_count; }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE13get_arg_countEv
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE13get_arg_countEv
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE13get_arg_countEv
87
88
6.00M
    void init(const std::string pattern_, size_t arg_count_) {
89
6.00M
        if (!init_flag) {
90
395
            this->pattern = pattern_;
91
395
            this->arg_count = arg_count_;
92
395
            parse_pattern();
93
395
            init_flag = true;
94
395
        }
95
6.00M
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Line
Count
Source
88
3.00M
    void init(const std::string pattern_, size_t arg_count_) {
89
3.00M
        if (!init_flag) {
90
199
            this->pattern = pattern_;
91
199
            this->arg_count = arg_count_;
92
199
            parse_pattern();
93
199
            init_flag = true;
94
199
        }
95
3.00M
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Line
Count
Source
88
3.00M
    void init(const std::string pattern_, size_t arg_count_) {
89
3.00M
        if (!init_flag) {
90
196
            this->pattern = pattern_;
91
196
            this->arg_count = arg_count_;
92
196
            parse_pattern();
93
196
            init_flag = true;
94
196
        }
95
3.00M
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE4initENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm
96
97
509
    void reset() {
98
509
        sorted = true;
99
509
        init_flag = false;
100
509
        pattern_has_time = false;
101
509
        pattern = "";
102
509
        arg_count = 0;
103
509
        conditions_met.reset();
104
509
        conditions_in_pattern.reset();
105
106
509
        events_list.clear();
107
509
        actions.clear();
108
509
        dfa_states.clear();
109
509
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE5resetEv
Line
Count
Source
97
256
    void reset() {
98
256
        sorted = true;
99
256
        init_flag = false;
100
256
        pattern_has_time = false;
101
256
        pattern = "";
102
256
        arg_count = 0;
103
256
        conditions_met.reset();
104
256
        conditions_in_pattern.reset();
105
106
256
        events_list.clear();
107
256
        actions.clear();
108
256
        dfa_states.clear();
109
256
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE5resetEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE5resetEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE5resetEv
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE5resetEv
Line
Count
Source
97
253
    void reset() {
98
253
        sorted = true;
99
253
        init_flag = false;
100
253
        pattern_has_time = false;
101
253
        pattern = "";
102
253
        arg_count = 0;
103
253
        conditions_met.reset();
104
253
        conditions_in_pattern.reset();
105
106
253
        events_list.clear();
107
253
        actions.clear();
108
253
        dfa_states.clear();
109
253
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE5resetEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE5resetEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE5resetEv
110
111
6.00M
    void add(const Timestamp& timestamp, const Events& events) {
112
        /// store information exclusively for rows with at least one event
113
6.00M
        if (events.any()) {
114
6.00M
            events_list.emplace_back(timestamp, events);
115
6.00M
            sorted = false;
116
6.00M
            conditions_met |= events;
117
6.00M
        }
118
6.00M
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE3addERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERKSt6bitsetILm32EE
Line
Count
Source
111
3.00M
    void add(const Timestamp& timestamp, const Events& events) {
112
        /// store information exclusively for rows with at least one event
113
3.00M
        if (events.any()) {
114
3.00M
            events_list.emplace_back(timestamp, events);
115
3.00M
            sorted = false;
116
3.00M
            conditions_met |= events;
117
3.00M
        }
118
3.00M
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE3addERKNS_16TimeStampNsValueERKSt6bitsetILm32EE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE3addERKNS_11DateV2ValueINS_15DateV2ValueTypeEEERKSt6bitsetILm32EE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE3addERKNS_16TimestampTzValueERKSt6bitsetILm32EE
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE3addERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERKSt6bitsetILm32EE
Line
Count
Source
111
3.00M
    void add(const Timestamp& timestamp, const Events& events) {
112
        /// store information exclusively for rows with at least one event
113
3.00M
        if (events.any()) {
114
3.00M
            events_list.emplace_back(timestamp, events);
115
3.00M
            sorted = false;
116
3.00M
            conditions_met |= events;
117
3.00M
        }
118
3.00M
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE3addERKNS_16TimeStampNsValueERKSt6bitsetILm32EE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE3addERKNS_11DateV2ValueINS_15DateV2ValueTypeEEERKSt6bitsetILm32EE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE3addERKNS_16TimestampTzValueERKSt6bitsetILm32EE
119
120
160
    void merge(const AggregateFunctionSequenceMatchData& other) {
121
160
        if (other.events_list.empty()) {
122
88
            return;
123
88
        }
124
125
72
        if (events_list.empty()) {
126
38
            reset();
127
38
            init(other.pattern, other.arg_count);
128
38
        } else if (UNLIKELY(pattern != other.pattern || arg_count != other.arg_count)) {
129
16
            throw Exception(ErrorCode::INVALID_ARGUMENT,
130
16
                            "sequence aggregate states have incompatible patterns or event counts");
131
16
        }
132
133
56
        events_list.insert(std::end(events_list), std::begin(other.events_list),
134
56
                           std::end(other.events_list));
135
56
        sorted = false;
136
56
        conditions_met |= other.conditions_met;
137
56
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE5mergeERKS4_
Line
Count
Source
120
80
    void merge(const AggregateFunctionSequenceMatchData& other) {
121
80
        if (other.events_list.empty()) {
122
44
            return;
123
44
        }
124
125
36
        if (events_list.empty()) {
126
19
            reset();
127
19
            init(other.pattern, other.arg_count);
128
19
        } else if (UNLIKELY(pattern != other.pattern || arg_count != other.arg_count)) {
129
8
            throw Exception(ErrorCode::INVALID_ARGUMENT,
130
8
                            "sequence aggregate states have incompatible patterns or event counts");
131
8
        }
132
133
28
        events_list.insert(std::end(events_list), std::begin(other.events_list),
134
28
                           std::end(other.events_list));
135
28
        sorted = false;
136
28
        conditions_met |= other.conditions_met;
137
28
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE5mergeERKS4_
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE5mergeERKS4_
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE5mergeERKS4_
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE5mergeERKS4_
Line
Count
Source
120
80
    void merge(const AggregateFunctionSequenceMatchData& other) {
121
80
        if (other.events_list.empty()) {
122
44
            return;
123
44
        }
124
125
36
        if (events_list.empty()) {
126
19
            reset();
127
19
            init(other.pattern, other.arg_count);
128
19
        } else if (UNLIKELY(pattern != other.pattern || arg_count != other.arg_count)) {
129
8
            throw Exception(ErrorCode::INVALID_ARGUMENT,
130
8
                            "sequence aggregate states have incompatible patterns or event counts");
131
8
        }
132
133
28
        events_list.insert(std::end(events_list), std::begin(other.events_list),
134
28
                           std::end(other.events_list));
135
28
        sorted = false;
136
28
        conditions_met |= other.conditions_met;
137
28
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE5mergeERKS4_
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE5mergeERKS4_
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE5mergeERKS4_
138
139
    // todo: rethink the sort method.
140
85
    void sort() {
141
85
        if (sorted) return;
142
143
85
        std::sort(std::begin(events_list), std::end(events_list), Comparator {});
144
85
        sorted = true;
145
85
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE4sortEv
Line
Count
Source
140
43
    void sort() {
141
43
        if (sorted) return;
142
143
43
        std::sort(std::begin(events_list), std::end(events_list), Comparator {});
144
43
        sorted = true;
145
43
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE4sortEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE4sortEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE4sortEv
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE4sortEv
Line
Count
Source
140
42
    void sort() {
141
42
        if (sorted) return;
142
143
42
        std::sort(std::begin(events_list), std::end(events_list), Comparator {});
144
42
        sorted = true;
145
42
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE4sortEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE4sortEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE4sortEv
146
147
77
    void write(BufferWritable& buf) const {
148
77
        buf.write_binary(sorted);
149
77
        buf.write_binary(events_list.size());
150
151
77
        for (const auto& events : events_list) {
152
43
            buf.write_binary(events.first);
153
43
            buf.write_binary(events.second.to_ulong());
154
43
        }
155
156
        // This is std::bitset<32>, which will not exceed 32 bits.
157
77
        UInt32 conditions_met_value = (UInt32)conditions_met.to_ulong();
158
77
        buf.write_binary(conditions_met_value);
159
160
77
        buf.write_binary(pattern);
161
77
        buf.write_binary(arg_count);
162
77
    }
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE5writeERNS_14BufferWritableE
Line
Count
Source
147
39
    void write(BufferWritable& buf) const {
148
39
        buf.write_binary(sorted);
149
39
        buf.write_binary(events_list.size());
150
151
39
        for (const auto& events : events_list) {
152
22
            buf.write_binary(events.first);
153
22
            buf.write_binary(events.second.to_ulong());
154
22
        }
155
156
        // This is std::bitset<32>, which will not exceed 32 bits.
157
39
        UInt32 conditions_met_value = (UInt32)conditions_met.to_ulong();
158
39
        buf.write_binary(conditions_met_value);
159
160
39
        buf.write_binary(pattern);
161
39
        buf.write_binary(arg_count);
162
39
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE5writeERNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE5writeERNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE5writeERNS_14BufferWritableE
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE5writeERNS_14BufferWritableE
Line
Count
Source
147
38
    void write(BufferWritable& buf) const {
148
38
        buf.write_binary(sorted);
149
38
        buf.write_binary(events_list.size());
150
151
38
        for (const auto& events : events_list) {
152
21
            buf.write_binary(events.first);
153
21
            buf.write_binary(events.second.to_ulong());
154
21
        }
155
156
        // This is std::bitset<32>, which will not exceed 32 bits.
157
38
        UInt32 conditions_met_value = (UInt32)conditions_met.to_ulong();
158
38
        buf.write_binary(conditions_met_value);
159
160
38
        buf.write_binary(pattern);
161
38
        buf.write_binary(arg_count);
162
38
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE5writeERNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE5writeERNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE5writeERNS_14BufferWritableE
163
164
85
    void read(BufferReadable& buf) {
165
85
        buf.read_binary(sorted);
166
167
85
        size_t events_list_size;
168
85
        buf.read_binary(events_list_size);
169
170
85
        events_list.clear();
171
85
        events_list.reserve(events_list_size);
172
173
136
        for (size_t i = 0; i < events_list_size; ++i) {
174
51
            Timestamp timestamp;
175
51
            buf.read_binary(timestamp);
176
177
51
            UInt64 events;
178
51
            buf.read_binary(events);
179
180
51
            events_list.emplace_back(timestamp, Events {events});
181
51
        }
182
183
85
        UInt32 conditions_met_value;
184
85
        buf.read_binary(conditions_met_value);
185
85
        conditions_met = conditions_met_value;
186
187
85
        buf.read_binary(pattern);
188
85
        buf.read_binary(arg_count);
189
85
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE4readERNS_14BufferReadableE
Line
Count
Source
164
43
    void read(BufferReadable& buf) {
165
43
        buf.read_binary(sorted);
166
167
43
        size_t events_list_size;
168
43
        buf.read_binary(events_list_size);
169
170
43
        events_list.clear();
171
43
        events_list.reserve(events_list_size);
172
173
69
        for (size_t i = 0; i < events_list_size; ++i) {
174
26
            Timestamp timestamp;
175
26
            buf.read_binary(timestamp);
176
177
26
            UInt64 events;
178
26
            buf.read_binary(events);
179
180
26
            events_list.emplace_back(timestamp, Events {events});
181
26
        }
182
183
43
        UInt32 conditions_met_value;
184
43
        buf.read_binary(conditions_met_value);
185
43
        conditions_met = conditions_met_value;
186
187
43
        buf.read_binary(pattern);
188
43
        buf.read_binary(arg_count);
189
43
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE4readERNS_14BufferReadableE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE4readERNS_14BufferReadableE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE4readERNS_14BufferReadableE
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE4readERNS_14BufferReadableE
Line
Count
Source
164
42
    void read(BufferReadable& buf) {
165
42
        buf.read_binary(sorted);
166
167
42
        size_t events_list_size;
168
42
        buf.read_binary(events_list_size);
169
170
42
        events_list.clear();
171
42
        events_list.reserve(events_list_size);
172
173
67
        for (size_t i = 0; i < events_list_size; ++i) {
174
25
            Timestamp timestamp;
175
25
            buf.read_binary(timestamp);
176
177
25
            UInt64 events;
178
25
            buf.read_binary(events);
179
180
25
            events_list.emplace_back(timestamp, Events {events});
181
25
        }
182
183
42
        UInt32 conditions_met_value;
184
42
        buf.read_binary(conditions_met_value);
185
42
        conditions_met = conditions_met_value;
186
187
42
        buf.read_binary(pattern);
188
42
        buf.read_binary(arg_count);
189
42
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE4readERNS_14BufferReadableE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE4readERNS_14BufferReadableE
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE4readERNS_14BufferReadableE
190
191
private:
192
    enum class PatternActionType {
193
        SpecificEvent,
194
        AnyEvent,
195
        KleeneStar,
196
        TimeLessOrEqual,
197
        TimeLess,
198
        TimeGreaterOrEqual,
199
        TimeGreater,
200
        TimeEqual
201
    };
202
203
    struct PatternAction final {
204
        PatternActionType type;
205
        std::uint64_t extra;
206
207
        PatternAction() = default;
208
        explicit PatternAction(const PatternActionType type_, const std::uint64_t extra_ = 0)
209
818
                : type {type_}, extra {extra_} {}
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE13PatternActionC2ENS4_17PatternActionTypeEm
Line
Count
Source
209
414
                : type {type_}, extra {extra_} {}
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE13PatternActionC2ENS4_17PatternActionTypeEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE13PatternActionC2ENS4_17PatternActionTypeEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE13PatternActionC2ENS4_17PatternActionTypeEm
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE13PatternActionC2ENS4_17PatternActionTypeEm
Line
Count
Source
209
404
                : type {type_}, extra {extra_} {}
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE13PatternActionC2ENS4_17PatternActionTypeEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE13PatternActionC2ENS4_17PatternActionTypeEm
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE13PatternActionC2ENS4_17PatternActionTypeEm
210
    };
211
212
    using PatternActions = PODArrayWithStackMemory<PatternAction, 64>;
213
214
    Derived& derived() { return assert_cast<Derived&, TypeCheckOnRelease::DISABLE>(*this); }
215
216
395
    void parse_pattern() {
217
395
        actions.clear();
218
395
        actions.emplace_back(PatternActionType::KleeneStar);
219
220
395
        dfa_states.clear();
221
395
        dfa_states.emplace_back(true);
222
223
395
        pattern_has_time = false;
224
395
        conditions_in_pattern.reset();
225
226
395
        const char* pos = pattern.data();
227
395
        const char* begin = pos;
228
395
        const char* end = pos + pattern.size();
229
395
        const size_t event_count = arg_count - 2;
230
231
        // FE checks a literal pattern, but a constant pattern only BE can evaluate is checked here.
232
395
        auto throw_exception = [&](const std::string& msg) {
233
7
            throw Exception(ErrorCode::INVALID_ARGUMENT, "{} '{}' at position {} of pattern '{}'",
234
7
                            msg, std::string(pos, end), pos - begin, pattern);
235
7
        };
_ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
Line
Count
Source
232
4
        auto throw_exception = [&](const std::string& msg) {
233
4
            throw Exception(ErrorCode::INVALID_ARGUMENT, "{} '{}' at position {} of pattern '{}'",
234
4
                            msg, std::string(pos, end), pos - begin, pattern);
235
4
        };
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
_ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
Line
Count
Source
232
3
        auto throw_exception = [&](const std::string& msg) {
233
3
            throw Exception(ErrorCode::INVALID_ARGUMENT, "{} '{}' at position {} of pattern '{}'",
234
3
                            msg, std::string(pos, end), pos - begin, pattern);
235
3
        };
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE13parse_patternEvENKUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_clESC_
236
237
1.31k
        auto match = [&pos, end](const char* str) mutable {
238
1.31k
            size_t length = strlen(str);
239
1.31k
            if (pos + length <= end && 0 == memcmp(pos, str, length)) {
240
879
                pos += length;
241
879
                return true;
242
879
            }
243
437
            return false;
244
1.31k
        };
_ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE13parse_patternEvENUlPKcE_clES6_
Line
Count
Source
237
671
        auto match = [&pos, end](const char* str) mutable {
238
671
            size_t length = strlen(str);
239
671
            if (pos + length <= end && 0 == memcmp(pos, str, length)) {
240
450
                pos += length;
241
450
                return true;
242
450
            }
243
221
            return false;
244
671
        };
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE13parse_patternEvENUlPKcE_clES6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE13parse_patternEvENUlPKcE_clES6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE13parse_patternEvENUlPKcE_clES6_
_ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE13parse_patternEvENUlPKcE_clES6_
Line
Count
Source
237
645
        auto match = [&pos, end](const char* str) mutable {
238
645
            size_t length = strlen(str);
239
645
            if (pos + length <= end && 0 == memcmp(pos, str, length)) {
240
429
                pos += length;
241
429
                return true;
242
429
            }
243
216
            return false;
244
645
        };
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE13parse_patternEvENUlPKcE_clES6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE13parse_patternEvENUlPKcE_clES6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE13parse_patternEvENUlPKcE_clES6_
245
246
430
        auto parse_uint = [&pos, end](auto& value) {
247
430
            const auto* start = pos;
248
861
            while (pos < end && std::isdigit(static_cast<unsigned char>(*pos))) {
249
431
                ++pos;
250
431
            }
251
252
430
            if (pos == start) {
253
1
                return false;
254
1
            }
255
256
429
            StringParser::ParseResult result;
257
429
            value = StringParser::string_to_int<std::decay_t<decltype(value)>, false>(
258
429
                    start, pos - start, &result);
259
429
            return result == StringParser::PARSE_SUCCESS;
260
430
        };
_ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
Line
Count
Source
246
219
        auto parse_uint = [&pos, end](auto& value) {
247
219
            const auto* start = pos;
248
438
            while (pos < end && std::isdigit(static_cast<unsigned char>(*pos))) {
249
219
                ++pos;
250
219
            }
251
252
219
            if (pos == start) {
253
1
                return false;
254
1
            }
255
256
218
            StringParser::ParseResult result;
257
218
            value = StringParser::string_to_int<std::decay_t<decltype(value)>, false>(
258
218
                    start, pos - start, &result);
259
218
            return result == StringParser::PARSE_SUCCESS;
260
219
        };
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
_ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
Line
Count
Source
246
211
        auto parse_uint = [&pos, end](auto& value) {
247
211
            const auto* start = pos;
248
423
            while (pos < end && std::isdigit(static_cast<unsigned char>(*pos))) {
249
212
                ++pos;
250
212
            }
251
252
211
            if (pos == start) {
253
0
                return false;
254
0
            }
255
256
211
            StringParser::ParseResult result;
257
211
            value = StringParser::string_to_int<std::decay_t<decltype(value)>, false>(
258
211
                    start, pos - start, &result);
259
211
            return result == StringParser::PARSE_SUCCESS;
260
211
        };
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
Unexecuted instantiation: _ZZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE13parse_patternEvENKUlRT_E_clImEEDaS6_
261
262
818
        while (pos < end) {
263
430
            if (match("(?")) {
264
430
                if (match("t")) {
265
13
                    PatternActionType type;
266
267
13
                    if (match("<="))
268
3
                        type = PatternActionType::TimeLessOrEqual;
269
10
                    else if (match("<"))
270
0
                        type = PatternActionType::TimeLess;
271
10
                    else if (match(">="))
272
10
                        type = PatternActionType::TimeGreaterOrEqual;
273
0
                    else if (match(">"))
274
0
                        type = PatternActionType::TimeGreater;
275
0
                    else if (match("=="))
276
0
                        type = PatternActionType::TimeEqual;
277
0
                    else {
278
0
                        throw_exception("Unknown time condition");
279
0
                        return;
280
0
                    }
281
282
13
                    uint64_t duration = 0;
283
13
                    if (!parse_uint(duration)) {
284
1
                        throw_exception("Could not parse number");
285
1
                        return;
286
1
                    }
287
288
12
                    if (actions.back().type != PatternActionType::SpecificEvent &&
289
12
                        actions.back().type != PatternActionType::AnyEvent &&
290
12
                        actions.back().type != PatternActionType::KleeneStar) {
291
0
                        throw_exception(
292
0
                                "Temporal condition should be preceded by an event condition");
293
0
                        return;
294
0
                    }
295
296
12
                    pattern_has_time = true;
297
12
                    actions.emplace_back(type, duration);
298
417
                } else {
299
417
                    UInt64 event_number = 0;
300
417
                    if (!parse_uint(event_number)) {
301
0
                        throw_exception("Could not parse number");
302
0
                        return;
303
0
                    }
304
305
417
                    if (event_number == 0 || event_number > event_count) {
306
6
                        throw_exception("Event number " + std::to_string(event_number) +
307
6
                                        " is out of range");
308
6
                        return;
309
6
                    }
310
311
411
                    const auto event_index = event_number - 1;
312
411
                    actions.emplace_back(PatternActionType::SpecificEvent, event_index);
313
411
                    dfa_states.back().transition = DFATransition::SpecificEvent;
314
411
                    dfa_states.back().event = static_cast<uint32_t>(event_index);
315
411
                    dfa_states.emplace_back();
316
411
                    conditions_in_pattern.set(event_index);
317
411
                }
318
319
423
                if (!match(")")) {
320
0
                    throw_exception("Expected closing parenthesis, found");
321
0
                    return;
322
0
                }
323
324
423
            } else if (match(".*")) {
325
0
                actions.emplace_back(PatternActionType::KleeneStar);
326
0
                dfa_states.back().has_kleene = true;
327
0
            } else if (match(".")) {
328
0
                actions.emplace_back(PatternActionType::AnyEvent);
329
0
                dfa_states.back().transition = DFATransition::AnyEvent;
330
0
                dfa_states.emplace_back();
331
0
            } else {
332
0
                throw_exception("Could not parse pattern, unexpected starting symbol");
333
0
                return;
334
0
            }
335
430
        }
336
395
    }
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE13parse_patternEv
Line
Count
Source
216
199
    void parse_pattern() {
217
199
        actions.clear();
218
199
        actions.emplace_back(PatternActionType::KleeneStar);
219
220
199
        dfa_states.clear();
221
199
        dfa_states.emplace_back(true);
222
223
199
        pattern_has_time = false;
224
199
        conditions_in_pattern.reset();
225
226
199
        const char* pos = pattern.data();
227
199
        const char* begin = pos;
228
199
        const char* end = pos + pattern.size();
229
199
        const size_t event_count = arg_count - 2;
230
231
        // FE checks a literal pattern, but a constant pattern only BE can evaluate is checked here.
232
199
        auto throw_exception = [&](const std::string& msg) {
233
199
            throw Exception(ErrorCode::INVALID_ARGUMENT, "{} '{}' at position {} of pattern '{}'",
234
199
                            msg, std::string(pos, end), pos - begin, pattern);
235
199
        };
236
237
199
        auto match = [&pos, end](const char* str) mutable {
238
199
            size_t length = strlen(str);
239
199
            if (pos + length <= end && 0 == memcmp(pos, str, length)) {
240
199
                pos += length;
241
199
                return true;
242
199
            }
243
199
            return false;
244
199
        };
245
246
199
        auto parse_uint = [&pos, end](auto& value) {
247
199
            const auto* start = pos;
248
199
            while (pos < end && std::isdigit(static_cast<unsigned char>(*pos))) {
249
199
                ++pos;
250
199
            }
251
252
199
            if (pos == start) {
253
199
                return false;
254
199
            }
255
256
199
            StringParser::ParseResult result;
257
199
            value = StringParser::string_to_int<std::decay_t<decltype(value)>, false>(
258
199
                    start, pos - start, &result);
259
199
            return result == StringParser::PARSE_SUCCESS;
260
199
        };
261
262
414
        while (pos < end) {
263
219
            if (match("(?")) {
264
219
                if (match("t")) {
265
8
                    PatternActionType type;
266
267
8
                    if (match("<="))
268
3
                        type = PatternActionType::TimeLessOrEqual;
269
5
                    else if (match("<"))
270
0
                        type = PatternActionType::TimeLess;
271
5
                    else if (match(">="))
272
5
                        type = PatternActionType::TimeGreaterOrEqual;
273
0
                    else if (match(">"))
274
0
                        type = PatternActionType::TimeGreater;
275
0
                    else if (match("=="))
276
0
                        type = PatternActionType::TimeEqual;
277
0
                    else {
278
0
                        throw_exception("Unknown time condition");
279
0
                        return;
280
0
                    }
281
282
8
                    uint64_t duration = 0;
283
8
                    if (!parse_uint(duration)) {
284
1
                        throw_exception("Could not parse number");
285
1
                        return;
286
1
                    }
287
288
7
                    if (actions.back().type != PatternActionType::SpecificEvent &&
289
7
                        actions.back().type != PatternActionType::AnyEvent &&
290
7
                        actions.back().type != PatternActionType::KleeneStar) {
291
0
                        throw_exception(
292
0
                                "Temporal condition should be preceded by an event condition");
293
0
                        return;
294
0
                    }
295
296
7
                    pattern_has_time = true;
297
7
                    actions.emplace_back(type, duration);
298
211
                } else {
299
211
                    UInt64 event_number = 0;
300
211
                    if (!parse_uint(event_number)) {
301
0
                        throw_exception("Could not parse number");
302
0
                        return;
303
0
                    }
304
305
211
                    if (event_number == 0 || event_number > event_count) {
306
3
                        throw_exception("Event number " + std::to_string(event_number) +
307
3
                                        " is out of range");
308
3
                        return;
309
3
                    }
310
311
208
                    const auto event_index = event_number - 1;
312
208
                    actions.emplace_back(PatternActionType::SpecificEvent, event_index);
313
208
                    dfa_states.back().transition = DFATransition::SpecificEvent;
314
208
                    dfa_states.back().event = static_cast<uint32_t>(event_index);
315
208
                    dfa_states.emplace_back();
316
208
                    conditions_in_pattern.set(event_index);
317
208
                }
318
319
215
                if (!match(")")) {
320
0
                    throw_exception("Expected closing parenthesis, found");
321
0
                    return;
322
0
                }
323
324
215
            } else if (match(".*")) {
325
0
                actions.emplace_back(PatternActionType::KleeneStar);
326
0
                dfa_states.back().has_kleene = true;
327
0
            } else if (match(".")) {
328
0
                actions.emplace_back(PatternActionType::AnyEvent);
329
0
                dfa_states.back().transition = DFATransition::AnyEvent;
330
0
                dfa_states.emplace_back();
331
0
            } else {
332
0
                throw_exception("Could not parse pattern, unexpected starting symbol");
333
0
                return;
334
0
            }
335
219
        }
336
199
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE13parse_patternEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE13parse_patternEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE13parse_patternEv
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE13parse_patternEv
Line
Count
Source
216
196
    void parse_pattern() {
217
196
        actions.clear();
218
196
        actions.emplace_back(PatternActionType::KleeneStar);
219
220
196
        dfa_states.clear();
221
196
        dfa_states.emplace_back(true);
222
223
196
        pattern_has_time = false;
224
196
        conditions_in_pattern.reset();
225
226
196
        const char* pos = pattern.data();
227
196
        const char* begin = pos;
228
196
        const char* end = pos + pattern.size();
229
196
        const size_t event_count = arg_count - 2;
230
231
        // FE checks a literal pattern, but a constant pattern only BE can evaluate is checked here.
232
196
        auto throw_exception = [&](const std::string& msg) {
233
196
            throw Exception(ErrorCode::INVALID_ARGUMENT, "{} '{}' at position {} of pattern '{}'",
234
196
                            msg, std::string(pos, end), pos - begin, pattern);
235
196
        };
236
237
196
        auto match = [&pos, end](const char* str) mutable {
238
196
            size_t length = strlen(str);
239
196
            if (pos + length <= end && 0 == memcmp(pos, str, length)) {
240
196
                pos += length;
241
196
                return true;
242
196
            }
243
196
            return false;
244
196
        };
245
246
196
        auto parse_uint = [&pos, end](auto& value) {
247
196
            const auto* start = pos;
248
196
            while (pos < end && std::isdigit(static_cast<unsigned char>(*pos))) {
249
196
                ++pos;
250
196
            }
251
252
196
            if (pos == start) {
253
196
                return false;
254
196
            }
255
256
196
            StringParser::ParseResult result;
257
196
            value = StringParser::string_to_int<std::decay_t<decltype(value)>, false>(
258
196
                    start, pos - start, &result);
259
196
            return result == StringParser::PARSE_SUCCESS;
260
196
        };
261
262
404
        while (pos < end) {
263
211
            if (match("(?")) {
264
211
                if (match("t")) {
265
5
                    PatternActionType type;
266
267
5
                    if (match("<="))
268
0
                        type = PatternActionType::TimeLessOrEqual;
269
5
                    else if (match("<"))
270
0
                        type = PatternActionType::TimeLess;
271
5
                    else if (match(">="))
272
5
                        type = PatternActionType::TimeGreaterOrEqual;
273
0
                    else if (match(">"))
274
0
                        type = PatternActionType::TimeGreater;
275
0
                    else if (match("=="))
276
0
                        type = PatternActionType::TimeEqual;
277
0
                    else {
278
0
                        throw_exception("Unknown time condition");
279
0
                        return;
280
0
                    }
281
282
5
                    uint64_t duration = 0;
283
5
                    if (!parse_uint(duration)) {
284
0
                        throw_exception("Could not parse number");
285
0
                        return;
286
0
                    }
287
288
5
                    if (actions.back().type != PatternActionType::SpecificEvent &&
289
5
                        actions.back().type != PatternActionType::AnyEvent &&
290
5
                        actions.back().type != PatternActionType::KleeneStar) {
291
0
                        throw_exception(
292
0
                                "Temporal condition should be preceded by an event condition");
293
0
                        return;
294
0
                    }
295
296
5
                    pattern_has_time = true;
297
5
                    actions.emplace_back(type, duration);
298
206
                } else {
299
206
                    UInt64 event_number = 0;
300
206
                    if (!parse_uint(event_number)) {
301
0
                        throw_exception("Could not parse number");
302
0
                        return;
303
0
                    }
304
305
206
                    if (event_number == 0 || event_number > event_count) {
306
3
                        throw_exception("Event number " + std::to_string(event_number) +
307
3
                                        " is out of range");
308
3
                        return;
309
3
                    }
310
311
203
                    const auto event_index = event_number - 1;
312
203
                    actions.emplace_back(PatternActionType::SpecificEvent, event_index);
313
203
                    dfa_states.back().transition = DFATransition::SpecificEvent;
314
203
                    dfa_states.back().event = static_cast<uint32_t>(event_index);
315
203
                    dfa_states.emplace_back();
316
203
                    conditions_in_pattern.set(event_index);
317
203
                }
318
319
208
                if (!match(")")) {
320
0
                    throw_exception("Expected closing parenthesis, found");
321
0
                    return;
322
0
                }
323
324
208
            } else if (match(".*")) {
325
0
                actions.emplace_back(PatternActionType::KleeneStar);
326
0
                dfa_states.back().has_kleene = true;
327
0
            } else if (match(".")) {
328
0
                actions.emplace_back(PatternActionType::AnyEvent);
329
0
                dfa_states.back().transition = DFATransition::AnyEvent;
330
0
                dfa_states.emplace_back();
331
0
            } else {
332
0
                throw_exception("Could not parse pattern, unexpected starting symbol");
333
0
                return;
334
0
            }
335
211
        }
336
196
    }
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE13parse_patternEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE13parse_patternEv
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE13parse_patternEv
337
338
public:
339
    /// Uses a DFA based approach in order to better handle patterns without
340
    /// time assertions.
341
    ///
342
    /// NOTE: This implementation relies on the assumption that the pattern is *small*.
343
    ///
344
    /// This algorithm performs in O(mn) (with m the number of DFA states and N the number
345
    /// of events) with a memory consumption and memory allocations in O(m). It means that
346
    /// if n >>> m (which is expected to be the case), this algorithm can be considered linear.
347
    template <typename EventEntry>
348
37
    bool dfa_match(EventEntry& events_it, const EventEntry events_end) const {
349
37
        using ActiveStates = std::vector<bool>;
350
        /// Those two vectors keep track of which states should be considered for the current
351
        /// event as well as the states which should be considered for the next event.
352
37
        ActiveStates active_states(dfa_states.size(), false);
353
37
        ActiveStates next_active_states(dfa_states.size(), false);
354
37
        active_states[0] = true;
355
356
        /// Keeps track of dead-ends in order not to iterate over all the events to realize that
357
        /// the match failed.
358
37
        size_t n_active = 1;
359
360
77
        for (/* empty */; events_it != events_end && n_active > 0 && !active_states.back();
361
40
             ++events_it) {
362
40
            n_active = 0;
363
40
            next_active_states.assign(dfa_states.size(), false);
364
365
126
            for (size_t state = 0; state < dfa_states.size(); ++state) {
366
86
                if (!active_states[state]) {
367
43
                    continue;
368
43
                }
369
370
43
                switch (dfa_states[state].transition) {
371
0
                case DFATransition::None:
372
0
                    break;
373
0
                case DFATransition::AnyEvent:
374
0
                    next_active_states[state + 1] = true;
375
0
                    ++n_active;
376
0
                    break;
377
43
                case DFATransition::SpecificEvent:
378
43
                    if (events_it->second.test(dfa_states[state].event)) {
379
40
                        next_active_states[state + 1] = true;
380
40
                        ++n_active;
381
40
                    }
382
43
                    break;
383
43
                }
384
385
43
                if (dfa_states[state].has_kleene) {
386
40
                    next_active_states[state] = true;
387
40
                    ++n_active;
388
40
                }
389
43
            }
390
40
            swap(active_states, next_active_states);
391
40
        }
392
393
37
        return active_states.back();
394
37
    }
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE9dfa_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_
Line
Count
Source
348
37
    bool dfa_match(EventEntry& events_it, const EventEntry events_end) const {
349
37
        using ActiveStates = std::vector<bool>;
350
        /// Those two vectors keep track of which states should be considered for the current
351
        /// event as well as the states which should be considered for the next event.
352
37
        ActiveStates active_states(dfa_states.size(), false);
353
37
        ActiveStates next_active_states(dfa_states.size(), false);
354
37
        active_states[0] = true;
355
356
        /// Keeps track of dead-ends in order not to iterate over all the events to realize that
357
        /// the match failed.
358
37
        size_t n_active = 1;
359
360
77
        for (/* empty */; events_it != events_end && n_active > 0 && !active_states.back();
361
40
             ++events_it) {
362
40
            n_active = 0;
363
40
            next_active_states.assign(dfa_states.size(), false);
364
365
126
            for (size_t state = 0; state < dfa_states.size(); ++state) {
366
86
                if (!active_states[state]) {
367
43
                    continue;
368
43
                }
369
370
43
                switch (dfa_states[state].transition) {
371
0
                case DFATransition::None:
372
0
                    break;
373
0
                case DFATransition::AnyEvent:
374
0
                    next_active_states[state + 1] = true;
375
0
                    ++n_active;
376
0
                    break;
377
43
                case DFATransition::SpecificEvent:
378
43
                    if (events_it->second.test(dfa_states[state].event)) {
379
40
                        next_active_states[state + 1] = true;
380
40
                        ++n_active;
381
40
                    }
382
43
                    break;
383
43
                }
384
385
43
                if (dfa_states[state].has_kleene) {
386
40
                    next_active_states[state] = true;
387
40
                    ++n_active;
388
40
                }
389
43
            }
390
40
            swap(active_states, next_active_states);
391
40
        }
392
393
37
        return active_states.back();
394
37
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE9dfa_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE9dfa_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE9dfa_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_
395
396
    template <typename EventEntry>
397
57
    bool backtracking_match(EventEntry& events_it, const EventEntry events_end) const {
398
57
        const auto action_begin = std::begin(actions);
399
57
        const auto action_end = std::end(actions);
400
57
        auto action_it = action_begin;
401
402
57
        const auto events_begin = events_it;
403
57
        auto base_it = events_it;
404
405
        /// an iterator to action plus an iterator to row in events list plus timestamp at the start of sequence
406
57
        using backtrack_info = std::tuple<decltype(action_it), EventEntry, EventEntry>;
407
57
        std::stack<backtrack_info> back_stack;
408
409
        /// backtrack if possible
410
57
        const auto do_backtrack = [&] {
411
2
            while (!back_stack.empty()) {
412
2
                auto& top = back_stack.top();
413
414
2
                action_it = std::get<0>(top);
415
2
                events_it = std::next(std::get<1>(top));
416
2
                base_it = std::get<2>(top);
417
418
2
                back_stack.pop();
419
420
2
                if (events_it != events_end) return true;
421
2
            }
422
423
0
            return false;
424
2
        };
_ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_ENKUlvE_clEv
Line
Count
Source
410
2
        const auto do_backtrack = [&] {
411
2
            while (!back_stack.empty()) {
412
2
                auto& top = back_stack.top();
413
414
2
                action_it = std::get<0>(top);
415
2
                events_it = std::next(std::get<1>(top));
416
2
                base_it = std::get<2>(top);
417
418
2
                back_stack.pop();
419
420
2
                if (events_it != events_end) return true;
421
2
            }
422
423
0
            return false;
424
2
        };
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_ENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_ENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_ENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_ENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_ENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_ENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_ENKUlvE_clEv
425
426
57
        size_t i = 0;
427
6.00M
        while (action_it != action_end && events_it != events_end) {
428
6.00M
            if (action_it->type == PatternActionType::SpecificEvent) {
429
74
                if (events_it->second.test(action_it->extra)) {
430
                    /// move to the next action and events
431
72
                    base_it = events_it;
432
72
                    ++action_it, ++events_it;
433
72
                } else if (!do_backtrack())
434
                    /// backtracking failed, bail out
435
0
                    break;
436
6.00M
            } else if (action_it->type == PatternActionType::AnyEvent) {
437
0
                base_it = events_it;
438
0
                ++action_it, ++events_it;
439
6.00M
            } else if (action_it->type == PatternActionType::KleeneStar) {
440
57
                back_stack.emplace(action_it, events_it, base_it);
441
57
                base_it = events_it;
442
57
                ++action_it;
443
6.00M
            } else if (action_it->type == PatternActionType::TimeLessOrEqual) {
444
4
                if (events_it->first.datetime_diff_in_seconds(base_it->first) <= action_it->extra) {
445
                    /// condition satisfied, move onto next action
446
4
                    back_stack.emplace(action_it, events_it, base_it);
447
4
                    base_it = events_it;
448
4
                    ++action_it;
449
4
                } else if (!do_backtrack())
450
0
                    break;
451
6.00M
            } else if (action_it->type == PatternActionType::TimeLess) {
452
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) < action_it->extra) {
453
0
                    back_stack.emplace(action_it, events_it, base_it);
454
0
                    base_it = events_it;
455
0
                    ++action_it;
456
0
                } else if (!do_backtrack())
457
0
                    break;
458
6.00M
            } else if (action_it->type == PatternActionType::TimeGreaterOrEqual) {
459
6.00M
                if (events_it->first.datetime_diff_in_seconds(base_it->first) >= action_it->extra) {
460
6
                    back_stack.emplace(action_it, events_it, base_it);
461
6
                    base_it = events_it;
462
6
                    ++action_it;
463
6.00M
                } else if (++events_it == events_end && !do_backtrack())
464
0
                    break;
465
6.00M
            } else if (action_it->type == PatternActionType::TimeGreater) {
466
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) > action_it->extra) {
467
0
                    back_stack.emplace(action_it, events_it, base_it);
468
0
                    base_it = events_it;
469
0
                    ++action_it;
470
0
                } else if (++events_it == events_end && !do_backtrack())
471
0
                    break;
472
0
            } else if (action_it->type == PatternActionType::TimeEqual) {
473
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) == action_it->extra) {
474
0
                    back_stack.emplace(action_it, events_it, base_it);
475
0
                    base_it = events_it;
476
0
                    ++action_it;
477
0
                } else if (++events_it == events_end && !do_backtrack())
478
0
                    break;
479
0
            } else {
480
0
                LOG(WARNING) << "Unknown PatternActionType";
481
0
                return false;
482
0
            }
483
484
6.00M
            if (++i > sequence_match_max_iterations) {
485
                // The only matching event may follow the budget (e.g. a million earlier events).
486
                // Exhausting the search is not proof that the pattern does not match.
487
4
                throw Exception(ErrorCode::INVALID_ARGUMENT,
488
4
                                "sequence pattern evaluation exceeded max iterations ({})",
489
4
                                sequence_match_max_iterations);
490
4
            }
491
6.00M
        }
492
493
        /// if there are some actions remaining
494
53
        if (action_it != action_end) {
495
            /// match multiple empty strings at end
496
0
            while (action_it->type == PatternActionType::KleeneStar ||
497
0
                   action_it->type == PatternActionType::TimeLessOrEqual ||
498
0
                   action_it->type == PatternActionType::TimeLess ||
499
0
                   (action_it->type == PatternActionType::TimeGreaterOrEqual &&
500
0
                    action_it->extra == 0))
501
0
                ++action_it;
502
0
        }
503
504
53
        if (events_it == events_begin) ++events_it;
505
506
53
        return action_it == action_end;
507
57
    }
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_
Line
Count
Source
397
6
    bool backtracking_match(EventEntry& events_it, const EventEntry events_end) const {
398
6
        const auto action_begin = std::begin(actions);
399
6
        const auto action_end = std::end(actions);
400
6
        auto action_it = action_begin;
401
402
6
        const auto events_begin = events_it;
403
6
        auto base_it = events_it;
404
405
        /// an iterator to action plus an iterator to row in events list plus timestamp at the start of sequence
406
6
        using backtrack_info = std::tuple<decltype(action_it), EventEntry, EventEntry>;
407
6
        std::stack<backtrack_info> back_stack;
408
409
        /// backtrack if possible
410
6
        const auto do_backtrack = [&] {
411
6
            while (!back_stack.empty()) {
412
6
                auto& top = back_stack.top();
413
414
6
                action_it = std::get<0>(top);
415
6
                events_it = std::next(std::get<1>(top));
416
6
                base_it = std::get<2>(top);
417
418
6
                back_stack.pop();
419
420
6
                if (events_it != events_end) return true;
421
6
            }
422
423
6
            return false;
424
6
        };
425
426
6
        size_t i = 0;
427
3.00M
        while (action_it != action_end && events_it != events_end) {
428
3.00M
            if (action_it->type == PatternActionType::SpecificEvent) {
429
13
                if (events_it->second.test(action_it->extra)) {
430
                    /// move to the next action and events
431
11
                    base_it = events_it;
432
11
                    ++action_it, ++events_it;
433
11
                } else if (!do_backtrack())
434
                    /// backtracking failed, bail out
435
0
                    break;
436
3.00M
            } else if (action_it->type == PatternActionType::AnyEvent) {
437
0
                base_it = events_it;
438
0
                ++action_it, ++events_it;
439
3.00M
            } else if (action_it->type == PatternActionType::KleeneStar) {
440
6
                back_stack.emplace(action_it, events_it, base_it);
441
6
                base_it = events_it;
442
6
                ++action_it;
443
3.00M
            } else if (action_it->type == PatternActionType::TimeLessOrEqual) {
444
4
                if (events_it->first.datetime_diff_in_seconds(base_it->first) <= action_it->extra) {
445
                    /// condition satisfied, move onto next action
446
4
                    back_stack.emplace(action_it, events_it, base_it);
447
4
                    base_it = events_it;
448
4
                    ++action_it;
449
4
                } else if (!do_backtrack())
450
0
                    break;
451
3.00M
            } else if (action_it->type == PatternActionType::TimeLess) {
452
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) < action_it->extra) {
453
0
                    back_stack.emplace(action_it, events_it, base_it);
454
0
                    base_it = events_it;
455
0
                    ++action_it;
456
0
                } else if (!do_backtrack())
457
0
                    break;
458
3.00M
            } else if (action_it->type == PatternActionType::TimeGreaterOrEqual) {
459
3.00M
                if (events_it->first.datetime_diff_in_seconds(base_it->first) >= action_it->extra) {
460
3
                    back_stack.emplace(action_it, events_it, base_it);
461
3
                    base_it = events_it;
462
3
                    ++action_it;
463
3.00M
                } else if (++events_it == events_end && !do_backtrack())
464
0
                    break;
465
3.00M
            } else if (action_it->type == PatternActionType::TimeGreater) {
466
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) > action_it->extra) {
467
0
                    back_stack.emplace(action_it, events_it, base_it);
468
0
                    base_it = events_it;
469
0
                    ++action_it;
470
0
                } else if (++events_it == events_end && !do_backtrack())
471
0
                    break;
472
0
            } else if (action_it->type == PatternActionType::TimeEqual) {
473
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) == action_it->extra) {
474
0
                    back_stack.emplace(action_it, events_it, base_it);
475
0
                    base_it = events_it;
476
0
                    ++action_it;
477
0
                } else if (++events_it == events_end && !do_backtrack())
478
0
                    break;
479
0
            } else {
480
0
                LOG(WARNING) << "Unknown PatternActionType";
481
0
                return false;
482
0
            }
483
484
3.00M
            if (++i > sequence_match_max_iterations) {
485
                // The only matching event may follow the budget (e.g. a million earlier events).
486
                // Exhausting the search is not proof that the pattern does not match.
487
2
                throw Exception(ErrorCode::INVALID_ARGUMENT,
488
2
                                "sequence pattern evaluation exceeded max iterations ({})",
489
2
                                sequence_match_max_iterations);
490
2
            }
491
3.00M
        }
492
493
        /// if there are some actions remaining
494
4
        if (action_it != action_end) {
495
            /// match multiple empty strings at end
496
0
            while (action_it->type == PatternActionType::KleeneStar ||
497
0
                   action_it->type == PatternActionType::TimeLessOrEqual ||
498
0
                   action_it->type == PatternActionType::TimeLess ||
499
0
                   (action_it->type == PatternActionType::TimeGreaterOrEqual &&
500
0
                    action_it->extra == 0))
501
0
                ++action_it;
502
0
        }
503
504
4
        if (events_it == events_begin) ++events_it;
505
506
4
        return action_it == action_end;
507
6
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_
Line
Count
Source
397
51
    bool backtracking_match(EventEntry& events_it, const EventEntry events_end) const {
398
51
        const auto action_begin = std::begin(actions);
399
51
        const auto action_end = std::end(actions);
400
51
        auto action_it = action_begin;
401
402
51
        const auto events_begin = events_it;
403
51
        auto base_it = events_it;
404
405
        /// an iterator to action plus an iterator to row in events list plus timestamp at the start of sequence
406
51
        using backtrack_info = std::tuple<decltype(action_it), EventEntry, EventEntry>;
407
51
        std::stack<backtrack_info> back_stack;
408
409
        /// backtrack if possible
410
51
        const auto do_backtrack = [&] {
411
51
            while (!back_stack.empty()) {
412
51
                auto& top = back_stack.top();
413
414
51
                action_it = std::get<0>(top);
415
51
                events_it = std::next(std::get<1>(top));
416
51
                base_it = std::get<2>(top);
417
418
51
                back_stack.pop();
419
420
51
                if (events_it != events_end) return true;
421
51
            }
422
423
51
            return false;
424
51
        };
425
426
51
        size_t i = 0;
427
3.00M
        while (action_it != action_end && events_it != events_end) {
428
3.00M
            if (action_it->type == PatternActionType::SpecificEvent) {
429
61
                if (events_it->second.test(action_it->extra)) {
430
                    /// move to the next action and events
431
61
                    base_it = events_it;
432
61
                    ++action_it, ++events_it;
433
61
                } else if (!do_backtrack())
434
                    /// backtracking failed, bail out
435
0
                    break;
436
3.00M
            } else if (action_it->type == PatternActionType::AnyEvent) {
437
0
                base_it = events_it;
438
0
                ++action_it, ++events_it;
439
3.00M
            } else if (action_it->type == PatternActionType::KleeneStar) {
440
51
                back_stack.emplace(action_it, events_it, base_it);
441
51
                base_it = events_it;
442
51
                ++action_it;
443
3.00M
            } else if (action_it->type == PatternActionType::TimeLessOrEqual) {
444
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) <= action_it->extra) {
445
                    /// condition satisfied, move onto next action
446
0
                    back_stack.emplace(action_it, events_it, base_it);
447
0
                    base_it = events_it;
448
0
                    ++action_it;
449
0
                } else if (!do_backtrack())
450
0
                    break;
451
3.00M
            } else if (action_it->type == PatternActionType::TimeLess) {
452
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) < action_it->extra) {
453
0
                    back_stack.emplace(action_it, events_it, base_it);
454
0
                    base_it = events_it;
455
0
                    ++action_it;
456
0
                } else if (!do_backtrack())
457
0
                    break;
458
3.00M
            } else if (action_it->type == PatternActionType::TimeGreaterOrEqual) {
459
3.00M
                if (events_it->first.datetime_diff_in_seconds(base_it->first) >= action_it->extra) {
460
3
                    back_stack.emplace(action_it, events_it, base_it);
461
3
                    base_it = events_it;
462
3
                    ++action_it;
463
3.00M
                } else if (++events_it == events_end && !do_backtrack())
464
0
                    break;
465
3.00M
            } else if (action_it->type == PatternActionType::TimeGreater) {
466
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) > action_it->extra) {
467
0
                    back_stack.emplace(action_it, events_it, base_it);
468
0
                    base_it = events_it;
469
0
                    ++action_it;
470
0
                } else if (++events_it == events_end && !do_backtrack())
471
0
                    break;
472
0
            } else if (action_it->type == PatternActionType::TimeEqual) {
473
0
                if (events_it->first.datetime_diff_in_seconds(base_it->first) == action_it->extra) {
474
0
                    back_stack.emplace(action_it, events_it, base_it);
475
0
                    base_it = events_it;
476
0
                    ++action_it;
477
0
                } else if (++events_it == events_end && !do_backtrack())
478
0
                    break;
479
0
            } else {
480
0
                LOG(WARNING) << "Unknown PatternActionType";
481
0
                return false;
482
0
            }
483
484
3.00M
            if (++i > sequence_match_max_iterations) {
485
                // The only matching event may follow the budget (e.g. a million earlier events).
486
                // Exhausting the search is not proof that the pattern does not match.
487
2
                throw Exception(ErrorCode::INVALID_ARGUMENT,
488
2
                                "sequence pattern evaluation exceeded max iterations ({})",
489
2
                                sequence_match_max_iterations);
490
2
            }
491
3.00M
        }
492
493
        /// if there are some actions remaining
494
49
        if (action_it != action_end) {
495
            /// match multiple empty strings at end
496
0
            while (action_it->type == PatternActionType::KleeneStar ||
497
0
                   action_it->type == PatternActionType::TimeLessOrEqual ||
498
0
                   action_it->type == PatternActionType::TimeLess ||
499
0
                   (action_it->type == PatternActionType::TimeGreaterOrEqual &&
500
0
                    action_it->extra == 0))
501
0
                ++action_it;
502
0
        }
503
504
49
        if (events_it == events_begin) ++events_it;
505
506
49
        return action_it == action_end;
507
51
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbRT_SL_
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE18backtracking_matchIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbRT_SJ_
508
509
    /// Splits the pattern into deterministic parts separated by non-deterministic fragments
510
    /// (time constraints and Kleene stars), and tries to match the deterministic parts in their specified order,
511
    /// ignoring the non-deterministic fragments.
512
    /// This function can quickly check that a full match is not possible if some deterministic fragment is missing.
513
    template <typename EventEntry>
514
    bool could_match_deterministic_parts(const EventEntry events_begin, const EventEntry events_end,
515
48
                                         bool limit_iterations = true) const {
516
48
        size_t events_processed = 0;
517
48
        auto events_it = events_begin;
518
519
48
        const auto actions_end = std::end(actions);
520
48
        auto actions_it = std::begin(actions);
521
48
        auto det_part_begin = actions_it;
522
523
48
        auto match_deterministic_part = [&events_it, events_end, &events_processed, det_part_begin,
524
106
                                         actions_it, limit_iterations]() {
525
106
            auto events_it_init = events_it;
526
106
            auto det_part_it = det_part_begin;
527
528
106
            while (det_part_it != actions_it && events_it != events_end) {
529
                /// matching any event
530
0
                if (det_part_it->type == PatternActionType::AnyEvent) ++events_it, ++det_part_it;
531
532
                /// matching specific event
533
0
                else {
534
0
                    if (events_it->second.test(det_part_it->extra)) ++events_it, ++det_part_it;
535
536
                    /// abandon current matching, try to match the deterministic fragment further in the list
537
0
                    else {
538
0
                        events_it = ++events_it_init;
539
0
                        det_part_it = det_part_begin;
540
0
                    }
541
0
                }
542
543
0
                if (limit_iterations && ++events_processed > sequence_match_max_iterations) {
544
                    // A deterministic event may still occur after the inspected prefix.
545
                    // Report the exhausted budget instead of treating it as a missing event.
546
0
                    throw Exception(ErrorCode::INVALID_ARGUMENT,
547
0
                                    "sequence pattern evaluation exceeded max iterations ({})",
548
0
                                    sequence_match_max_iterations);
549
0
                }
550
0
            }
551
552
106
            return det_part_it == actions_it;
553
106
        };
_ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_bENKUlvE_clEv
Line
Count
Source
524
18
                                         actions_it, limit_iterations]() {
525
18
            auto events_it_init = events_it;
526
18
            auto det_part_it = det_part_begin;
527
528
18
            while (det_part_it != actions_it && events_it != events_end) {
529
                /// matching any event
530
0
                if (det_part_it->type == PatternActionType::AnyEvent) ++events_it, ++det_part_it;
531
532
                /// matching specific event
533
0
                else {
534
0
                    if (events_it->second.test(det_part_it->extra)) ++events_it, ++det_part_it;
535
536
                    /// abandon current matching, try to match the deterministic fragment further in the list
537
0
                    else {
538
0
                        events_it = ++events_it_init;
539
0
                        det_part_it = det_part_begin;
540
0
                    }
541
0
                }
542
543
0
                if (limit_iterations && ++events_processed > sequence_match_max_iterations) {
544
                    // A deterministic event may still occur after the inspected prefix.
545
                    // Report the exhausted budget instead of treating it as a missing event.
546
0
                    throw Exception(ErrorCode::INVALID_ARGUMENT,
547
0
                                    "sequence pattern evaluation exceeded max iterations ({})",
548
0
                                    sequence_match_max_iterations);
549
0
                }
550
0
            }
551
552
18
            return det_part_it == actions_it;
553
18
        };
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_bENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_bENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_bENKUlvE_clEv
_ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_bENKUlvE_clEv
Line
Count
Source
524
88
                                         actions_it, limit_iterations]() {
525
88
            auto events_it_init = events_it;
526
88
            auto det_part_it = det_part_begin;
527
528
88
            while (det_part_it != actions_it && events_it != events_end) {
529
                /// matching any event
530
0
                if (det_part_it->type == PatternActionType::AnyEvent) ++events_it, ++det_part_it;
531
532
                /// matching specific event
533
0
                else {
534
0
                    if (events_it->second.test(det_part_it->extra)) ++events_it, ++det_part_it;
535
536
                    /// abandon current matching, try to match the deterministic fragment further in the list
537
0
                    else {
538
0
                        events_it = ++events_it_init;
539
0
                        det_part_it = det_part_begin;
540
0
                    }
541
0
                }
542
543
0
                if (limit_iterations && ++events_processed > sequence_match_max_iterations) {
544
                    // A deterministic event may still occur after the inspected prefix.
545
                    // Report the exhausted budget instead of treating it as a missing event.
546
0
                    throw Exception(ErrorCode::INVALID_ARGUMENT,
547
0
                                    "sequence pattern evaluation exceeded max iterations ({})",
548
0
                                    sequence_match_max_iterations);
549
0
                }
550
0
            }
551
552
88
            return det_part_it == actions_it;
553
88
        };
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_bENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_bENKUlvE_clEv
Unexecuted instantiation: _ZZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_bENKUlvE_clEv
554
555
168
        for (; actions_it != actions_end; ++actions_it)
556
120
            if (actions_it->type != PatternActionType::SpecificEvent &&
557
120
                actions_it->type != PatternActionType::AnyEvent) {
558
58
                if (!match_deterministic_part()) return false;
559
58
                det_part_begin = std::next(actions_it);
560
58
            }
561
562
48
        return match_deterministic_part();
563
48
    }
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_b
Line
Count
Source
515
6
                                         bool limit_iterations = true) const {
516
6
        size_t events_processed = 0;
517
6
        auto events_it = events_begin;
518
519
6
        const auto actions_end = std::end(actions);
520
6
        auto actions_it = std::begin(actions);
521
6
        auto det_part_begin = actions_it;
522
523
6
        auto match_deterministic_part = [&events_it, events_end, &events_processed, det_part_begin,
524
6
                                         actions_it, limit_iterations]() {
525
6
            auto events_it_init = events_it;
526
6
            auto det_part_it = det_part_begin;
527
528
6
            while (det_part_it != actions_it && events_it != events_end) {
529
                /// matching any event
530
6
                if (det_part_it->type == PatternActionType::AnyEvent) ++events_it, ++det_part_it;
531
532
                /// matching specific event
533
6
                else {
534
6
                    if (events_it->second.test(det_part_it->extra)) ++events_it, ++det_part_it;
535
536
                    /// abandon current matching, try to match the deterministic fragment further in the list
537
6
                    else {
538
6
                        events_it = ++events_it_init;
539
6
                        det_part_it = det_part_begin;
540
6
                    }
541
6
                }
542
543
6
                if (limit_iterations && ++events_processed > sequence_match_max_iterations) {
544
                    // A deterministic event may still occur after the inspected prefix.
545
                    // Report the exhausted budget instead of treating it as a missing event.
546
6
                    throw Exception(ErrorCode::INVALID_ARGUMENT,
547
6
                                    "sequence pattern evaluation exceeded max iterations ({})",
548
6
                                    sequence_match_max_iterations);
549
6
                }
550
6
            }
551
552
6
            return det_part_it == actions_it;
553
6
        };
554
555
30
        for (; actions_it != actions_end; ++actions_it)
556
24
            if (actions_it->type != PatternActionType::SpecificEvent &&
557
24
                actions_it->type != PatternActionType::AnyEvent) {
558
12
                if (!match_deterministic_part()) return false;
559
12
                det_part_begin = std::next(actions_it);
560
12
            }
561
562
6
        return match_deterministic_part();
563
6
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_b
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_b
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_b
_ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_b
Line
Count
Source
515
42
                                         bool limit_iterations = true) const {
516
42
        size_t events_processed = 0;
517
42
        auto events_it = events_begin;
518
519
42
        const auto actions_end = std::end(actions);
520
42
        auto actions_it = std::begin(actions);
521
42
        auto det_part_begin = actions_it;
522
523
42
        auto match_deterministic_part = [&events_it, events_end, &events_processed, det_part_begin,
524
42
                                         actions_it, limit_iterations]() {
525
42
            auto events_it_init = events_it;
526
42
            auto det_part_it = det_part_begin;
527
528
42
            while (det_part_it != actions_it && events_it != events_end) {
529
                /// matching any event
530
42
                if (det_part_it->type == PatternActionType::AnyEvent) ++events_it, ++det_part_it;
531
532
                /// matching specific event
533
42
                else {
534
42
                    if (events_it->second.test(det_part_it->extra)) ++events_it, ++det_part_it;
535
536
                    /// abandon current matching, try to match the deterministic fragment further in the list
537
42
                    else {
538
42
                        events_it = ++events_it_init;
539
42
                        det_part_it = det_part_begin;
540
42
                    }
541
42
                }
542
543
42
                if (limit_iterations && ++events_processed > sequence_match_max_iterations) {
544
                    // A deterministic event may still occur after the inspected prefix.
545
                    // Report the exhausted budget instead of treating it as a missing event.
546
42
                    throw Exception(ErrorCode::INVALID_ARGUMENT,
547
42
                                    "sequence pattern evaluation exceeded max iterations ({})",
548
42
                                    sequence_match_max_iterations);
549
42
                }
550
42
            }
551
552
42
            return det_part_it == actions_it;
553
42
        };
554
555
138
        for (; actions_it != actions_end; ++actions_it)
556
96
            if (actions_it->type != PatternActionType::SpecificEvent &&
557
96
                actions_it->type != PatternActionType::AnyEvent) {
558
46
                if (!match_deterministic_part()) return false;
559
46
                det_part_begin = std::next(actions_it);
560
46
            }
561
562
42
        return match_deterministic_part();
563
42
    }
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimeStampNsValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_b
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_11DateV2ValueINS_15DateV2ValueTypeEEESt6bitsetILm32EEESt6vectorISE_SaISE_EEEEEEbT_SL_b
Unexecuted instantiation: _ZNK5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE31could_match_deterministic_partsIN9__gnu_cxx17__normal_iteratorIPKSt4pairINS_16TimestampTzValueESt6bitsetILm32EEESt6vectorISC_SaISC_EEEEEEbT_SJ_b
564
565
private:
566
    enum class DFATransition : char {
567
        ///   .-------.
568
        ///   |       |
569
        ///   `-------'
570
        None,
571
        ///   .-------.  (?[0-9])
572
        ///   |       | ----------
573
        ///   `-------'
574
        SpecificEvent,
575
        ///   .-------.      .
576
        ///   |       | ----------
577
        ///   `-------'
578
        AnyEvent,
579
    };
580
581
    struct DFAState {
582
        explicit DFAState(bool has_kleene_ = false)
583
806
                : has_kleene {has_kleene_}, event {0}, transition {DFATransition::None} {}
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE8DFAStateC2Eb
Line
Count
Source
583
407
                : has_kleene {has_kleene_}, event {0}, transition {DFATransition::None} {}
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE8DFAStateC2Eb
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE8DFAStateC2Eb
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE8DFAStateC2Eb
_ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE8DFAStateC2Eb
Line
Count
Source
583
399
                : has_kleene {has_kleene_}, event {0}, transition {DFATransition::None} {}
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE8DFAStateC2Eb
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE8DFAStateC2Eb
Unexecuted instantiation: _ZN5doris34AggregateFunctionSequenceMatchDataILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE8DFAStateC2Eb
584
585
        ///   .-------.
586
        ///   |       | - - -
587
        ///   `-------'
588
        ///     |_^
589
        bool has_kleene;
590
        /// In the case of a state transitions with a `SpecificEvent`,
591
        /// `event` contains the value of the event.
592
        uint32_t event;
593
        /// The kind of transition out of this state.
594
        DFATransition transition;
595
    };
596
597
    using DFAStates = std::vector<DFAState>;
598
599
public:
600
    bool sorted = true;
601
    std::vector<TimestampEvents> events_list;
602
    // sequenceMatch conditions met at least once in events_list
603
    std::bitset<MAX_EVENTS> conditions_met;
604
    // sequenceMatch conditions met at least once in the pattern
605
    std::bitset<MAX_EVENTS> conditions_in_pattern;
606
    // `True` if the parsed pattern contains time assertions (?t...), `false` otherwise.
607
    bool pattern_has_time;
608
609
private:
610
    std::string pattern;
611
    size_t arg_count;
612
    bool init_flag = false;
613
614
    PatternActions actions;
615
    DFAStates dfa_states;
616
};
617
618
template <PrimitiveType T, typename Derived>
619
class AggregateFunctionSequenceBase
620
        : public IAggregateFunctionDataHelper<AggregateFunctionSequenceMatchData<T, Derived>,
621
                                              Derived> {
622
public:
623
    AggregateFunctionSequenceBase(const DataTypes& arguments)
624
45
            : IAggregateFunctionDataHelper<AggregateFunctionSequenceMatchData<T, Derived>, Derived>(
625
45
                      arguments) {
626
45
        arg_count = arguments.size();
627
45
    }
_ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
624
21
            : IAggregateFunctionDataHelper<AggregateFunctionSequenceMatchData<T, Derived>, Derived>(
625
21
                      arguments) {
626
21
        arg_count = arguments.size();
627
21
    }
_ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
624
1
            : IAggregateFunctionDataHelper<AggregateFunctionSequenceMatchData<T, Derived>, Derived>(
625
1
                      arguments) {
626
1
        arg_count = arguments.size();
627
1
    }
Unexecuted instantiation: _ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Unexecuted instantiation: _ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
_ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
624
22
            : IAggregateFunctionDataHelper<AggregateFunctionSequenceMatchData<T, Derived>, Derived>(
625
22
                      arguments) {
626
22
        arg_count = arguments.size();
627
22
    }
_ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
624
1
            : IAggregateFunctionDataHelper<AggregateFunctionSequenceMatchData<T, Derived>, Derived>(
625
1
                      arguments) {
626
1
        arg_count = arguments.size();
627
1
    }
Unexecuted instantiation: _ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Unexecuted instantiation: _ZN5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
628
629
8
    void reset(AggregateDataPtr __restrict place) const override { this->data(place).reset(); }
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE5resetEPc
Line
Count
Source
629
4
    void reset(AggregateDataPtr __restrict place) const override { this->data(place).reset(); }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE5resetEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE5resetEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE5resetEPc
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE5resetEPc
Line
Count
Source
629
4
    void reset(AggregateDataPtr __restrict place) const override { this->data(place).reset(); }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE5resetEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE5resetEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE5resetEPc
630
631
    void add(AggregateDataPtr __restrict place, const IColumn** columns, const ssize_t row_num,
632
6.00M
             Arena&) const override {
633
6.00M
        std::string pattern =
634
6.00M
                assert_cast<const ColumnString*, TypeCheckOnRelease::DISABLE>(columns[0])
635
6.00M
                        ->get_data_at(0)
636
6.00M
                        .to_string();
637
6.00M
        this->data(place).init(pattern, arg_count);
638
639
6.00M
        const auto& timestamp = assert_cast<const typename PrimitiveTypeTraits<T>::ColumnType&,
640
6.00M
                                            TypeCheckOnRelease::DISABLE>(*columns[1])
641
6.00M
                                        .get_data()[row_num];
642
6.00M
        typename AggregateFunctionSequenceMatchData<T, Derived>::Events events;
643
644
24.0M
        for (auto i = 2; i < arg_count; i++) {
645
18.0M
            const auto event =
646
18.0M
                    assert_cast<const ColumnUInt8*, TypeCheckOnRelease::DISABLE>(columns[i])
647
18.0M
                            ->get_data()[row_num];
648
18.0M
            events.set(i - 2, event);
649
18.0M
        }
650
651
6.00M
        this->data(place).add(timestamp, events);
652
6.00M
    }
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Line
Count
Source
632
3.00M
             Arena&) const override {
633
3.00M
        std::string pattern =
634
3.00M
                assert_cast<const ColumnString*, TypeCheckOnRelease::DISABLE>(columns[0])
635
3.00M
                        ->get_data_at(0)
636
3.00M
                        .to_string();
637
3.00M
        this->data(place).init(pattern, arg_count);
638
639
3.00M
        const auto& timestamp = assert_cast<const typename PrimitiveTypeTraits<T>::ColumnType&,
640
3.00M
                                            TypeCheckOnRelease::DISABLE>(*columns[1])
641
3.00M
                                        .get_data()[row_num];
642
3.00M
        typename AggregateFunctionSequenceMatchData<T, Derived>::Events events;
643
644
12.0M
        for (auto i = 2; i < arg_count; i++) {
645
9.00M
            const auto event =
646
9.00M
                    assert_cast<const ColumnUInt8*, TypeCheckOnRelease::DISABLE>(columns[i])
647
9.00M
                            ->get_data()[row_num];
648
9.00M
            events.set(i - 2, event);
649
9.00M
        }
650
651
3.00M
        this->data(place).add(timestamp, events);
652
3.00M
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Line
Count
Source
632
3.00M
             Arena&) const override {
633
3.00M
        std::string pattern =
634
3.00M
                assert_cast<const ColumnString*, TypeCheckOnRelease::DISABLE>(columns[0])
635
3.00M
                        ->get_data_at(0)
636
3.00M
                        .to_string();
637
3.00M
        this->data(place).init(pattern, arg_count);
638
639
3.00M
        const auto& timestamp = assert_cast<const typename PrimitiveTypeTraits<T>::ColumnType&,
640
3.00M
                                            TypeCheckOnRelease::DISABLE>(*columns[1])
641
3.00M
                                        .get_data()[row_num];
642
3.00M
        typename AggregateFunctionSequenceMatchData<T, Derived>::Events events;
643
644
12.0M
        for (auto i = 2; i < arg_count; i++) {
645
9.00M
            const auto event =
646
9.00M
                    assert_cast<const ColumnUInt8*, TypeCheckOnRelease::DISABLE>(columns[i])
647
9.00M
                            ->get_data()[row_num];
648
9.00M
            events.set(i - 2, event);
649
9.00M
        }
650
651
3.00M
        this->data(place).add(timestamp, events);
652
3.00M
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE3addEPcPPKNS_7IColumnElRNS_5ArenaE
653
654
    void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs,
655
160
               Arena&) const override {
656
160
        this->data(place).merge(this->data(rhs));
657
160
    }
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE5mergeEPcPKcRNS_5ArenaE
Line
Count
Source
655
80
               Arena&) const override {
656
80
        this->data(place).merge(this->data(rhs));
657
80
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE5mergeEPcPKcRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE5mergeEPcPKcRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE5mergeEPcPKcRNS_5ArenaE
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE5mergeEPcPKcRNS_5ArenaE
Line
Count
Source
655
80
               Arena&) const override {
656
80
        this->data(place).merge(this->data(rhs));
657
80
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE5mergeEPcPKcRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE5mergeEPcPKcRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE5mergeEPcPKcRNS_5ArenaE
658
659
77
    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override {
660
77
        this->data(place).write(buf);
661
77
    }
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE9serializeEPKcRNS_14BufferWritableE
Line
Count
Source
659
39
    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override {
660
39
        this->data(place).write(buf);
661
39
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE9serializeEPKcRNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE9serializeEPKcRNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE9serializeEPKcRNS_14BufferWritableE
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE9serializeEPKcRNS_14BufferWritableE
Line
Count
Source
659
38
    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override {
660
38
        this->data(place).write(buf);
661
38
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE9serializeEPKcRNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE9serializeEPKcRNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE9serializeEPKcRNS_14BufferWritableE
662
663
    void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf,
664
85
                     Arena&) const override {
665
85
        auto& state = AggregateFunctionSequenceBase::data(place);
666
85
        state.read(buf);
667
        // A serialized uninitialized state has no arguments and must stay uninitialized.
668
85
        if (state.get_arg_count() == 0) {
669
24
            return;
670
24
        }
671
61
        state.init(state.get_pattern(), state.get_arg_count());
672
61
    }
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Line
Count
Source
664
43
                     Arena&) const override {
665
43
        auto& state = AggregateFunctionSequenceBase::data(place);
666
43
        state.read(buf);
667
        // A serialized uninitialized state has no arguments and must stay uninitialized.
668
43
        if (state.get_arg_count() == 0) {
669
12
            return;
670
12
        }
671
31
        state.init(state.get_pattern(), state.get_arg_count());
672
31
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Line
Count
Source
664
42
                     Arena&) const override {
665
42
        auto& state = AggregateFunctionSequenceBase::data(place);
666
42
        state.read(buf);
667
        // A serialized uninitialized state has no arguments and must stay uninitialized.
668
42
        if (state.get_arg_count() == 0) {
669
12
            return;
670
12
        }
671
30
        state.init(state.get_pattern(), state.get_arg_count());
672
30
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
673
674
0
    void check_input_columns_type(const IColumn** columns) const override {
675
0
        this->template check_argument_column_type<ColumnString>(columns[0]);
676
0
        this->template check_argument_column_type<typename PrimitiveTypeTraits<T>::ColumnType>(
677
0
                columns[1]);
678
0
        for (size_t i = 2; i < arg_count; ++i) {
679
0
            this->template check_argument_column_type<ColumnUInt8>(columns[i]);
680
0
        }
681
0
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE24check_input_columns_typeEPPKNS_7IColumnE
682
683
    // the pattern is a constant checked in FE: either a literal or a value only BE can evaluate.
684
    // A literal NULL pattern is rejected by FE; reject a BE-evaluated NULL here too, and validate
685
    // the pattern syntax eagerly. Both checks are normally done lazily in add(), but the nullable
686
    // wrapper above can skip every row (and so skip add() entirely) when any argument, including
687
    // a non-constant one such as the timestamp, is NULL for every row.
688
4
    void check_nullable_input_columns(const IColumn** columns) const {
689
4
        if (columns[0]->empty()) {
690
0
            return;
691
0
        }
692
4
        if (columns[0]->is_null_at(0)) {
693
2
            throw Exception(ErrorCode::INVALID_ARGUMENT,
694
2
                            "the pattern argument of {} must not be null", this->get_name());
695
2
        }
696
2
        std::string pattern = columns[0]->get_data_at(0).to_string();
697
2
        AggregateFunctionSequenceMatchData<T, Derived> validator;
698
2
        validator.init(pattern, arg_count);
699
2
    }
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceMatchILS1_26EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
Line
Count
Source
688
2
    void check_nullable_input_columns(const IColumn** columns) const {
689
2
        if (columns[0]->empty()) {
690
0
            return;
691
0
        }
692
2
        if (columns[0]->is_null_at(0)) {
693
1
            throw Exception(ErrorCode::INVALID_ARGUMENT,
694
1
                            "the pattern argument of {} must not be null", this->get_name());
695
1
        }
696
1
        std::string pattern = columns[0]->get_data_at(0).to_string();
697
1
        AggregateFunctionSequenceMatchData<T, Derived> validator;
698
1
        validator.init(pattern, arg_count);
699
1
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceMatchILS1_43EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceMatchILS1_25EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceMatchILS1_42EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
_ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE26ENS_30AggregateFunctionSequenceCountILS1_26EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
Line
Count
Source
688
2
    void check_nullable_input_columns(const IColumn** columns) const {
689
2
        if (columns[0]->empty()) {
690
0
            return;
691
0
        }
692
2
        if (columns[0]->is_null_at(0)) {
693
1
            throw Exception(ErrorCode::INVALID_ARGUMENT,
694
1
                            "the pattern argument of {} must not be null", this->get_name());
695
1
        }
696
1
        std::string pattern = columns[0]->get_data_at(0).to_string();
697
1
        AggregateFunctionSequenceMatchData<T, Derived> validator;
698
1
        validator.init(pattern, arg_count);
699
1
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE43ENS_30AggregateFunctionSequenceCountILS1_43EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE25ENS_30AggregateFunctionSequenceCountILS1_25EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionSequenceBaseILNS_13PrimitiveTypeE42ENS_30AggregateFunctionSequenceCountILS1_42EEEE28check_nullable_input_columnsEPPKNS_7IColumnE
700
701
private:
702
    size_t arg_count;
703
};
704
705
template <PrimitiveType T>
706
class AggregateFunctionSequenceMatch final
707
        : public AggregateFunctionSequenceBase<T, AggregateFunctionSequenceMatch<T>>,
708
          VarargsExpression,
709
          NullableAggregateFunction {
710
public:
711
    AggregateFunctionSequenceMatch(const DataTypes& arguments, const String& pattern_)
712
            : AggregateFunctionSequenceBase<T, AggregateFunctionSequenceMatch<T>>(arguments,
713
                                                                                  pattern_) {}
714
715
    using AggregateFunctionSequenceBase<
716
            T, AggregateFunctionSequenceMatch<T>>::AggregateFunctionSequenceBase;
717
718
1
    String get_name() const override { return "sequence_match"; }
_ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE26EE8get_nameB5cxx11Ev
Line
Count
Source
718
1
    String get_name() const override { return "sequence_match"; }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE43EE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE25EE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE42EE8get_nameB5cxx11Ev
719
720
104
    DataTypePtr get_return_type() const override { return std::make_shared<DataTypeUInt8>(); }
_ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE26EE15get_return_typeEv
Line
Count
Source
720
104
    DataTypePtr get_return_type() const override { return std::make_shared<DataTypeUInt8>(); }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE43EE15get_return_typeEv
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE25EE15get_return_typeEv
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE42EE15get_return_typeEv
721
722
117
    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
723
117
        auto& output = assert_cast<ColumnUInt8&, TypeCheckOnRelease::DISABLE>(to).get_data();
724
117
        if (!this->data(place).conditions_in_pattern.any()) {
725
13
            output.push_back(false);
726
13
            return;
727
13
        }
728
729
104
        if ((this->data(place).conditions_in_pattern & this->data(place).conditions_met) !=
730
104
            this->data(place).conditions_in_pattern) {
731
61
            output.push_back(false);
732
61
            return;
733
61
        }
734
        // place is essentially an AggregateDataPtr, passed as a ConstAggregateDataPtr.
735
43
        this->data(const_cast<AggregateDataPtr>(place)).sort();
736
737
43
        const auto& data_ref = this->data(place);
738
739
43
        const auto events_begin = std::begin(data_ref.events_list);
740
43
        const auto events_end = std::end(data_ref.events_list);
741
43
        auto events_it = events_begin;
742
743
43
        bool match = (this->data(place).pattern_has_time
744
43
                              ? (this->data(place).could_match_deterministic_parts(events_begin,
745
6
                                                                                   events_end) &&
746
6
                                 this->data(place).backtracking_match(events_it, events_end))
747
43
                              : this->data(place).dfa_match(events_it, events_end));
748
43
        output.push_back(match);
749
43
    }
_ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE26EE18insert_result_intoEPKcRNS_7IColumnE
Line
Count
Source
722
117
    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
723
117
        auto& output = assert_cast<ColumnUInt8&, TypeCheckOnRelease::DISABLE>(to).get_data();
724
117
        if (!this->data(place).conditions_in_pattern.any()) {
725
13
            output.push_back(false);
726
13
            return;
727
13
        }
728
729
104
        if ((this->data(place).conditions_in_pattern & this->data(place).conditions_met) !=
730
104
            this->data(place).conditions_in_pattern) {
731
61
            output.push_back(false);
732
61
            return;
733
61
        }
734
        // place is essentially an AggregateDataPtr, passed as a ConstAggregateDataPtr.
735
43
        this->data(const_cast<AggregateDataPtr>(place)).sort();
736
737
43
        const auto& data_ref = this->data(place);
738
739
43
        const auto events_begin = std::begin(data_ref.events_list);
740
43
        const auto events_end = std::end(data_ref.events_list);
741
43
        auto events_it = events_begin;
742
743
43
        bool match = (this->data(place).pattern_has_time
744
43
                              ? (this->data(place).could_match_deterministic_parts(events_begin,
745
6
                                                                                   events_end) &&
746
6
                                 this->data(place).backtracking_match(events_it, events_end))
747
43
                              : this->data(place).dfa_match(events_it, events_end));
748
43
        output.push_back(match);
749
43
    }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE43EE18insert_result_intoEPKcRNS_7IColumnE
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE25EE18insert_result_intoEPKcRNS_7IColumnE
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceMatchILNS_13PrimitiveTypeE42EE18insert_result_intoEPKcRNS_7IColumnE
750
};
751
752
template <PrimitiveType T>
753
class AggregateFunctionSequenceCount final
754
        : public AggregateFunctionSequenceBase<T, AggregateFunctionSequenceCount<T>>,
755
          VarargsExpression,
756
          NotNullableAggregateFunction {
757
public:
758
    AggregateFunctionSequenceCount(const DataTypes& arguments, const String& pattern_)
759
            : AggregateFunctionSequenceBase<T, AggregateFunctionSequenceCount<T>>(arguments,
760
                                                                                  pattern_) {}
761
762
    using AggregateFunctionSequenceBase<
763
            T, AggregateFunctionSequenceCount<T>>::AggregateFunctionSequenceBase;
764
765
1
    String get_name() const override { return "sequence_count"; }
_ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE26EE8get_nameB5cxx11Ev
Line
Count
Source
765
1
    String get_name() const override { return "sequence_count"; }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE43EE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE25EE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE42EE8get_nameB5cxx11Ev
766
767
104
    DataTypePtr get_return_type() const override { return std::make_shared<DataTypeInt64>(); }
_ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE26EE15get_return_typeEv
Line
Count
Source
767
104
    DataTypePtr get_return_type() const override { return std::make_shared<DataTypeInt64>(); }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE43EE15get_return_typeEv
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE25EE15get_return_typeEv
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE42EE15get_return_typeEv
768
769
115
    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
770
115
        auto& output = assert_cast<ColumnInt64&, TypeCheckOnRelease::DISABLE>(to).get_data();
771
115
        if (!this->data(place).conditions_in_pattern.any()) {
772
13
            output.push_back(0);
773
13
            return;
774
13
        }
775
776
102
        if ((this->data(place).conditions_in_pattern & this->data(place).conditions_met) !=
777
102
            this->data(place).conditions_in_pattern) {
778
60
            output.push_back(0);
779
60
            return;
780
60
        }
781
        // place is essentially an AggregateDataPtr, passed as a ConstAggregateDataPtr.
782
42
        this->data(const_cast<AggregateDataPtr>(place)).sort();
783
42
        output.push_back(count(place));
784
42
    }
_ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE26EE18insert_result_intoEPKcRNS_7IColumnE
Line
Count
Source
769
115
    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
770
115
        auto& output = assert_cast<ColumnInt64&, TypeCheckOnRelease::DISABLE>(to).get_data();
771
115
        if (!this->data(place).conditions_in_pattern.any()) {
772
13
            output.push_back(0);
773
13
            return;
774
13
        }
775
776
102
        if ((this->data(place).conditions_in_pattern & this->data(place).conditions_met) !=
777
102
            this->data(place).conditions_in_pattern) {
778
60
            output.push_back(0);
779
60
            return;
780
60
        }
781
        // place is essentially an AggregateDataPtr, passed as a ConstAggregateDataPtr.
782
42
        this->data(const_cast<AggregateDataPtr>(place)).sort();
783
42
        output.push_back(count(place));
784
42
    }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE43EE18insert_result_intoEPKcRNS_7IColumnE
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE25EE18insert_result_intoEPKcRNS_7IColumnE
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE42EE18insert_result_intoEPKcRNS_7IColumnE
785
786
private:
787
42
    UInt64 count(ConstAggregateDataPtr __restrict place) const {
788
42
        const auto& data_ref = this->data(place);
789
790
42
        const auto events_begin = std::begin(data_ref.events_list);
791
42
        const auto events_end = std::end(data_ref.events_list);
792
42
        auto events_it = events_begin;
793
794
42
        size_t count = 0;
795
        // check if there is a chance of matching the sequence at least once
796
42
        if (this->data(place).could_match_deterministic_parts(events_begin, events_end)) {
797
91
            while (events_it != events_end &&
798
91
                   this->data(place).backtracking_match(events_it, events_end))
799
49
                ++count;
800
42
        }
801
802
42
        return count;
803
42
    }
_ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE26EE5countEPKc
Line
Count
Source
787
42
    UInt64 count(ConstAggregateDataPtr __restrict place) const {
788
42
        const auto& data_ref = this->data(place);
789
790
42
        const auto events_begin = std::begin(data_ref.events_list);
791
42
        const auto events_end = std::end(data_ref.events_list);
792
42
        auto events_it = events_begin;
793
794
42
        size_t count = 0;
795
        // check if there is a chance of matching the sequence at least once
796
42
        if (this->data(place).could_match_deterministic_parts(events_begin, events_end)) {
797
91
            while (events_it != events_end &&
798
91
                   this->data(place).backtracking_match(events_it, events_end))
799
49
                ++count;
800
42
        }
801
802
42
        return count;
803
42
    }
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE43EE5countEPKc
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE25EE5countEPKc
Unexecuted instantiation: _ZNK5doris30AggregateFunctionSequenceCountILNS_13PrimitiveTypeE42EE5countEPKc
804
};
805
806
} // namespace doris