Coverage Report

Created: 2026-09-09 04:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_window_funnel.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/AggregateFunctionWindowFunnel.h
20
// and modified by Doris
21
22
#pragma once
23
24
#include <gen_cpp/data.pb.h>
25
26
#include <algorithm>
27
#include <boost/iterator/iterator_facade.hpp>
28
#include <iterator>
29
#include <memory>
30
#include <type_traits>
31
#include <utility>
32
33
#include "common/cast_set.h"
34
#include "common/exception.h"
35
#include "common/status.h"
36
#include "core/assert_cast.h"
37
#include "core/binary_cast.hpp"
38
#include "core/column/column_string.h"
39
#include "core/column/column_vector.h"
40
#include "core/data_type/data_type_number.h"
41
#include "core/types.h"
42
#include "core/value/vdatetime_value.h"
43
#include "exec/sort/sort_block.h"
44
#include "exprs/aggregate/aggregate_function.h"
45
#include "util/simd/bits.h"
46
#include "util/var_int.h"
47
48
namespace doris {
49
class Arena;
50
class BufferReadable;
51
class BufferWritable;
52
class IColumn;
53
} // namespace doris
54
55
namespace doris {
56
57
enum class WindowFunnelMode : Int64 { INVALID, DEFAULT, DEDUPLICATION, FIXED, INCREASE };
58
59
252
inline WindowFunnelMode string_to_window_funnel_mode(const String& string) {
60
252
    if (string == "default") {
61
95
        return WindowFunnelMode::DEFAULT;
62
157
    } else if (string == "deduplication") {
63
36
        return WindowFunnelMode::DEDUPLICATION;
64
121
    } else if (string == "fixed") {
65
19
        return WindowFunnelMode::FIXED;
66
102
    } else if (string == "increase") {
67
18
        return WindowFunnelMode::INCREASE;
68
84
    } else {
69
84
        return WindowFunnelMode::INVALID;
70
84
    }
71
252
}
72
73
template <PrimitiveType T>
74
struct DataValue {
75
    using TimestampEvent = std::vector<ColumnUInt8::Container>;
76
    using DateValueType = typename PrimitiveTypeTraits<T>::CppType;
77
    std::vector<DateValueType> dt;
78
    TimestampEvent event_columns_data;
79
    bool operator<(const DataValue& other) const { return dt < other.dt; }
80
3
    void clear() {
81
3
        dt.clear();
82
9
        for (auto& data : event_columns_data) {
83
9
            data.clear();
84
9
        }
85
3
    }
_ZN5doris9DataValueILNS_13PrimitiveTypeE43EE5clearEv
Line
Count
Source
80
1
    void clear() {
81
1
        dt.clear();
82
1
        for (auto& data : event_columns_data) {
83
1
            data.clear();
84
1
        }
85
1
    }
_ZN5doris9DataValueILNS_13PrimitiveTypeE26EE5clearEv
Line
Count
Source
80
2
    void clear() {
81
2
        dt.clear();
82
8
        for (auto& data : event_columns_data) {
83
8
            data.clear();
84
8
        }
85
2
    }
Unexecuted instantiation: _ZN5doris9DataValueILNS_13PrimitiveTypeE42EE5clearEv
86
75
    auto size() const { return dt.size(); }
_ZNK5doris9DataValueILNS_13PrimitiveTypeE43EE4sizeEv
Line
Count
Source
86
3
    auto size() const { return dt.size(); }
_ZNK5doris9DataValueILNS_13PrimitiveTypeE26EE4sizeEv
Line
Count
Source
86
72
    auto size() const { return dt.size(); }
Unexecuted instantiation: _ZNK5doris9DataValueILNS_13PrimitiveTypeE42EE4sizeEv
87
11
    bool empty() const { return dt.empty(); }
_ZNK5doris9DataValueILNS_13PrimitiveTypeE26EE5emptyEv
Line
Count
Source
87
11
    bool empty() const { return dt.empty(); }
Unexecuted instantiation: _ZNK5doris9DataValueILNS_13PrimitiveTypeE43EE5emptyEv
Unexecuted instantiation: _ZNK5doris9DataValueILNS_13PrimitiveTypeE42EE5emptyEv
88
    std::string debug_string() const {
89
        std::string result = "\n" + std::to_string(dt.size()) + " " +
90
                             std::to_string(event_columns_data[0].size()) + "\n";
91
        for (size_t i = 0; i < dt.size(); ++i) {
92
            result += dt[i].debug_string() + " ,";
93
            for (const auto& event : event_columns_data) {
94
                result += std::to_string(event[i]) + ",";
95
            }
96
            result += "\n";
97
        }
98
        return result;
99
    }
100
};
101
102
template <PrimitiveType T>
103
struct WindowFunnelState {
104
    static constexpr PrimitiveType PType = T;
105
    using NativeType = typename PrimitiveTypeTraits<T>::StorageFieldType;
106
    using DateValueType = typename PrimitiveTypeTraits<T>::CppType;
107
    int event_count = 0;
108
    int64_t window;
109
    bool enable_mode;
110
    WindowFunnelMode window_funnel_mode;
111
    DataValue<T> events_list;
112
113
37
    WindowFunnelState() {
114
37
        event_count = 0;
115
37
        window = 0;
116
37
        window_funnel_mode = WindowFunnelMode::INVALID;
117
37
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EEC2Ev
Line
Count
Source
113
3
    WindowFunnelState() {
114
3
        event_count = 0;
115
3
        window = 0;
116
3
        window_funnel_mode = WindowFunnelMode::INVALID;
117
3
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EEC2Ev
Line
Count
Source
113
34
    WindowFunnelState() {
114
34
        event_count = 0;
115
34
        window = 0;
116
34
        window_funnel_mode = WindowFunnelMode::INVALID;
117
34
    }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EEC2Ev
118
37
    WindowFunnelState(int arg_event_count) : WindowFunnelState() {
119
37
        event_count = arg_event_count;
120
37
        events_list.event_columns_data.resize(event_count);
121
37
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EEC2Ei
Line
Count
Source
118
3
    WindowFunnelState(int arg_event_count) : WindowFunnelState() {
119
3
        event_count = arg_event_count;
120
3
        events_list.event_columns_data.resize(event_count);
121
3
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EEC2Ei
Line
Count
Source
118
34
    WindowFunnelState(int arg_event_count) : WindowFunnelState() {
119
34
        event_count = arg_event_count;
120
34
        events_list.event_columns_data.resize(event_count);
121
34
    }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EEC2Ei
122
123
0
    void reset() { events_list.clear(); }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE5resetEv
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE5resetEv
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE5resetEv
124
125
84
    void add(const IColumn** arg_columns, ssize_t row_num, int64_t win, WindowFunnelMode mode) {
126
84
        window = win;
127
84
        window_funnel_mode = enable_mode ? mode : WindowFunnelMode::DEFAULT;
128
84
        events_list.dt.emplace_back(
129
84
                assert_cast<const typename PrimitiveTypeTraits<PType>::ColumnType&,
130
84
                            TypeCheckOnRelease::DISABLE>(*arg_columns[2])
131
84
                        .get_data()[row_num]);
132
420
        for (int i = 0; i < event_count; i++) {
133
336
            events_list.event_columns_data[i].emplace_back(
134
336
                    assert_cast<const ColumnUInt8&, TypeCheckOnRelease::DISABLE>(
135
336
                            *arg_columns[3 + i])
136
336
                            .get_data()[row_num]);
137
336
        }
138
84
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE3addEPPKNS_7IColumnEllNS_16WindowFunnelModeE
Line
Count
Source
125
84
    void add(const IColumn** arg_columns, ssize_t row_num, int64_t win, WindowFunnelMode mode) {
126
84
        window = win;
127
84
        window_funnel_mode = enable_mode ? mode : WindowFunnelMode::DEFAULT;
128
84
        events_list.dt.emplace_back(
129
84
                assert_cast<const typename PrimitiveTypeTraits<PType>::ColumnType&,
130
84
                            TypeCheckOnRelease::DISABLE>(*arg_columns[2])
131
84
                        .get_data()[row_num]);
132
420
        for (int i = 0; i < event_count; i++) {
133
336
            events_list.event_columns_data[i].emplace_back(
134
336
                    assert_cast<const ColumnUInt8&, TypeCheckOnRelease::DISABLE>(
135
336
                            *arg_columns[3 + i])
136
336
                            .get_data()[row_num]);
137
336
        }
138
84
    }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE3addEPPKNS_7IColumnEllNS_16WindowFunnelModeE
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE3addEPPKNS_7IColumnEllNS_16WindowFunnelModeE
139
140
    // todo: rethink thid sort method.
141
24
    void sort() {
142
24
        auto num = events_list.size();
143
24
        std::vector<size_t> indices(num);
144
24
        std::iota(indices.begin(), indices.end(), 0);
145
24
        std::sort(indices.begin(), indices.end(),
146
102
                  [this](size_t i1, size_t i2) { return events_list.dt[i1] < events_list.dt[i2]; });
_ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE4sortEvENKUlmmE_clEmm
Line
Count
Source
146
102
                  [this](size_t i1, size_t i2) { return events_list.dt[i1] < events_list.dt[i2]; });
Unexecuted instantiation: _ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE4sortEvENKUlmmE_clEmm
Unexecuted instantiation: _ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE4sortEvENKUlmmE_clEmm
147
148
120
        auto reorder = [&indices, &num](auto& vec) {
149
120
            std::decay_t<decltype(vec)> temp;
150
120
            temp.resize(num);
151
560
            for (auto i = 0; i < num; i++) {
152
440
                temp[i] = vec[indices[i]];
153
440
            }
154
120
            std::swap(vec, temp);
155
120
        };
_ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE4sortEvENKUlRT_E_clISt6vectorINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEESaISA_EEEEDaS4_
Line
Count
Source
148
24
        auto reorder = [&indices, &num](auto& vec) {
149
24
            std::decay_t<decltype(vec)> temp;
150
24
            temp.resize(num);
151
112
            for (auto i = 0; i < num; i++) {
152
88
                temp[i] = vec[indices[i]];
153
88
            }
154
24
            std::swap(vec, temp);
155
24
        };
_ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE4sortEvENKUlRT_E_clINS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEEEDaS4_
Line
Count
Source
148
96
        auto reorder = [&indices, &num](auto& vec) {
149
96
            std::decay_t<decltype(vec)> temp;
150
96
            temp.resize(num);
151
448
            for (auto i = 0; i < num; i++) {
152
352
                temp[i] = vec[indices[i]];
153
352
            }
154
96
            std::swap(vec, temp);
155
96
        };
Unexecuted instantiation: _ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE4sortEvENKUlRT_E_clISt6vectorINS_16TimeStampNsValueESaIS8_EEEEDaS4_
Unexecuted instantiation: _ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE4sortEvENKUlRT_E_clINS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEEEDaS4_
Unexecuted instantiation: _ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE4sortEvENKUlRT_E_clISt6vectorINS_16TimestampTzValueESaIS8_EEEEDaS4_
Unexecuted instantiation: _ZZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE4sortEvENKUlRT_E_clINS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEEEEDaS4_
156
157
24
        reorder(events_list.dt);
158
96
        for (auto& inner_vec : events_list.event_columns_data) {
159
96
            reorder(inner_vec);
160
96
        }
161
24
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE4sortEv
Line
Count
Source
141
24
    void sort() {
142
24
        auto num = events_list.size();
143
24
        std::vector<size_t> indices(num);
144
24
        std::iota(indices.begin(), indices.end(), 0);
145
24
        std::sort(indices.begin(), indices.end(),
146
24
                  [this](size_t i1, size_t i2) { return events_list.dt[i1] < events_list.dt[i2]; });
147
148
24
        auto reorder = [&indices, &num](auto& vec) {
149
24
            std::decay_t<decltype(vec)> temp;
150
24
            temp.resize(num);
151
24
            for (auto i = 0; i < num; i++) {
152
24
                temp[i] = vec[indices[i]];
153
24
            }
154
24
            std::swap(vec, temp);
155
24
        };
156
157
24
        reorder(events_list.dt);
158
96
        for (auto& inner_vec : events_list.event_columns_data) {
159
96
            reorder(inner_vec);
160
96
        }
161
24
    }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE4sortEv
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE4sortEv
162
163
    bool _within_window(const DateValueType& base_timestamp, const DateValueType& current_timestamp,
164
55
                        const DateValueType& end_timestamp) const {
165
55
        if constexpr (T == TYPE_TIMESTAMP_NS) {
166
1
            const auto elapsed_nanos = static_cast<__int128>(current_timestamp.epoch_nanos()) -
167
1
                                       base_timestamp.epoch_nanos();
168
1
            const auto window_nanos =
169
1
                    static_cast<__int128>(window) * TimeStampNsValue::NANOS_PER_SECOND;
170
1
            return elapsed_nanos <= window_nanos;
171
1
        }
172
0
        return current_timestamp <= end_timestamp;
173
55
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE14_within_windowERKNS_16TimeStampNsValueES5_S5_
Line
Count
Source
164
1
                        const DateValueType& end_timestamp) const {
165
1
        if constexpr (T == TYPE_TIMESTAMP_NS) {
166
1
            const auto elapsed_nanos = static_cast<__int128>(current_timestamp.epoch_nanos()) -
167
1
                                       base_timestamp.epoch_nanos();
168
1
            const auto window_nanos =
169
1
                    static_cast<__int128>(window) * TimeStampNsValue::NANOS_PER_SECOND;
170
1
            return elapsed_nanos <= window_nanos;
171
1
        }
172
0
        return current_timestamp <= end_timestamp;
173
1
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE14_within_windowERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEES7_S7_
Line
Count
Source
164
54
                        const DateValueType& end_timestamp) const {
165
        if constexpr (T == TYPE_TIMESTAMP_NS) {
166
            const auto elapsed_nanos = static_cast<__int128>(current_timestamp.epoch_nanos()) -
167
                                       base_timestamp.epoch_nanos();
168
            const auto window_nanos =
169
                    static_cast<__int128>(window) * TimeStampNsValue::NANOS_PER_SECOND;
170
            return elapsed_nanos <= window_nanos;
171
        }
172
54
        return current_timestamp <= end_timestamp;
173
54
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE14_within_windowERKNS_16TimestampTzValueES5_S5_
174
175
    template <WindowFunnelMode WINDOW_FUNNEL_MODE>
176
37
    int _match_event_list(size_t& start_row, size_t row_count) const {
177
37
        int matched_count = 0;
178
37
        DateValueType end_timestamp;
179
180
37
        if (window < 0) {
181
0
            throw Exception(ErrorCode::INVALID_ARGUMENT,
182
0
                            "the sliding time window must be a positive integer, but got: {}",
183
0
                            window);
184
0
        }
185
37
        int column_idx = 0;
186
37
        const auto& timestamp_data = events_list.dt;
187
37
        const auto& first_event_data = events_list.event_columns_data[column_idx].data();
188
37
        auto match_row = simd::find_one(first_event_data, start_row, row_count);
189
37
        start_row = match_row + 1;
190
37
        if (match_row < row_count) {
191
23
            auto prev_timestamp = timestamp_data[match_row];
192
23
            const auto first_timestamp = prev_timestamp;
193
23
            if constexpr (T != TYPE_TIMESTAMP_NS) {
194
22
                TimeInterval interval(SECOND, window, false);
195
22
                end_timestamp = first_timestamp;
196
22
                end_timestamp.template date_add_interval<SECOND>(interval);
197
22
            }
198
199
23
            matched_count++;
200
23
            column_idx++;
201
23
            auto last_match_row = match_row;
202
23
            ++match_row;
203
64
            for (; column_idx < event_count && match_row < row_count; column_idx++, match_row++) {
204
55
                const auto& event_data = events_list.event_columns_data[column_idx];
205
55
                if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::FIXED) {
206
0
                    if (event_data[match_row] == 1) {
207
0
                        auto current_timestamp = timestamp_data[match_row];
208
0
                        if (_within_window(first_timestamp, current_timestamp, end_timestamp)) {
209
0
                            matched_count++;
210
0
                            continue;
211
0
                        }
212
0
                    }
213
0
                    break;
214
0
                }
215
0
                match_row = simd::find_one(event_data.data(), match_row, row_count);
216
55
                if (match_row < row_count) {
217
55
                    auto current_timestamp = timestamp_data[match_row];
218
55
                    bool is_matched =
219
55
                            _within_window(first_timestamp, current_timestamp, end_timestamp);
220
55
                    if (is_matched) {
221
41
                        if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::INCREASE) {
222
0
                            is_matched = current_timestamp > prev_timestamp;
223
0
                        }
224
41
                    }
225
55
                    if (!is_matched) {
226
14
                        break;
227
14
                    }
228
41
                    if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::INCREASE) {
229
0
                        prev_timestamp = timestamp_data[match_row];
230
0
                    }
231
41
                    if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::DEDUPLICATION) {
232
0
                        bool is_dup = false;
233
0
                        if (match_row != last_match_row + 1) {
234
0
                            for (int tmp_column_idx = 0; tmp_column_idx < column_idx;
235
0
                                 tmp_column_idx++) {
236
0
                                const auto& tmp_event_data =
237
0
                                        events_list.event_columns_data[tmp_column_idx].data();
238
0
                                auto dup_match_row = simd::find_one(tmp_event_data,
239
0
                                                                    last_match_row + 1, match_row);
240
0
                                if (dup_match_row < match_row) {
241
0
                                    is_dup = true;
242
0
                                    break;
243
0
                                }
244
0
                            }
245
0
                        }
246
0
                        if (is_dup) {
247
0
                            break;
248
0
                        }
249
0
                        last_match_row = match_row;
250
0
                    }
251
0
                    matched_count++;
252
41
                } else {
253
0
                    break;
254
0
                }
255
55
            }
256
23
        }
257
0
        return matched_count;
258
0
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE17_match_event_listILNS_16WindowFunnelModeE1EEEiRmm
Line
Count
Source
176
1
    int _match_event_list(size_t& start_row, size_t row_count) const {
177
1
        int matched_count = 0;
178
1
        DateValueType end_timestamp;
179
180
1
        if (window < 0) {
181
0
            throw Exception(ErrorCode::INVALID_ARGUMENT,
182
0
                            "the sliding time window must be a positive integer, but got: {}",
183
0
                            window);
184
0
        }
185
1
        int column_idx = 0;
186
1
        const auto& timestamp_data = events_list.dt;
187
1
        const auto& first_event_data = events_list.event_columns_data[column_idx].data();
188
1
        auto match_row = simd::find_one(first_event_data, start_row, row_count);
189
1
        start_row = match_row + 1;
190
1
        if (match_row < row_count) {
191
1
            auto prev_timestamp = timestamp_data[match_row];
192
1
            const auto first_timestamp = prev_timestamp;
193
            if constexpr (T != TYPE_TIMESTAMP_NS) {
194
                TimeInterval interval(SECOND, window, false);
195
                end_timestamp = first_timestamp;
196
                end_timestamp.template date_add_interval<SECOND>(interval);
197
            }
198
199
1
            matched_count++;
200
1
            column_idx++;
201
1
            auto last_match_row = match_row;
202
1
            ++match_row;
203
2
            for (; column_idx < event_count && match_row < row_count; column_idx++, match_row++) {
204
1
                const auto& event_data = events_list.event_columns_data[column_idx];
205
                if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::FIXED) {
206
                    if (event_data[match_row] == 1) {
207
                        auto current_timestamp = timestamp_data[match_row];
208
                        if (_within_window(first_timestamp, current_timestamp, end_timestamp)) {
209
                            matched_count++;
210
                            continue;
211
                        }
212
                    }
213
                    break;
214
                }
215
1
                match_row = simd::find_one(event_data.data(), match_row, row_count);
216
1
                if (match_row < row_count) {
217
1
                    auto current_timestamp = timestamp_data[match_row];
218
1
                    bool is_matched =
219
1
                            _within_window(first_timestamp, current_timestamp, end_timestamp);
220
1
                    if (is_matched) {
221
                        if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::INCREASE) {
222
                            is_matched = current_timestamp > prev_timestamp;
223
                        }
224
1
                    }
225
1
                    if (!is_matched) {
226
0
                        break;
227
0
                    }
228
                    if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::INCREASE) {
229
                        prev_timestamp = timestamp_data[match_row];
230
                    }
231
                    if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::DEDUPLICATION) {
232
                        bool is_dup = false;
233
                        if (match_row != last_match_row + 1) {
234
                            for (int tmp_column_idx = 0; tmp_column_idx < column_idx;
235
                                 tmp_column_idx++) {
236
                                const auto& tmp_event_data =
237
                                        events_list.event_columns_data[tmp_column_idx].data();
238
                                auto dup_match_row = simd::find_one(tmp_event_data,
239
                                                                    last_match_row + 1, match_row);
240
                                if (dup_match_row < match_row) {
241
                                    is_dup = true;
242
                                    break;
243
                                }
244
                            }
245
                        }
246
                        if (is_dup) {
247
                            break;
248
                        }
249
                        last_match_row = match_row;
250
                    }
251
1
                    matched_count++;
252
1
                } else {
253
0
                    break;
254
0
                }
255
1
            }
256
1
        }
257
1
        return matched_count;
258
1
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE17_match_event_listILNS_16WindowFunnelModeE2EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE17_match_event_listILNS_16WindowFunnelModeE3EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE17_match_event_listILNS_16WindowFunnelModeE4EEEiRmm
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE17_match_event_listILNS_16WindowFunnelModeE1EEEiRmm
Line
Count
Source
176
36
    int _match_event_list(size_t& start_row, size_t row_count) const {
177
36
        int matched_count = 0;
178
36
        DateValueType end_timestamp;
179
180
36
        if (window < 0) {
181
0
            throw Exception(ErrorCode::INVALID_ARGUMENT,
182
0
                            "the sliding time window must be a positive integer, but got: {}",
183
0
                            window);
184
0
        }
185
36
        int column_idx = 0;
186
36
        const auto& timestamp_data = events_list.dt;
187
36
        const auto& first_event_data = events_list.event_columns_data[column_idx].data();
188
36
        auto match_row = simd::find_one(first_event_data, start_row, row_count);
189
36
        start_row = match_row + 1;
190
36
        if (match_row < row_count) {
191
22
            auto prev_timestamp = timestamp_data[match_row];
192
22
            const auto first_timestamp = prev_timestamp;
193
22
            if constexpr (T != TYPE_TIMESTAMP_NS) {
194
22
                TimeInterval interval(SECOND, window, false);
195
22
                end_timestamp = first_timestamp;
196
22
                end_timestamp.template date_add_interval<SECOND>(interval);
197
22
            }
198
199
22
            matched_count++;
200
22
            column_idx++;
201
22
            auto last_match_row = match_row;
202
22
            ++match_row;
203
62
            for (; column_idx < event_count && match_row < row_count; column_idx++, match_row++) {
204
54
                const auto& event_data = events_list.event_columns_data[column_idx];
205
                if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::FIXED) {
206
                    if (event_data[match_row] == 1) {
207
                        auto current_timestamp = timestamp_data[match_row];
208
                        if (_within_window(first_timestamp, current_timestamp, end_timestamp)) {
209
                            matched_count++;
210
                            continue;
211
                        }
212
                    }
213
                    break;
214
                }
215
54
                match_row = simd::find_one(event_data.data(), match_row, row_count);
216
54
                if (match_row < row_count) {
217
54
                    auto current_timestamp = timestamp_data[match_row];
218
54
                    bool is_matched =
219
54
                            _within_window(first_timestamp, current_timestamp, end_timestamp);
220
54
                    if (is_matched) {
221
                        if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::INCREASE) {
222
                            is_matched = current_timestamp > prev_timestamp;
223
                        }
224
40
                    }
225
54
                    if (!is_matched) {
226
14
                        break;
227
14
                    }
228
                    if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::INCREASE) {
229
                        prev_timestamp = timestamp_data[match_row];
230
                    }
231
                    if constexpr (WINDOW_FUNNEL_MODE == WindowFunnelMode::DEDUPLICATION) {
232
                        bool is_dup = false;
233
                        if (match_row != last_match_row + 1) {
234
                            for (int tmp_column_idx = 0; tmp_column_idx < column_idx;
235
                                 tmp_column_idx++) {
236
                                const auto& tmp_event_data =
237
                                        events_list.event_columns_data[tmp_column_idx].data();
238
                                auto dup_match_row = simd::find_one(tmp_event_data,
239
                                                                    last_match_row + 1, match_row);
240
                                if (dup_match_row < match_row) {
241
                                    is_dup = true;
242
                                    break;
243
                                }
244
                            }
245
                        }
246
                        if (is_dup) {
247
                            break;
248
                        }
249
                        last_match_row = match_row;
250
                    }
251
40
                    matched_count++;
252
40
                } else {
253
0
                    break;
254
0
                }
255
54
            }
256
22
        }
257
36
        return matched_count;
258
36
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE17_match_event_listILNS_16WindowFunnelModeE2EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE17_match_event_listILNS_16WindowFunnelModeE3EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE17_match_event_listILNS_16WindowFunnelModeE4EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE17_match_event_listILNS_16WindowFunnelModeE1EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE17_match_event_listILNS_16WindowFunnelModeE2EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE17_match_event_listILNS_16WindowFunnelModeE3EEEiRmm
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE17_match_event_listILNS_16WindowFunnelModeE4EEEiRmm
259
260
    template <WindowFunnelMode WINDOW_FUNNEL_MODE>
261
23
    int _get_internal() const {
262
23
        size_t start_row = 0;
263
23
        int max_found_event_count = 0;
264
23
        auto row_count = events_list.size();
265
51
        while (start_row < row_count) {
266
37
            auto found_event_count = _match_event_list<WINDOW_FUNNEL_MODE>(start_row, row_count);
267
37
            if (found_event_count == event_count) {
268
9
                return found_event_count;
269
9
            }
270
28
            max_found_event_count = std::max(max_found_event_count, found_event_count);
271
28
        }
272
14
        return max_found_event_count;
273
23
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE13_get_internalILNS_16WindowFunnelModeE1EEEiv
Line
Count
Source
261
1
    int _get_internal() const {
262
1
        size_t start_row = 0;
263
1
        int max_found_event_count = 0;
264
1
        auto row_count = events_list.size();
265
1
        while (start_row < row_count) {
266
1
            auto found_event_count = _match_event_list<WINDOW_FUNNEL_MODE>(start_row, row_count);
267
1
            if (found_event_count == event_count) {
268
1
                return found_event_count;
269
1
            }
270
0
            max_found_event_count = std::max(max_found_event_count, found_event_count);
271
0
        }
272
0
        return max_found_event_count;
273
1
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE13_get_internalILNS_16WindowFunnelModeE2EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE13_get_internalILNS_16WindowFunnelModeE3EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE13_get_internalILNS_16WindowFunnelModeE4EEEiv
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE13_get_internalILNS_16WindowFunnelModeE1EEEiv
Line
Count
Source
261
22
    int _get_internal() const {
262
22
        size_t start_row = 0;
263
22
        int max_found_event_count = 0;
264
22
        auto row_count = events_list.size();
265
50
        while (start_row < row_count) {
266
36
            auto found_event_count = _match_event_list<WINDOW_FUNNEL_MODE>(start_row, row_count);
267
36
            if (found_event_count == event_count) {
268
8
                return found_event_count;
269
8
            }
270
28
            max_found_event_count = std::max(max_found_event_count, found_event_count);
271
28
        }
272
14
        return max_found_event_count;
273
22
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE13_get_internalILNS_16WindowFunnelModeE2EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE13_get_internalILNS_16WindowFunnelModeE3EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE13_get_internalILNS_16WindowFunnelModeE4EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE13_get_internalILNS_16WindowFunnelModeE1EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE13_get_internalILNS_16WindowFunnelModeE2EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE13_get_internalILNS_16WindowFunnelModeE3EEEiv
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE13_get_internalILNS_16WindowFunnelModeE4EEEiv
274
25
    int get() const {
275
25
        auto row_count = events_list.size();
276
25
        if (event_count == 0 || row_count == 0) {
277
2
            return 0;
278
2
        }
279
23
        switch (window_funnel_mode) {
280
23
        case WindowFunnelMode::DEFAULT:
281
23
            return _get_internal<WindowFunnelMode::DEFAULT>();
282
0
        case WindowFunnelMode::DEDUPLICATION:
283
0
            return _get_internal<WindowFunnelMode::DEDUPLICATION>();
284
0
        case WindowFunnelMode::FIXED:
285
0
            return _get_internal<WindowFunnelMode::FIXED>();
286
0
        case WindowFunnelMode::INCREASE:
287
0
            return _get_internal<WindowFunnelMode::INCREASE>();
288
0
        default:
289
0
            throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Invalid window_funnel mode");
290
0
            return 0;
291
23
        }
292
23
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE3getEv
Line
Count
Source
274
1
    int get() const {
275
1
        auto row_count = events_list.size();
276
1
        if (event_count == 0 || row_count == 0) {
277
0
            return 0;
278
0
        }
279
1
        switch (window_funnel_mode) {
280
1
        case WindowFunnelMode::DEFAULT:
281
1
            return _get_internal<WindowFunnelMode::DEFAULT>();
282
0
        case WindowFunnelMode::DEDUPLICATION:
283
0
            return _get_internal<WindowFunnelMode::DEDUPLICATION>();
284
0
        case WindowFunnelMode::FIXED:
285
0
            return _get_internal<WindowFunnelMode::FIXED>();
286
0
        case WindowFunnelMode::INCREASE:
287
0
            return _get_internal<WindowFunnelMode::INCREASE>();
288
0
        default:
289
0
            throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Invalid window_funnel mode");
290
0
            return 0;
291
1
        }
292
1
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE3getEv
Line
Count
Source
274
24
    int get() const {
275
24
        auto row_count = events_list.size();
276
24
        if (event_count == 0 || row_count == 0) {
277
2
            return 0;
278
2
        }
279
22
        switch (window_funnel_mode) {
280
22
        case WindowFunnelMode::DEFAULT:
281
22
            return _get_internal<WindowFunnelMode::DEFAULT>();
282
0
        case WindowFunnelMode::DEDUPLICATION:
283
0
            return _get_internal<WindowFunnelMode::DEDUPLICATION>();
284
0
        case WindowFunnelMode::FIXED:
285
0
            return _get_internal<WindowFunnelMode::FIXED>();
286
0
        case WindowFunnelMode::INCREASE:
287
0
            return _get_internal<WindowFunnelMode::INCREASE>();
288
0
        default:
289
0
            throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Invalid window_funnel mode");
290
0
            return 0;
291
22
        }
292
22
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE3getEv
293
294
11
    void merge(const WindowFunnelState<T>& other) {
295
11
        if (other.events_list.empty()) {
296
1
            return;
297
1
        }
298
10
        events_list.dt.insert(std::end(events_list.dt), std::begin(other.events_list.dt),
299
10
                              std::end(other.events_list.dt));
300
50
        for (size_t i = 0; i < event_count; i++) {
301
40
            events_list.event_columns_data[i].insert(
302
40
                    std::end(events_list.event_columns_data[i]),
303
40
                    std::begin(other.events_list.event_columns_data[i]),
304
40
                    std::end(other.events_list.event_columns_data[i]));
305
40
        }
306
10
        event_count = event_count > 0 ? event_count : other.event_count;
307
10
        window = window > 0 ? window : other.window;
308
10
        if (enable_mode) {
309
0
            window_funnel_mode = window_funnel_mode == WindowFunnelMode::INVALID
310
0
                                         ? other.window_funnel_mode
311
0
                                         : window_funnel_mode;
312
10
        } else {
313
10
            window_funnel_mode = WindowFunnelMode::DEFAULT;
314
10
        }
315
10
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE5mergeERKS2_
Line
Count
Source
294
11
    void merge(const WindowFunnelState<T>& other) {
295
11
        if (other.events_list.empty()) {
296
1
            return;
297
1
        }
298
10
        events_list.dt.insert(std::end(events_list.dt), std::begin(other.events_list.dt),
299
10
                              std::end(other.events_list.dt));
300
50
        for (size_t i = 0; i < event_count; i++) {
301
40
            events_list.event_columns_data[i].insert(
302
40
                    std::end(events_list.event_columns_data[i]),
303
40
                    std::begin(other.events_list.event_columns_data[i]),
304
40
                    std::end(other.events_list.event_columns_data[i]));
305
40
        }
306
10
        event_count = event_count > 0 ? event_count : other.event_count;
307
10
        window = window > 0 ? window : other.window;
308
10
        if (enable_mode) {
309
0
            window_funnel_mode = window_funnel_mode == WindowFunnelMode::INVALID
310
0
                                         ? other.window_funnel_mode
311
0
                                         : window_funnel_mode;
312
10
        } else {
313
10
            window_funnel_mode = WindowFunnelMode::DEFAULT;
314
10
        }
315
10
    }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE5mergeERKS2_
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE5mergeERKS2_
316
317
3
    void write(BufferWritable& out) const {
318
3
        write_var_int(event_count, out);
319
3
        write_var_int(window, out);
320
3
        if (enable_mode) {
321
1
            write_var_int(static_cast<std::underlying_type_t<WindowFunnelMode>>(window_funnel_mode),
322
1
                          out);
323
1
        }
324
3
        auto size = events_list.size();
325
3
        write_var_int(size, out);
326
5
        for (const auto& timestamp : events_list.dt) {
327
5
            write_var_int(timestamp.to_date_int_val(), out);
328
5
        }
329
12
        for (int64_t i = 0; i < event_count; i++) {
330
9
            const auto& event_columns_data = events_list.event_columns_data[i];
331
17
            for (auto event : event_columns_data) {
332
17
                write_var_int(event, out);
333
17
            }
334
9
        }
335
3
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE5writeERNS_14BufferWritableE
Line
Count
Source
317
1
    void write(BufferWritable& out) const {
318
1
        write_var_int(event_count, out);
319
1
        write_var_int(window, out);
320
1
        if (enable_mode) {
321
1
            write_var_int(static_cast<std::underlying_type_t<WindowFunnelMode>>(window_funnel_mode),
322
1
                          out);
323
1
        }
324
1
        auto size = events_list.size();
325
1
        write_var_int(size, out);
326
1
        for (const auto& timestamp : events_list.dt) {
327
1
            write_var_int(timestamp.to_date_int_val(), out);
328
1
        }
329
2
        for (int64_t i = 0; i < event_count; i++) {
330
1
            const auto& event_columns_data = events_list.event_columns_data[i];
331
1
            for (auto event : event_columns_data) {
332
1
                write_var_int(event, out);
333
1
            }
334
1
        }
335
1
    }
_ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE5writeERNS_14BufferWritableE
Line
Count
Source
317
2
    void write(BufferWritable& out) const {
318
2
        write_var_int(event_count, out);
319
2
        write_var_int(window, out);
320
2
        if (enable_mode) {
321
0
            write_var_int(static_cast<std::underlying_type_t<WindowFunnelMode>>(window_funnel_mode),
322
0
                          out);
323
0
        }
324
2
        auto size = events_list.size();
325
2
        write_var_int(size, out);
326
4
        for (const auto& timestamp : events_list.dt) {
327
4
            write_var_int(timestamp.to_date_int_val(), out);
328
4
        }
329
10
        for (int64_t i = 0; i < event_count; i++) {
330
8
            const auto& event_columns_data = events_list.event_columns_data[i];
331
16
            for (auto event : event_columns_data) {
332
16
                write_var_int(event, out);
333
16
            }
334
8
        }
335
2
    }
Unexecuted instantiation: _ZNK5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE5writeERNS_14BufferWritableE
336
337
3
    void read(BufferReadable& in) {
338
3
        int64_t event_level;
339
3
        read_var_int(event_level, in);
340
3
        event_count = (int)event_level;
341
3
        read_var_int(window, in);
342
3
        window_funnel_mode = WindowFunnelMode::DEFAULT;
343
3
        if (enable_mode) {
344
1
            int64_t mode;
345
1
            read_var_int(mode, in);
346
1
            window_funnel_mode = static_cast<WindowFunnelMode>(mode);
347
1
        }
348
3
        int64_t size = 0;
349
3
        read_var_int(size, in);
350
3
        events_list.clear();
351
3
        events_list.dt.resize(size);
352
8
        for (auto i = 0; i < size; i++) {
353
5
            Int64 timestamp = 0;
354
5
            read_var_int(timestamp, in);
355
5
            if constexpr (T == TYPE_TIMESTAMP_NS) {
356
1
                events_list.dt[i] = DateValueType(timestamp);
357
4
            } else {
358
4
                events_list.dt[i] = DateValueType(static_cast<UInt64>(timestamp));
359
4
            }
360
5
        }
361
3
        events_list.event_columns_data.resize(event_count);
362
12
        for (int64_t i = 0; i < event_count; i++) {
363
9
            auto& event_columns_data = events_list.event_columns_data[i];
364
9
            event_columns_data.resize(size);
365
26
            for (auto j = 0; j < size; j++) {
366
17
                Int64 temp_value;
367
17
                read_var_int(temp_value, in);
368
17
                event_columns_data[j] = static_cast<UInt8>(temp_value);
369
17
            }
370
9
        }
371
3
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE43EE4readERNS_14BufferReadableE
Line
Count
Source
337
1
    void read(BufferReadable& in) {
338
1
        int64_t event_level;
339
1
        read_var_int(event_level, in);
340
1
        event_count = (int)event_level;
341
1
        read_var_int(window, in);
342
1
        window_funnel_mode = WindowFunnelMode::DEFAULT;
343
1
        if (enable_mode) {
344
1
            int64_t mode;
345
1
            read_var_int(mode, in);
346
1
            window_funnel_mode = static_cast<WindowFunnelMode>(mode);
347
1
        }
348
1
        int64_t size = 0;
349
1
        read_var_int(size, in);
350
1
        events_list.clear();
351
1
        events_list.dt.resize(size);
352
2
        for (auto i = 0; i < size; i++) {
353
1
            Int64 timestamp = 0;
354
1
            read_var_int(timestamp, in);
355
1
            if constexpr (T == TYPE_TIMESTAMP_NS) {
356
1
                events_list.dt[i] = DateValueType(timestamp);
357
            } else {
358
                events_list.dt[i] = DateValueType(static_cast<UInt64>(timestamp));
359
            }
360
1
        }
361
1
        events_list.event_columns_data.resize(event_count);
362
2
        for (int64_t i = 0; i < event_count; i++) {
363
1
            auto& event_columns_data = events_list.event_columns_data[i];
364
1
            event_columns_data.resize(size);
365
2
            for (auto j = 0; j < size; j++) {
366
1
                Int64 temp_value;
367
1
                read_var_int(temp_value, in);
368
1
                event_columns_data[j] = static_cast<UInt8>(temp_value);
369
1
            }
370
1
        }
371
1
    }
_ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE26EE4readERNS_14BufferReadableE
Line
Count
Source
337
2
    void read(BufferReadable& in) {
338
2
        int64_t event_level;
339
2
        read_var_int(event_level, in);
340
2
        event_count = (int)event_level;
341
2
        read_var_int(window, in);
342
2
        window_funnel_mode = WindowFunnelMode::DEFAULT;
343
2
        if (enable_mode) {
344
0
            int64_t mode;
345
0
            read_var_int(mode, in);
346
0
            window_funnel_mode = static_cast<WindowFunnelMode>(mode);
347
0
        }
348
2
        int64_t size = 0;
349
2
        read_var_int(size, in);
350
2
        events_list.clear();
351
2
        events_list.dt.resize(size);
352
6
        for (auto i = 0; i < size; i++) {
353
4
            Int64 timestamp = 0;
354
4
            read_var_int(timestamp, in);
355
            if constexpr (T == TYPE_TIMESTAMP_NS) {
356
                events_list.dt[i] = DateValueType(timestamp);
357
4
            } else {
358
4
                events_list.dt[i] = DateValueType(static_cast<UInt64>(timestamp));
359
4
            }
360
4
        }
361
2
        events_list.event_columns_data.resize(event_count);
362
10
        for (int64_t i = 0; i < event_count; i++) {
363
8
            auto& event_columns_data = events_list.event_columns_data[i];
364
8
            event_columns_data.resize(size);
365
24
            for (auto j = 0; j < size; j++) {
366
16
                Int64 temp_value;
367
16
                read_var_int(temp_value, in);
368
16
                event_columns_data[j] = static_cast<UInt8>(temp_value);
369
16
            }
370
8
        }
371
2
    }
Unexecuted instantiation: _ZN5doris17WindowFunnelStateILNS_13PrimitiveTypeE42EE4readERNS_14BufferReadableE
372
};
373
374
template <PrimitiveType T>
375
class AggregateFunctionWindowFunnel final
376
        : public IAggregateFunctionDataHelper<WindowFunnelState<T>,
377
                                              AggregateFunctionWindowFunnel<T>>,
378
          MultiExpression,
379
          NullableAggregateFunction {
380
public:
381
    AggregateFunctionWindowFunnel(const DataTypes& argument_types_)
382
7
            : IAggregateFunctionDataHelper<WindowFunnelState<T>, AggregateFunctionWindowFunnel<T>>(
383
7
                      argument_types_) {}
_ZN5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
382
6
            : IAggregateFunctionDataHelper<WindowFunnelState<T>, AggregateFunctionWindowFunnel<T>>(
383
6
                      argument_types_) {}
_ZN5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
Line
Count
Source
382
1
            : IAggregateFunctionDataHelper<WindowFunnelState<T>, AggregateFunctionWindowFunnel<T>>(
383
1
                      argument_types_) {}
Unexecuted instantiation: _ZN5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EEC2ERKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS7_EE
384
385
34
    void create(AggregateDataPtr __restrict place) const override {
386
34
        auto data = new (place) WindowFunnelState<T>(
387
34
                cast_set<int>(IAggregateFunction::get_argument_types().size() - 3));
388
        /// support window funnel mode from 2.0. See `BeExecVersionManager::max_be_exec_version`
389
34
        data->enable_mode = IAggregateFunction::version >= 3;
390
34
    }
_ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE6createEPc
Line
Count
Source
385
34
    void create(AggregateDataPtr __restrict place) const override {
386
34
        auto data = new (place) WindowFunnelState<T>(
387
34
                cast_set<int>(IAggregateFunction::get_argument_types().size() - 3));
388
        /// support window funnel mode from 2.0. See `BeExecVersionManager::max_be_exec_version`
389
34
        data->enable_mode = IAggregateFunction::version >= 3;
390
34
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE6createEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE6createEPc
391
392
0
    String get_name() const override { return "window_funnel"; }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE8get_nameB5cxx11Ev
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE8get_nameB5cxx11Ev
393
394
0
    DataTypePtr get_return_type() const override { return std::make_shared<DataTypeInt32>(); }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE15get_return_typeEv
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE15get_return_typeEv
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE15get_return_typeEv
395
396
0
    void reset(AggregateDataPtr __restrict place) const override { this->data(place).reset(); }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE5resetEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE5resetEPc
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE5resetEPc
397
398
    void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num,
399
84
             Arena&) const override {
400
84
        const auto& window =
401
84
                assert_cast<const ColumnInt64&, TypeCheckOnRelease::DISABLE>(*columns[0])
402
84
                        .get_data()[row_num];
403
84
        StringRef mode = columns[1]->get_data_at(row_num);
404
84
        this->data(place).add(columns, row_num, window,
405
84
                              string_to_window_funnel_mode(mode.to_string()));
406
84
    }
_ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Line
Count
Source
399
84
             Arena&) const override {
400
84
        const auto& window =
401
84
                assert_cast<const ColumnInt64&, TypeCheckOnRelease::DISABLE>(*columns[0])
402
84
                        .get_data()[row_num];
403
84
        StringRef mode = columns[1]->get_data_at(row_num);
404
84
        this->data(place).add(columns, row_num, window,
405
84
                              string_to_window_funnel_mode(mode.to_string()));
406
84
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE3addEPcPPKNS_7IColumnElRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE3addEPcPPKNS_7IColumnElRNS_5ArenaE
407
408
0
    void check_input_columns_type(const IColumn** columns) const override {
409
0
        this->template check_argument_column_type<ColumnInt64>(columns[0]);
410
0
        this->template check_argument_column_type<ColumnString>(columns[1]);
411
0
        this->template check_argument_column_type<typename PrimitiveTypeTraits<T>::ColumnType>(
412
0
                columns[2]);
413
0
        for (size_t i = 3; i < this->argument_types.size(); ++i) {
414
0
            this->template check_argument_column_type<ColumnUInt8>(columns[i]);
415
0
        }
416
0
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE24check_input_columns_typeEPPKNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE24check_input_columns_typeEPPKNS_7IColumnE
417
418
    void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs,
419
11
               Arena&) const override {
420
11
        this->data(place).merge(this->data(rhs));
421
11
    }
_ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE5mergeEPcPKcRNS_5ArenaE
Line
Count
Source
419
11
               Arena&) const override {
420
11
        this->data(place).merge(this->data(rhs));
421
11
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE5mergeEPcPKcRNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE5mergeEPcPKcRNS_5ArenaE
422
423
2
    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override {
424
2
        this->data(place).write(buf);
425
2
    }
_ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE9serializeEPKcRNS_14BufferWritableE
Line
Count
Source
423
2
    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override {
424
2
        this->data(place).write(buf);
425
2
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE9serializeEPKcRNS_14BufferWritableE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE9serializeEPKcRNS_14BufferWritableE
426
427
    void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf,
428
2
                     Arena&) const override {
429
2
        this->data(place).read(buf);
430
2
    }
_ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Line
Count
Source
428
2
                     Arena&) const override {
429
2
        this->data(place).read(buf);
430
2
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE11deserializeEPcRNS_14BufferReadableERNS_5ArenaE
431
432
24
    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
433
        // place is essentially an AggregateDataPtr, passed as a ConstAggregateDataPtr.
434
24
        this->data(const_cast<AggregateDataPtr>(place)).sort();
435
24
        assert_cast<ColumnInt32&, TypeCheckOnRelease::DISABLE>(to).get_data().push_back(
436
24
                IAggregateFunctionDataHelper<WindowFunnelState<T>,
437
24
                                             AggregateFunctionWindowFunnel<T>>::data(place)
438
24
                        .get());
439
24
    }
_ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE26EE18insert_result_intoEPKcRNS_7IColumnE
Line
Count
Source
432
24
    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
433
        // place is essentially an AggregateDataPtr, passed as a ConstAggregateDataPtr.
434
24
        this->data(const_cast<AggregateDataPtr>(place)).sort();
435
24
        assert_cast<ColumnInt32&, TypeCheckOnRelease::DISABLE>(to).get_data().push_back(
436
24
                IAggregateFunctionDataHelper<WindowFunnelState<T>,
437
24
                                             AggregateFunctionWindowFunnel<T>>::data(place)
438
24
                        .get());
439
24
    }
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE43EE18insert_result_intoEPKcRNS_7IColumnE
Unexecuted instantiation: _ZNK5doris29AggregateFunctionWindowFunnelILNS_13PrimitiveTypeE42EE18insert_result_intoEPKcRNS_7IColumnE
440
441
protected:
442
    using IAggregateFunction::version;
443
};
444
} // namespace doris