Coverage Report

Created: 2025-06-03 05:12

/root/doris/be/src/util/counts.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <pdqsort.h>
21
22
#include <algorithm>
23
#include <cmath>
24
#include <queue>
25
26
#include "udf/udf.h"
27
#include "vec/common/pod_array.h"
28
#include "vec/common/string_buffer.hpp"
29
#include "vec/io/io_helper.h"
30
31
namespace doris {
32
33
template <typename Ty>
34
class Counts {
35
public:
36
5.90k
    Counts() = default;
Unexecuted instantiation: _ZN5doris6CountsIhEC2Ev
_ZN5doris6CountsIaEC2Ev
Line
Count
Source
36
34
    Counts() = default;
_ZN5doris6CountsIsEC2Ev
Line
Count
Source
36
243
    Counts() = default;
_ZN5doris6CountsIiEC2Ev
Line
Count
Source
36
4.02k
    Counts() = default;
_ZN5doris6CountsIlEC2Ev
Line
Count
Source
36
989
    Counts() = default;
_ZN5doris6CountsInEC2Ev
Line
Count
Source
36
30
    Counts() = default;
Unexecuted instantiation: _ZN5doris6CountsIfEC2Ev
_ZN5doris6CountsIdEC2Ev
Line
Count
Source
36
576
    Counts() = default;
37
38
2.39k
    void merge(Counts* other) {
39
2.39k
        if (other != nullptr && !other->_nums.empty()) {
40
2.39k
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
2.39k
        }
42
2.39k
    }
Unexecuted instantiation: _ZN5doris6CountsIhE5mergeEPS1_
Unexecuted instantiation: _ZN5doris6CountsIaE5mergeEPS1_
_ZN5doris6CountsIsE5mergeEPS1_
Line
Count
Source
38
12
    void merge(Counts* other) {
39
12
        if (other != nullptr && !other->_nums.empty()) {
40
12
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
12
        }
42
12
    }
_ZN5doris6CountsIiE5mergeEPS1_
Line
Count
Source
38
1.72k
    void merge(Counts* other) {
39
1.72k
        if (other != nullptr && !other->_nums.empty()) {
40
1.72k
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
1.72k
        }
42
1.72k
    }
_ZN5doris6CountsIlE5mergeEPS1_
Line
Count
Source
38
416
    void merge(Counts* other) {
39
416
        if (other != nullptr && !other->_nums.empty()) {
40
416
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
416
        }
42
416
    }
Unexecuted instantiation: _ZN5doris6CountsInE5mergeEPS1_
Unexecuted instantiation: _ZN5doris6CountsIfE5mergeEPS1_
_ZN5doris6CountsIdE5mergeEPS1_
Line
Count
Source
38
236
    void merge(Counts* other) {
39
236
        if (other != nullptr && !other->_nums.empty()) {
40
236
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
236
        }
42
236
    }
43
44
    void increment(Ty key, uint32_t i) {
45
        auto old_size = _nums.size();
46
        _nums.resize(_nums.size() + i);
47
        for (uint32_t j = 0; j < i; ++j) {
48
            _nums[old_size + j] = key;
49
        }
50
    }
51
52
3.16k
    void increment(Ty key) { _nums.push_back(key); }
Unexecuted instantiation: _ZN5doris6CountsIhE9incrementEh
_ZN5doris6CountsIaE9incrementEa
Line
Count
Source
52
64
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsIsE9incrementEs
Line
Count
Source
52
789
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsIiE9incrementEi
Line
Count
Source
52
1.60k
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsIlE9incrementEl
Line
Count
Source
52
412
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsInE9incrementEn
Line
Count
Source
52
36
    void increment(Ty key) { _nums.push_back(key); }
Unexecuted instantiation: _ZN5doris6CountsIfE9incrementEf
_ZN5doris6CountsIdE9incrementEd
Line
Count
Source
52
268
    void increment(Ty key) { _nums.push_back(key); }
53
54
5
    void increment_batch(const vectorized::PaddedPODArray<Ty>& keys) {
55
5
        _nums.insert(keys.begin(), keys.end());
56
5
    }
Unexecuted instantiation: _ZN5doris6CountsIhE15increment_batchERKNS_10vectorized8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIaE15increment_batchERKNS_10vectorized8PODArrayIaLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIsE15increment_batchERKNS_10vectorized8PODArrayIsLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIiE15increment_batchERKNS_10vectorized8PODArrayIiLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
_ZN5doris6CountsIlE15increment_batchERKNS_10vectorized8PODArrayIlLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
Line
Count
Source
54
5
    void increment_batch(const vectorized::PaddedPODArray<Ty>& keys) {
55
5
        _nums.insert(keys.begin(), keys.end());
56
5
    }
Unexecuted instantiation: _ZN5doris6CountsInE15increment_batchERKNS_10vectorized8PODArrayInLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIfE15increment_batchERKNS_10vectorized8PODArrayIfLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIdE15increment_batchERKNS_10vectorized8PODArrayIdLm4096ENS_9AllocatorILb0ELb0ELb0ENS_32NoTrackingDefaultMemoryAllocatorEEELm16ELm15EEE
57
58
3.80k
    void serialize(vectorized::BufferWritable& buf) {
59
3.80k
        if (!_nums.empty()) {
60
2.50k
            pdqsort(_nums.begin(), _nums.end());
61
2.50k
            size_t size = _nums.size();
62
2.50k
            write_binary(size, buf);
63
2.50k
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
2.50k
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
1.30k
            _convert_sorted_num_vec_to_nums();
67
1.30k
            serialize(buf);
68
1.30k
        }
69
3.80k
    }
Unexecuted instantiation: _ZN5doris6CountsIhE9serializeERNS_10vectorized14BufferWritableE
Unexecuted instantiation: _ZN5doris6CountsIaE9serializeERNS_10vectorized14BufferWritableE
_ZN5doris6CountsIsE9serializeERNS_10vectorized14BufferWritableE
Line
Count
Source
58
12
    void serialize(vectorized::BufferWritable& buf) {
59
12
        if (!_nums.empty()) {
60
12
            pdqsort(_nums.begin(), _nums.end());
61
12
            size_t size = _nums.size();
62
12
            write_binary(size, buf);
63
12
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
12
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
0
            _convert_sorted_num_vec_to_nums();
67
0
            serialize(buf);
68
0
        }
69
12
    }
_ZN5doris6CountsIiE9serializeERNS_10vectorized14BufferWritableE
Line
Count
Source
58
2.77k
    void serialize(vectorized::BufferWritable& buf) {
59
2.77k
        if (!_nums.empty()) {
60
1.80k
            pdqsort(_nums.begin(), _nums.end());
61
1.80k
            size_t size = _nums.size();
62
1.80k
            write_binary(size, buf);
63
1.80k
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
1.80k
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
972
            _convert_sorted_num_vec_to_nums();
67
972
            serialize(buf);
68
972
        }
69
2.77k
    }
_ZN5doris6CountsIlE9serializeERNS_10vectorized14BufferWritableE
Line
Count
Source
58
647
    void serialize(vectorized::BufferWritable& buf) {
59
647
        if (!_nums.empty()) {
60
448
            pdqsort(_nums.begin(), _nums.end());
61
448
            size_t size = _nums.size();
62
448
            write_binary(size, buf);
63
448
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
448
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
199
            _convert_sorted_num_vec_to_nums();
67
199
            serialize(buf);
68
199
        }
69
647
    }
Unexecuted instantiation: _ZN5doris6CountsInE9serializeERNS_10vectorized14BufferWritableE
Unexecuted instantiation: _ZN5doris6CountsIfE9serializeERNS_10vectorized14BufferWritableE
_ZN5doris6CountsIdE9serializeERNS_10vectorized14BufferWritableE
Line
Count
Source
58
368
    void serialize(vectorized::BufferWritable& buf) {
59
368
        if (!_nums.empty()) {
60
236
            pdqsort(_nums.begin(), _nums.end());
61
236
            size_t size = _nums.size();
62
236
            write_binary(size, buf);
63
236
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
236
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
132
            _convert_sorted_num_vec_to_nums();
67
132
            serialize(buf);
68
132
        }
69
368
    }
70
71
2.39k
    void unserialize(vectorized::BufferReadable& buf) {
72
2.39k
        size_t size;
73
2.39k
        read_binary(size, buf);
74
2.39k
        _nums.resize(size);
75
2.39k
        auto buff = buf.read(sizeof(Ty) * size);
76
2.39k
        memcpy(_nums.data(), buff.data, buff.size);
77
2.39k
    }
Unexecuted instantiation: _ZN5doris6CountsIhE11unserializeERNS_10vectorized14BufferReadableE
Unexecuted instantiation: _ZN5doris6CountsIaE11unserializeERNS_10vectorized14BufferReadableE
_ZN5doris6CountsIsE11unserializeERNS_10vectorized14BufferReadableE
Line
Count
Source
71
12
    void unserialize(vectorized::BufferReadable& buf) {
72
12
        size_t size;
73
12
        read_binary(size, buf);
74
12
        _nums.resize(size);
75
12
        auto buff = buf.read(sizeof(Ty) * size);
76
12
        memcpy(_nums.data(), buff.data, buff.size);
77
12
    }
_ZN5doris6CountsIiE11unserializeERNS_10vectorized14BufferReadableE
Line
Count
Source
71
1.72k
    void unserialize(vectorized::BufferReadable& buf) {
72
1.72k
        size_t size;
73
1.72k
        read_binary(size, buf);
74
1.72k
        _nums.resize(size);
75
1.72k
        auto buff = buf.read(sizeof(Ty) * size);
76
1.72k
        memcpy(_nums.data(), buff.data, buff.size);
77
1.72k
    }
_ZN5doris6CountsIlE11unserializeERNS_10vectorized14BufferReadableE
Line
Count
Source
71
416
    void unserialize(vectorized::BufferReadable& buf) {
72
416
        size_t size;
73
416
        read_binary(size, buf);
74
416
        _nums.resize(size);
75
416
        auto buff = buf.read(sizeof(Ty) * size);
76
416
        memcpy(_nums.data(), buff.data, buff.size);
77
416
    }
Unexecuted instantiation: _ZN5doris6CountsInE11unserializeERNS_10vectorized14BufferReadableE
Unexecuted instantiation: _ZN5doris6CountsIfE11unserializeERNS_10vectorized14BufferReadableE
_ZN5doris6CountsIdE11unserializeERNS_10vectorized14BufferReadableE
Line
Count
Source
71
236
    void unserialize(vectorized::BufferReadable& buf) {
72
236
        size_t size;
73
236
        read_binary(size, buf);
74
236
        _nums.resize(size);
75
236
        auto buff = buf.read(sizeof(Ty) * size);
76
236
        memcpy(_nums.data(), buff.data, buff.size);
77
236
    }
78
79
1.14k
    double terminate(double quantile) {
80
1.14k
        if (_sorted_nums_vec.size() <= 1) {
81
1.01k
            if (_sorted_nums_vec.size() == 1) {
82
380
                _nums = std::move(_sorted_nums_vec[0]);
83
380
            }
84
85
1.01k
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
1.01k
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
201
                pdqsort(_nums.begin(), _nums.end());
93
201
            }
94
95
1.01k
            if (quantile == 1 || _nums.size() == 1) {
96
500
                return _nums.back();
97
500
            }
98
99
510
            double u = (_nums.size() - 1) * quantile;
100
510
            auto index = static_cast<uint32_t>(u);
101
510
            return _nums[index] +
102
510
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
1.01k
        } else {
104
135
            DCHECK(_nums.empty());
105
135
            size_t rows = 0;
106
401
            for (const auto& i : _sorted_nums_vec) {
107
401
                rows += i.size();
108
401
            }
109
135
            const bool reverse = quantile > 0.5 && rows > 2;
110
135
            double u = (rows - 1) * quantile;
111
135
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
135
            size_t target = reverse ? rows - index - 2 : index;
120
135
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
135
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
135
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
135
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
135
        }
129
1.14k
    }
Unexecuted instantiation: _ZN5doris6CountsIhE9terminateEd
_ZN5doris6CountsIaE9terminateEd
Line
Count
Source
79
58
    double terminate(double quantile) {
80
58
        if (_sorted_nums_vec.size() <= 1) {
81
58
            if (_sorted_nums_vec.size() == 1) {
82
0
                _nums = std::move(_sorted_nums_vec[0]);
83
0
            }
84
85
58
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
58
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
24
                pdqsort(_nums.begin(), _nums.end());
93
24
            }
94
95
58
            if (quantile == 1 || _nums.size() == 1) {
96
34
                return _nums.back();
97
34
            }
98
99
24
            double u = (_nums.size() - 1) * quantile;
100
24
            auto index = static_cast<uint32_t>(u);
101
24
            return _nums[index] +
102
24
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
58
        } else {
104
0
            DCHECK(_nums.empty());
105
0
            size_t rows = 0;
106
0
            for (const auto& i : _sorted_nums_vec) {
107
0
                rows += i.size();
108
0
            }
109
0
            const bool reverse = quantile > 0.5 && rows > 2;
110
0
            double u = (rows - 1) * quantile;
111
0
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
0
            size_t target = reverse ? rows - index - 2 : index;
120
0
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
0
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
0
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
0
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
0
        }
129
58
    }
_ZN5doris6CountsIsE9terminateEd
Line
Count
Source
79
296
    double terminate(double quantile) {
80
296
        if (_sorted_nums_vec.size() <= 1) {
81
293
            if (_sorted_nums_vec.size() == 1) {
82
0
                _nums = std::move(_sorted_nums_vec[0]);
83
0
            }
84
85
293
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
293
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
165
                pdqsort(_nums.begin(), _nums.end());
93
165
            }
94
95
293
            if (quantile == 1 || _nums.size() == 1) {
96
86
                return _nums.back();
97
86
            }
98
99
207
            double u = (_nums.size() - 1) * quantile;
100
207
            auto index = static_cast<uint32_t>(u);
101
207
            return _nums[index] +
102
207
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
293
        } else {
104
3
            DCHECK(_nums.empty());
105
3
            size_t rows = 0;
106
12
            for (const auto& i : _sorted_nums_vec) {
107
12
                rows += i.size();
108
12
            }
109
3
            const bool reverse = quantile > 0.5 && rows > 2;
110
3
            double u = (rows - 1) * quantile;
111
3
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
3
            size_t target = reverse ? rows - index - 2 : index;
120
3
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
3
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
3
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
3
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
3
        }
129
296
    }
_ZN5doris6CountsIiE9terminateEd
Line
Count
Source
79
495
    double terminate(double quantile) {
80
495
        if (_sorted_nums_vec.size() <= 1) {
81
398
            if (_sorted_nums_vec.size() == 1) {
82
304
                _nums = std::move(_sorted_nums_vec[0]);
83
304
            }
84
85
398
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
398
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
11
                pdqsort(_nums.begin(), _nums.end());
93
11
            }
94
95
398
            if (quantile == 1 || _nums.size() == 1) {
96
254
                return _nums.back();
97
254
            }
98
99
144
            double u = (_nums.size() - 1) * quantile;
100
144
            auto index = static_cast<uint32_t>(u);
101
144
            return _nums[index] +
102
144
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
398
        } else {
104
97
            DCHECK(_nums.empty());
105
97
            size_t rows = 0;
106
267
            for (const auto& i : _sorted_nums_vec) {
107
267
                rows += i.size();
108
267
            }
109
97
            const bool reverse = quantile > 0.5 && rows > 2;
110
97
            double u = (rows - 1) * quantile;
111
97
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
97
            size_t target = reverse ? rows - index - 2 : index;
120
97
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
97
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
97
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
97
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
97
        }
129
495
    }
_ZN5doris6CountsIlE9terminateEd
Line
Count
Source
79
118
    double terminate(double quantile) {
80
118
        if (_sorted_nums_vec.size() <= 1) {
81
95
            if (_sorted_nums_vec.size() == 1) {
82
38
                _nums = std::move(_sorted_nums_vec[0]);
83
38
            }
84
85
95
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
95
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
1
                pdqsort(_nums.begin(), _nums.end());
93
1
            }
94
95
95
            if (quantile == 1 || _nums.size() == 1) {
96
60
                return _nums.back();
97
60
            }
98
99
35
            double u = (_nums.size() - 1) * quantile;
100
35
            auto index = static_cast<uint32_t>(u);
101
35
            return _nums[index] +
102
35
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
95
        } else {
104
23
            DCHECK(_nums.empty());
105
23
            size_t rows = 0;
106
86
            for (const auto& i : _sorted_nums_vec) {
107
86
                rows += i.size();
108
86
            }
109
23
            const bool reverse = quantile > 0.5 && rows > 2;
110
23
            double u = (rows - 1) * quantile;
111
23
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
23
            size_t target = reverse ? rows - index - 2 : index;
120
23
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
23
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
23
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
23
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
23
        }
129
118
    }
_ZN5doris6CountsInE9terminateEd
Line
Count
Source
79
30
    double terminate(double quantile) {
80
30
        if (_sorted_nums_vec.size() <= 1) {
81
30
            if (_sorted_nums_vec.size() == 1) {
82
0
                _nums = std::move(_sorted_nums_vec[0]);
83
0
            }
84
85
30
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
30
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
0
                pdqsort(_nums.begin(), _nums.end());
93
0
            }
94
95
30
            if (quantile == 1 || _nums.size() == 1) {
96
24
                return _nums.back();
97
24
            }
98
99
6
            double u = (_nums.size() - 1) * quantile;
100
6
            auto index = static_cast<uint32_t>(u);
101
6
            return _nums[index] +
102
6
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
30
        } else {
104
0
            DCHECK(_nums.empty());
105
0
            size_t rows = 0;
106
0
            for (const auto& i : _sorted_nums_vec) {
107
0
                rows += i.size();
108
0
            }
109
0
            const bool reverse = quantile > 0.5 && rows > 2;
110
0
            double u = (rows - 1) * quantile;
111
0
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
0
            size_t target = reverse ? rows - index - 2 : index;
120
0
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
0
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
0
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
0
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
0
        }
129
30
    }
Unexecuted instantiation: _ZN5doris6CountsIfE9terminateEd
_ZN5doris6CountsIdE9terminateEd
Line
Count
Source
79
148
    double terminate(double quantile) {
80
148
        if (_sorted_nums_vec.size() <= 1) {
81
136
            if (_sorted_nums_vec.size() == 1) {
82
38
                _nums = std::move(_sorted_nums_vec[0]);
83
38
            }
84
85
136
            if (_nums.empty()) {
86
                // Although set null here, but the value is 0.0 and the call method just
87
                // get val in aggregate_function_percentile_approx.h
88
0
                return 0.0;
89
0
            }
90
91
136
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
0
                pdqsort(_nums.begin(), _nums.end());
93
0
            }
94
95
136
            if (quantile == 1 || _nums.size() == 1) {
96
42
                return _nums.back();
97
42
            }
98
99
94
            double u = (_nums.size() - 1) * quantile;
100
94
            auto index = static_cast<uint32_t>(u);
101
94
            return _nums[index] +
102
94
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
136
        } else {
104
12
            DCHECK(_nums.empty());
105
12
            size_t rows = 0;
106
36
            for (const auto& i : _sorted_nums_vec) {
107
36
                rows += i.size();
108
36
            }
109
12
            const bool reverse = quantile > 0.5 && rows > 2;
110
12
            double u = (rows - 1) * quantile;
111
12
            auto index = static_cast<uint32_t>(u);
112
            // if reverse, the step of target should start 0 like not reverse
113
            // so here rows need to minus index + 2
114
            // eg: rows = 10, index = 5
115
            // if not reverse, so the first number loc is 5, the second number loc is 6
116
            // if reverse, so the second number is 3, the first number is 4
117
            // 5 + 4 = 3 + 6 = 9 = rows - 1.
118
            // the rows must GE 2 beacuse `_sorted_nums_vec` size GE 2
119
12
            size_t target = reverse ? rows - index - 2 : index;
120
12
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
12
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
12
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
12
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
12
        }
129
148
    }
130
131
private:
132
    struct Node {
133
        Ty value;
134
        int array_index;
135
        int64_t element_index;
136
137
1.51k
        auto operator<=>(const Node& other) const { return value <=> other.value; }
Unexecuted instantiation: _ZNK5doris6CountsIhE4NodessERKS2_
Unexecuted instantiation: _ZNK5doris6CountsIaE4NodessERKS2_
_ZNK5doris6CountsIsE4NodessERKS2_
Line
Count
Source
137
68
        auto operator<=>(const Node& other) const { return value <=> other.value; }
_ZNK5doris6CountsIiE4NodessERKS2_
Line
Count
Source
137
936
        auto operator<=>(const Node& other) const { return value <=> other.value; }
_ZNK5doris6CountsIlE4NodessERKS2_
Line
Count
Source
137
434
        auto operator<=>(const Node& other) const { return value <=> other.value; }
Unexecuted instantiation: _ZNK5doris6CountsInE4NodessERKS2_
Unexecuted instantiation: _ZNK5doris6CountsIfE4NodessERKS2_
_ZNK5doris6CountsIdE4NodessERKS2_
Line
Count
Source
137
78
        auto operator<=>(const Node& other) const { return value <=> other.value; }
138
    };
139
140
1.30k
    void _convert_sorted_num_vec_to_nums() {
141
1.30k
        size_t rows = 0;
142
1.60k
        for (const auto& i : _sorted_nums_vec) {
143
1.60k
            rows += i.size();
144
1.60k
        }
145
1.30k
        _nums.resize(rows);
146
1.30k
        size_t count = 0;
147
148
1.30k
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
2.91k
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
1.60k
            if (!_sorted_nums_vec[i].empty()) {
151
1.60k
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
1.60k
            }
153
1.60k
        }
154
155
3.74k
        while (!min_heap.empty()) {
156
2.43k
            Node node = min_heap.top();
157
2.43k
            min_heap.pop();
158
2.43k
            _nums[count++] = node.value;
159
2.43k
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
829
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
829
                min_heap.push(node);
162
829
            }
163
2.43k
        }
164
1.30k
        _sorted_nums_vec.clear();
165
1.30k
    }
Unexecuted instantiation: _ZN5doris6CountsIhE31_convert_sorted_num_vec_to_numsEv
Unexecuted instantiation: _ZN5doris6CountsIaE31_convert_sorted_num_vec_to_numsEv
Unexecuted instantiation: _ZN5doris6CountsIsE31_convert_sorted_num_vec_to_numsEv
_ZN5doris6CountsIiE31_convert_sorted_num_vec_to_numsEv
Line
Count
Source
140
972
    void _convert_sorted_num_vec_to_nums() {
141
972
        size_t rows = 0;
142
1.15k
        for (const auto& i : _sorted_nums_vec) {
143
1.15k
            rows += i.size();
144
1.15k
        }
145
972
        _nums.resize(rows);
146
972
        size_t count = 0;
147
148
972
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
2.12k
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
1.15k
            if (!_sorted_nums_vec[i].empty()) {
151
1.15k
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
1.15k
            }
153
1.15k
        }
154
155
2.87k
        while (!min_heap.empty()) {
156
1.90k
            Node node = min_heap.top();
157
1.90k
            min_heap.pop();
158
1.90k
            _nums[count++] = node.value;
159
1.90k
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
749
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
749
                min_heap.push(node);
162
749
            }
163
1.90k
        }
164
972
        _sorted_nums_vec.clear();
165
972
    }
_ZN5doris6CountsIlE31_convert_sorted_num_vec_to_numsEv
Line
Count
Source
140
199
    void _convert_sorted_num_vec_to_nums() {
141
199
        size_t rows = 0;
142
292
        for (const auto& i : _sorted_nums_vec) {
143
292
            rows += i.size();
144
292
        }
145
199
        _nums.resize(rows);
146
199
        size_t count = 0;
147
148
199
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
491
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
292
            if (!_sorted_nums_vec[i].empty()) {
151
292
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
292
            }
153
292
        }
154
155
541
        while (!min_heap.empty()) {
156
342
            Node node = min_heap.top();
157
342
            min_heap.pop();
158
342
            _nums[count++] = node.value;
159
342
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
50
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
50
                min_heap.push(node);
162
50
            }
163
342
        }
164
199
        _sorted_nums_vec.clear();
165
199
    }
Unexecuted instantiation: _ZN5doris6CountsInE31_convert_sorted_num_vec_to_numsEv
Unexecuted instantiation: _ZN5doris6CountsIfE31_convert_sorted_num_vec_to_numsEv
_ZN5doris6CountsIdE31_convert_sorted_num_vec_to_numsEv
Line
Count
Source
140
132
    void _convert_sorted_num_vec_to_nums() {
141
132
        size_t rows = 0;
142
162
        for (const auto& i : _sorted_nums_vec) {
143
162
            rows += i.size();
144
162
        }
145
132
        _nums.resize(rows);
146
132
        size_t count = 0;
147
148
132
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
294
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
162
            if (!_sorted_nums_vec[i].empty()) {
151
162
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
162
            }
153
162
        }
154
155
324
        while (!min_heap.empty()) {
156
192
            Node node = min_heap.top();
157
192
            min_heap.pop();
158
192
            _nums[count++] = node.value;
159
192
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
30
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
30
                min_heap.push(node);
162
30
            }
163
192
        }
164
132
        _sorted_nums_vec.clear();
165
132
    }
166
167
135
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
135
        Ty first_number = 0, second_number = 0;
169
135
        size_t count = 0;
170
135
        if (reverse) {
171
31
            std::priority_queue<Node> max_heap;
172
143
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
112
                if (!_sorted_nums_vec[i].empty()) {
174
112
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
112
                                     _sorted_nums_vec[i].size() - 1);
176
112
                }
177
112
            }
178
179
130
            while (!max_heap.empty()) {
180
130
                Node node = max_heap.top();
181
130
                max_heap.pop();
182
130
                if (count == target) {
183
31
                    second_number = node.value;
184
99
                } else if (count == target + 1) {
185
31
                    first_number = node.value;
186
31
                    break;
187
31
                }
188
99
                ++count;
189
99
                if (--node.element_index >= 0) {
190
72
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
72
                    max_heap.push(node);
192
72
                }
193
99
            }
194
195
104
        } else {
196
104
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
393
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
289
                if (!_sorted_nums_vec[i].empty()) {
199
289
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
289
                }
201
289
            }
202
203
301
            while (!min_heap.empty()) {
204
301
                Node node = min_heap.top();
205
301
                min_heap.pop();
206
301
                if (count == target) {
207
104
                    first_number = node.value;
208
197
                } else if (count == target + 1) {
209
104
                    second_number = node.value;
210
104
                    break;
211
104
                }
212
197
                ++count;
213
197
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
122
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
122
                    min_heap.push(node);
216
122
                }
217
197
            }
218
104
        }
219
220
135
        return {first_number, second_number};
221
135
    }
Unexecuted instantiation: _ZN5doris6CountsIhE27_merge_sort_and_get_numbersElb
Unexecuted instantiation: _ZN5doris6CountsIaE27_merge_sort_and_get_numbersElb
_ZN5doris6CountsIsE27_merge_sort_and_get_numbersElb
Line
Count
Source
167
3
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
3
        Ty first_number = 0, second_number = 0;
169
3
        size_t count = 0;
170
3
        if (reverse) {
171
1
            std::priority_queue<Node> max_heap;
172
5
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
4
                if (!_sorted_nums_vec[i].empty()) {
174
4
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
4
                                     _sorted_nums_vec[i].size() - 1);
176
4
                }
177
4
            }
178
179
6
            while (!max_heap.empty()) {
180
6
                Node node = max_heap.top();
181
6
                max_heap.pop();
182
6
                if (count == target) {
183
1
                    second_number = node.value;
184
5
                } else if (count == target + 1) {
185
1
                    first_number = node.value;
186
1
                    break;
187
1
                }
188
5
                ++count;
189
5
                if (--node.element_index >= 0) {
190
3
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
3
                    max_heap.push(node);
192
3
                }
193
5
            }
194
195
2
        } else {
196
2
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
10
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
8
                if (!_sorted_nums_vec[i].empty()) {
199
8
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
8
                }
201
8
            }
202
203
13
            while (!min_heap.empty()) {
204
13
                Node node = min_heap.top();
205
13
                min_heap.pop();
206
13
                if (count == target) {
207
2
                    first_number = node.value;
208
11
                } else if (count == target + 1) {
209
2
                    second_number = node.value;
210
2
                    break;
211
2
                }
212
11
                ++count;
213
11
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
11
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
11
                    min_heap.push(node);
216
11
                }
217
11
            }
218
2
        }
219
220
3
        return {first_number, second_number};
221
3
    }
_ZN5doris6CountsIiE27_merge_sort_and_get_numbersElb
Line
Count
Source
167
97
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
97
        Ty first_number = 0, second_number = 0;
169
97
        size_t count = 0;
170
97
        if (reverse) {
171
10
            std::priority_queue<Node> max_heap;
172
38
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
28
                if (!_sorted_nums_vec[i].empty()) {
174
28
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
28
                                     _sorted_nums_vec[i].size() - 1);
176
28
                }
177
28
            }
178
179
39
            while (!max_heap.empty()) {
180
39
                Node node = max_heap.top();
181
39
                max_heap.pop();
182
39
                if (count == target) {
183
10
                    second_number = node.value;
184
29
                } else if (count == target + 1) {
185
10
                    first_number = node.value;
186
10
                    break;
187
10
                }
188
29
                ++count;
189
29
                if (--node.element_index >= 0) {
190
22
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
22
                    max_heap.push(node);
192
22
                }
193
29
            }
194
195
87
        } else {
196
87
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
326
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
239
                if (!_sorted_nums_vec[i].empty()) {
199
239
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
239
                }
201
239
            }
202
203
244
            while (!min_heap.empty()) {
204
244
                Node node = min_heap.top();
205
244
                min_heap.pop();
206
244
                if (count == target) {
207
87
                    first_number = node.value;
208
157
                } else if (count == target + 1) {
209
87
                    second_number = node.value;
210
87
                    break;
211
87
                }
212
157
                ++count;
213
157
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
99
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
99
                    min_heap.push(node);
216
99
                }
217
157
            }
218
87
        }
219
220
97
        return {first_number, second_number};
221
97
    }
_ZN5doris6CountsIlE27_merge_sort_and_get_numbersElb
Line
Count
Source
167
23
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
23
        Ty first_number = 0, second_number = 0;
169
23
        size_t count = 0;
170
23
        if (reverse) {
171
18
            std::priority_queue<Node> max_heap;
172
92
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
74
                if (!_sorted_nums_vec[i].empty()) {
174
74
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
74
                                     _sorted_nums_vec[i].size() - 1);
176
74
                }
177
74
            }
178
179
80
            while (!max_heap.empty()) {
180
80
                Node node = max_heap.top();
181
80
                max_heap.pop();
182
80
                if (count == target) {
183
18
                    second_number = node.value;
184
62
                } else if (count == target + 1) {
185
18
                    first_number = node.value;
186
18
                    break;
187
18
                }
188
62
                ++count;
189
62
                if (--node.element_index >= 0) {
190
47
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
47
                    max_heap.push(node);
192
47
                }
193
62
            }
194
195
18
        } else {
196
5
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
17
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
12
                if (!_sorted_nums_vec[i].empty()) {
199
12
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
12
                }
201
12
            }
202
203
16
            while (!min_heap.empty()) {
204
16
                Node node = min_heap.top();
205
16
                min_heap.pop();
206
16
                if (count == target) {
207
5
                    first_number = node.value;
208
11
                } else if (count == target + 1) {
209
5
                    second_number = node.value;
210
5
                    break;
211
5
                }
212
11
                ++count;
213
11
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
10
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
10
                    min_heap.push(node);
216
10
                }
217
11
            }
218
5
        }
219
220
23
        return {first_number, second_number};
221
23
    }
Unexecuted instantiation: _ZN5doris6CountsInE27_merge_sort_and_get_numbersElb
Unexecuted instantiation: _ZN5doris6CountsIfE27_merge_sort_and_get_numbersElb
_ZN5doris6CountsIdE27_merge_sort_and_get_numbersElb
Line
Count
Source
167
12
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
12
        Ty first_number = 0, second_number = 0;
169
12
        size_t count = 0;
170
12
        if (reverse) {
171
2
            std::priority_queue<Node> max_heap;
172
8
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
6
                if (!_sorted_nums_vec[i].empty()) {
174
6
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
6
                                     _sorted_nums_vec[i].size() - 1);
176
6
                }
177
6
            }
178
179
5
            while (!max_heap.empty()) {
180
5
                Node node = max_heap.top();
181
5
                max_heap.pop();
182
5
                if (count == target) {
183
2
                    second_number = node.value;
184
3
                } else if (count == target + 1) {
185
2
                    first_number = node.value;
186
2
                    break;
187
2
                }
188
3
                ++count;
189
3
                if (--node.element_index >= 0) {
190
0
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
0
                    max_heap.push(node);
192
0
                }
193
3
            }
194
195
10
        } else {
196
10
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
40
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
30
                if (!_sorted_nums_vec[i].empty()) {
199
30
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
30
                }
201
30
            }
202
203
28
            while (!min_heap.empty()) {
204
28
                Node node = min_heap.top();
205
28
                min_heap.pop();
206
28
                if (count == target) {
207
10
                    first_number = node.value;
208
18
                } else if (count == target + 1) {
209
10
                    second_number = node.value;
210
10
                    break;
211
10
                }
212
18
                ++count;
213
18
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
2
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
2
                    min_heap.push(node);
216
2
                }
217
18
            }
218
10
        }
219
220
12
        return {first_number, second_number};
221
12
    }
222
223
    vectorized::PODArray<Ty> _nums;
224
    std::vector<vectorized::PODArray<Ty>> _sorted_nums_vec;
225
};
226
227
} // namespace doris