Coverage Report

Created: 2025-07-25 13:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/util/counts.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
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
9.64k
    Counts() = default;
Unexecuted instantiation: _ZN5doris6CountsIhEC2Ev
_ZN5doris6CountsIaEC2Ev
Line
Count
Source
36
68
    Counts() = default;
_ZN5doris6CountsIsEC2Ev
Line
Count
Source
36
384
    Counts() = default;
_ZN5doris6CountsIiEC2Ev
Line
Count
Source
36
6.34k
    Counts() = default;
_ZN5doris6CountsIlEC2Ev
Line
Count
Source
36
1.87k
    Counts() = default;
_ZN5doris6CountsInEC2Ev
Line
Count
Source
36
60
    Counts() = default;
Unexecuted instantiation: _ZN5doris6CountsIfEC2Ev
_ZN5doris6CountsIdEC2Ev
Line
Count
Source
36
918
    Counts() = default;
37
38
3.78k
    void merge(Counts* other) {
39
3.78k
        if (other != nullptr && !other->_nums.empty()) {
40
3.78k
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
3.78k
        }
42
3.78k
    }
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
2.61k
    void merge(Counts* other) {
39
2.61k
        if (other != nullptr && !other->_nums.empty()) {
40
2.61k
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
2.61k
        }
42
2.61k
    }
_ZN5doris6CountsIlE5mergeEPS1_
Line
Count
Source
38
778
    void merge(Counts* other) {
39
778
        if (other != nullptr && !other->_nums.empty()) {
40
778
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
778
        }
42
778
    }
Unexecuted instantiation: _ZN5doris6CountsInE5mergeEPS1_
Unexecuted instantiation: _ZN5doris6CountsIfE5mergeEPS1_
_ZN5doris6CountsIdE5mergeEPS1_
Line
Count
Source
38
376
    void merge(Counts* other) {
39
376
        if (other != nullptr && !other->_nums.empty()) {
40
376
            _sorted_nums_vec.emplace_back(std::move(other->_nums));
41
376
        }
42
376
    }
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
5.77k
    void increment(Ty key) { _nums.push_back(key); }
Unexecuted instantiation: _ZN5doris6CountsIhE9incrementEh
_ZN5doris6CountsIaE9incrementEa
Line
Count
Source
52
128
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsIsE9incrementEs
Line
Count
Source
52
1.08k
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsIiE9incrementEi
Line
Count
Source
52
3.16k
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsIlE9incrementEl
Line
Count
Source
52
824
    void increment(Ty key) { _nums.push_back(key); }
_ZN5doris6CountsInE9incrementEn
Line
Count
Source
52
70
    void increment(Ty key) { _nums.push_back(key); }
Unexecuted instantiation: _ZN5doris6CountsIfE9incrementEf
_ZN5doris6CountsIdE9incrementEd
Line
Count
Source
52
500
    void increment(Ty key) { _nums.push_back(key); }
53
54
10
    void increment_batch(const vectorized::PaddedPODArray<Ty>& keys) {
55
10
        _nums.insert(keys.begin(), keys.end());
56
10
    }
Unexecuted instantiation: _ZN5doris6CountsIhE15increment_batchERKNS_10vectorized8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIaE15increment_batchERKNS_10vectorized8PODArrayIaLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIsE15increment_batchERKNS_10vectorized8PODArrayIsLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIiE15increment_batchERKNS_10vectorized8PODArrayIiLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
_ZN5doris6CountsIlE15increment_batchERKNS_10vectorized8PODArrayIlLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
Line
Count
Source
54
10
    void increment_batch(const vectorized::PaddedPODArray<Ty>& keys) {
55
10
        _nums.insert(keys.begin(), keys.end());
56
10
    }
Unexecuted instantiation: _ZN5doris6CountsInE15increment_batchERKNS_10vectorized8PODArrayInLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIfE15increment_batchERKNS_10vectorized8PODArrayIfLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
Unexecuted instantiation: _ZN5doris6CountsIdE15increment_batchERKNS_10vectorized8PODArrayIdLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb0EEELm16ELm15EEE
57
58
5.73k
    void serialize(vectorized::BufferWritable& buf) {
59
5.73k
        if (!_nums.empty()) {
60
4.00k
            pdqsort(_nums.begin(), _nums.end());
61
4.00k
            size_t size = _nums.size();
62
4.00k
            buf.write_binary(size);
63
4.00k
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
4.00k
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
1.73k
            _convert_sorted_num_vec_to_nums();
67
1.73k
            serialize(buf);
68
1.73k
        }
69
5.73k
    }
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
            buf.write_binary(size);
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
3.95k
    void serialize(vectorized::BufferWritable& buf) {
59
3.95k
        if (!_nums.empty()) {
60
2.77k
            pdqsort(_nums.begin(), _nums.end());
61
2.77k
            size_t size = _nums.size();
62
2.77k
            buf.write_binary(size);
63
2.77k
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
2.77k
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
1.18k
            _convert_sorted_num_vec_to_nums();
67
1.18k
            serialize(buf);
68
1.18k
        }
69
3.95k
    }
_ZN5doris6CountsIlE9serializeERNS_10vectorized14BufferWritableE
Line
Count
Source
58
1.21k
    void serialize(vectorized::BufferWritable& buf) {
59
1.21k
        if (!_nums.empty()) {
60
842
            pdqsort(_nums.begin(), _nums.end());
61
842
            size_t size = _nums.size();
62
842
            buf.write_binary(size);
63
842
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
842
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
370
            _convert_sorted_num_vec_to_nums();
67
370
            serialize(buf);
68
370
        }
69
1.21k
    }
Unexecuted instantiation: _ZN5doris6CountsInE9serializeERNS_10vectorized14BufferWritableE
Unexecuted instantiation: _ZN5doris6CountsIfE9serializeERNS_10vectorized14BufferWritableE
_ZN5doris6CountsIdE9serializeERNS_10vectorized14BufferWritableE
Line
Count
Source
58
556
    void serialize(vectorized::BufferWritable& buf) {
59
556
        if (!_nums.empty()) {
60
376
            pdqsort(_nums.begin(), _nums.end());
61
376
            size_t size = _nums.size();
62
376
            buf.write_binary(size);
63
376
            buf.write(reinterpret_cast<const char*>(_nums.data()), sizeof(Ty) * size);
64
376
        } else {
65
            // convert _sorted_nums_vec to _nums and do seiralize again
66
180
            _convert_sorted_num_vec_to_nums();
67
180
            serialize(buf);
68
180
        }
69
556
    }
70
71
3.78k
    void unserialize(vectorized::BufferReadable& buf) {
72
3.78k
        size_t size;
73
3.78k
        buf.read_binary(size);
74
3.78k
        _nums.resize(size);
75
3.78k
        auto buff = buf.read(sizeof(Ty) * size);
76
3.78k
        memcpy(_nums.data(), buff.data, buff.size);
77
3.78k
    }
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
        buf.read_binary(size);
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
2.61k
    void unserialize(vectorized::BufferReadable& buf) {
72
2.61k
        size_t size;
73
2.61k
        buf.read_binary(size);
74
2.61k
        _nums.resize(size);
75
2.61k
        auto buff = buf.read(sizeof(Ty) * size);
76
2.61k
        memcpy(_nums.data(), buff.data, buff.size);
77
2.61k
    }
_ZN5doris6CountsIlE11unserializeERNS_10vectorized14BufferReadableE
Line
Count
Source
71
778
    void unserialize(vectorized::BufferReadable& buf) {
72
778
        size_t size;
73
778
        buf.read_binary(size);
74
778
        _nums.resize(size);
75
778
        auto buff = buf.read(sizeof(Ty) * size);
76
778
        memcpy(_nums.data(), buff.data, buff.size);
77
778
    }
Unexecuted instantiation: _ZN5doris6CountsInE11unserializeERNS_10vectorized14BufferReadableE
Unexecuted instantiation: _ZN5doris6CountsIfE11unserializeERNS_10vectorized14BufferReadableE
_ZN5doris6CountsIdE11unserializeERNS_10vectorized14BufferReadableE
Line
Count
Source
71
376
    void unserialize(vectorized::BufferReadable& buf) {
72
376
        size_t size;
73
376
        buf.read_binary(size);
74
376
        _nums.resize(size);
75
376
        auto buff = buf.read(sizeof(Ty) * size);
76
376
        memcpy(_nums.data(), buff.data, buff.size);
77
376
    }
78
79
2.23k
    double terminate(double quantile) {
80
2.23k
        if (_sorted_nums_vec.size() <= 1) {
81
1.94k
            if (_sorted_nums_vec.size() == 1) {
82
640
                _nums = std::move(_sorted_nums_vec[0]);
83
640
            }
84
85
1.94k
            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.94k
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
360
                pdqsort(_nums.begin(), _nums.end());
93
360
            }
94
95
1.94k
            if (quantile == 1 || _nums.size() == 1) {
96
952
                return _nums.back();
97
952
            }
98
99
994
            double u = (_nums.size() - 1) * quantile;
100
994
            auto index = static_cast<uint32_t>(u);
101
994
            return _nums[index] +
102
994
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
1.94k
        } else {
104
286
            DCHECK(_nums.empty());
105
286
            size_t rows = 0;
106
822
            for (const auto& i : _sorted_nums_vec) {
107
822
                rows += i.size();
108
822
            }
109
286
            const bool reverse = quantile > 0.5 && rows > 2;
110
286
            double u = (rows - 1) * quantile;
111
286
            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
286
            size_t target = reverse ? rows - index - 2 : index;
120
286
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
286
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
286
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
286
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
286
        }
129
2.23k
    }
Unexecuted instantiation: _ZN5doris6CountsIhE9terminateEd
_ZN5doris6CountsIaE9terminateEd
Line
Count
Source
79
116
    double terminate(double quantile) {
80
116
        if (_sorted_nums_vec.size() <= 1) {
81
116
            if (_sorted_nums_vec.size() == 1) {
82
0
                _nums = std::move(_sorted_nums_vec[0]);
83
0
            }
84
85
116
            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
116
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
48
                pdqsort(_nums.begin(), _nums.end());
93
48
            }
94
95
116
            if (quantile == 1 || _nums.size() == 1) {
96
68
                return _nums.back();
97
68
            }
98
99
48
            double u = (_nums.size() - 1) * quantile;
100
48
            auto index = static_cast<uint32_t>(u);
101
48
            return _nums[index] +
102
48
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
116
        } 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
116
    }
_ZN5doris6CountsIsE9terminateEd
Line
Count
Source
79
594
    double terminate(double quantile) {
80
594
        if (_sorted_nums_vec.size() <= 1) {
81
588
            if (_sorted_nums_vec.size() == 1) {
82
0
                _nums = std::move(_sorted_nums_vec[0]);
83
0
            }
84
85
588
            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
588
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
288
                pdqsort(_nums.begin(), _nums.end());
93
288
            }
94
95
588
            if (quantile == 1 || _nums.size() == 1) {
96
172
                return _nums.back();
97
172
            }
98
99
416
            double u = (_nums.size() - 1) * quantile;
100
416
            auto index = static_cast<uint32_t>(u);
101
416
            return _nums[index] +
102
416
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
588
        } else {
104
6
            DCHECK(_nums.empty());
105
6
            size_t rows = 0;
106
12
            for (const auto& i : _sorted_nums_vec) {
107
12
                rows += i.size();
108
12
            }
109
6
            const bool reverse = quantile > 0.5 && rows > 2;
110
6
            double u = (rows - 1) * quantile;
111
6
            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
6
            size_t target = reverse ? rows - index - 2 : index;
120
6
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
6
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
6
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
6
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
6
        }
129
594
    }
_ZN5doris6CountsIiE9terminateEd
Line
Count
Source
79
960
    double terminate(double quantile) {
80
960
        if (_sorted_nums_vec.size() <= 1) {
81
774
            if (_sorted_nums_vec.size() == 1) {
82
538
                _nums = std::move(_sorted_nums_vec[0]);
83
538
            }
84
85
774
            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
774
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
22
                pdqsort(_nums.begin(), _nums.end());
93
22
            }
94
95
774
            if (quantile == 1 || _nums.size() == 1) {
96
484
                return _nums.back();
97
484
            }
98
99
290
            double u = (_nums.size() - 1) * quantile;
100
290
            auto index = static_cast<uint32_t>(u);
101
290
            return _nums[index] +
102
290
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
774
        } else {
104
186
            DCHECK(_nums.empty());
105
186
            size_t rows = 0;
106
494
            for (const auto& i : _sorted_nums_vec) {
107
494
                rows += i.size();
108
494
            }
109
186
            const bool reverse = quantile > 0.5 && rows > 2;
110
186
            double u = (rows - 1) * quantile;
111
186
            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
186
            size_t target = reverse ? rows - index - 2 : index;
120
186
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
186
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
186
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
186
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
186
        }
129
960
    }
_ZN5doris6CountsIlE9terminateEd
Line
Count
Source
79
236
    double terminate(double quantile) {
80
236
        if (_sorted_nums_vec.size() <= 1) {
81
190
            if (_sorted_nums_vec.size() == 1) {
82
50
                _nums = std::move(_sorted_nums_vec[0]);
83
50
            }
84
85
190
            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
190
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
2
                pdqsort(_nums.begin(), _nums.end());
93
2
            }
94
95
190
            if (quantile == 1 || _nums.size() == 1) {
96
120
                return _nums.back();
97
120
            }
98
99
70
            double u = (_nums.size() - 1) * quantile;
100
70
            auto index = static_cast<uint32_t>(u);
101
70
            return _nums[index] +
102
70
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
190
        } else {
104
46
            DCHECK(_nums.empty());
105
46
            size_t rows = 0;
106
172
            for (const auto& i : _sorted_nums_vec) {
107
172
                rows += i.size();
108
172
            }
109
46
            const bool reverse = quantile > 0.5 && rows > 2;
110
46
            double u = (rows - 1) * quantile;
111
46
            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
46
            size_t target = reverse ? rows - index - 2 : index;
120
46
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
46
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
46
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
46
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
46
        }
129
236
    }
_ZN5doris6CountsInE9terminateEd
Line
Count
Source
79
60
    double terminate(double quantile) {
80
60
        if (_sorted_nums_vec.size() <= 1) {
81
60
            if (_sorted_nums_vec.size() == 1) {
82
0
                _nums = std::move(_sorted_nums_vec[0]);
83
0
            }
84
85
60
            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
60
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
0
                pdqsort(_nums.begin(), _nums.end());
93
0
            }
94
95
60
            if (quantile == 1 || _nums.size() == 1) {
96
48
                return _nums.back();
97
48
            }
98
99
12
            double u = (_nums.size() - 1) * quantile;
100
12
            auto index = static_cast<uint32_t>(u);
101
12
            return _nums[index] +
102
12
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
60
        } 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
60
    }
Unexecuted instantiation: _ZN5doris6CountsIfE9terminateEd
_ZN5doris6CountsIdE9terminateEd
Line
Count
Source
79
266
    double terminate(double quantile) {
80
266
        if (_sorted_nums_vec.size() <= 1) {
81
218
            if (_sorted_nums_vec.size() == 1) {
82
52
                _nums = std::move(_sorted_nums_vec[0]);
83
52
            }
84
85
218
            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
218
            if (UNLIKELY(!std::is_sorted(_nums.begin(), _nums.end()))) {
92
0
                pdqsort(_nums.begin(), _nums.end());
93
0
            }
94
95
218
            if (quantile == 1 || _nums.size() == 1) {
96
60
                return _nums.back();
97
60
            }
98
99
158
            double u = (_nums.size() - 1) * quantile;
100
158
            auto index = static_cast<uint32_t>(u);
101
158
            return _nums[index] +
102
158
                   (u - static_cast<double>(index)) * (_nums[index + 1] - _nums[index]);
103
218
        } else {
104
48
            DCHECK(_nums.empty());
105
48
            size_t rows = 0;
106
144
            for (const auto& i : _sorted_nums_vec) {
107
144
                rows += i.size();
108
144
            }
109
48
            const bool reverse = quantile > 0.5 && rows > 2;
110
48
            double u = (rows - 1) * quantile;
111
48
            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
48
            size_t target = reverse ? rows - index - 2 : index;
120
48
            if (quantile == 1) {
121
0
                target = 0;
122
0
            }
123
48
            auto [first_number, second_number] = _merge_sort_and_get_numbers(target, reverse);
124
48
            if (quantile == 1) {
125
0
                return second_number;
126
0
            }
127
48
            return first_number + (u - static_cast<double>(index)) * (second_number - first_number);
128
48
        }
129
266
    }
130
131
private:
132
    struct Node {
133
        Ty value;
134
        int array_index;
135
        int64_t element_index;
136
137
2.94k
        auto operator<=>(const Node& other) const { return value <=> other.value; }
Unexecuted instantiation: _ZNK5doris6CountsIhE4NodessERKS2_
Unexecuted instantiation: _ZNK5doris6CountsIaE4NodessERKS2_
_ZNK5doris6CountsIsE4NodessERKS2_
Line
Count
Source
137
38
        auto operator<=>(const Node& other) const { return value <=> other.value; }
_ZNK5doris6CountsIiE4NodessERKS2_
Line
Count
Source
137
1.85k
        auto operator<=>(const Node& other) const { return value <=> other.value; }
_ZNK5doris6CountsIlE4NodessERKS2_
Line
Count
Source
137
874
        auto operator<=>(const Node& other) const { return value <=> other.value; }
Unexecuted instantiation: _ZNK5doris6CountsInE4NodessERKS2_
Unexecuted instantiation: _ZNK5doris6CountsIfE4NodessERKS2_
_ZNK5doris6CountsIdE4NodessERKS2_
Line
Count
Source
137
172
        auto operator<=>(const Node& other) const { return value <=> other.value; }
138
    };
139
140
1.73k
    void _convert_sorted_num_vec_to_nums() {
141
1.73k
        size_t rows = 0;
142
2.31k
        for (const auto& i : _sorted_nums_vec) {
143
2.31k
            rows += i.size();
144
2.31k
        }
145
1.73k
        _nums.resize(rows);
146
1.73k
        size_t count = 0;
147
148
1.73k
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
4.05k
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
2.31k
            if (!_sorted_nums_vec[i].empty()) {
151
2.31k
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
2.31k
            }
153
2.31k
        }
154
155
4.94k
        while (!min_heap.empty()) {
156
3.21k
            Node node = min_heap.top();
157
3.21k
            min_heap.pop();
158
3.21k
            _nums[count++] = node.value;
159
3.21k
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
896
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
896
                min_heap.push(node);
162
896
            }
163
3.21k
        }
164
1.73k
        _sorted_nums_vec.clear();
165
1.73k
    }
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
1.18k
    void _convert_sorted_num_vec_to_nums() {
141
1.18k
        size_t rows = 0;
142
1.58k
        for (const auto& i : _sorted_nums_vec) {
143
1.58k
            rows += i.size();
144
1.58k
        }
145
1.18k
        _nums.resize(rows);
146
1.18k
        size_t count = 0;
147
148
1.18k
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
2.76k
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
1.58k
            if (!_sorted_nums_vec[i].empty()) {
151
1.58k
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
1.58k
            }
153
1.58k
        }
154
155
3.57k
        while (!min_heap.empty()) {
156
2.39k
            Node node = min_heap.top();
157
2.39k
            min_heap.pop();
158
2.39k
            _nums[count++] = node.value;
159
2.39k
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
808
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
808
                min_heap.push(node);
162
808
            }
163
2.39k
        }
164
1.18k
        _sorted_nums_vec.clear();
165
1.18k
    }
_ZN5doris6CountsIlE31_convert_sorted_num_vec_to_numsEv
Line
Count
Source
140
370
    void _convert_sorted_num_vec_to_nums() {
141
370
        size_t rows = 0;
142
556
        for (const auto& i : _sorted_nums_vec) {
143
556
            rows += i.size();
144
556
        }
145
370
        _nums.resize(rows);
146
370
        size_t count = 0;
147
148
370
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
926
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
556
            if (!_sorted_nums_vec[i].empty()) {
151
556
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
556
            }
153
556
        }
154
155
1.00k
        while (!min_heap.empty()) {
156
632
            Node node = min_heap.top();
157
632
            min_heap.pop();
158
632
            _nums[count++] = node.value;
159
632
            if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
160
76
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
76
                min_heap.push(node);
162
76
            }
163
632
        }
164
370
        _sorted_nums_vec.clear();
165
370
    }
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
180
    void _convert_sorted_num_vec_to_nums() {
141
180
        size_t rows = 0;
142
180
        for (const auto& i : _sorted_nums_vec) {
143
180
            rows += i.size();
144
180
        }
145
180
        _nums.resize(rows);
146
180
        size_t count = 0;
147
148
180
        std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
149
360
        for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
150
180
            if (!_sorted_nums_vec[i].empty()) {
151
180
                min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
152
180
            }
153
180
        }
154
155
372
        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
12
                node.value = _sorted_nums_vec[node.array_index][node.element_index];
161
12
                min_heap.push(node);
162
12
            }
163
192
        }
164
180
        _sorted_nums_vec.clear();
165
180
    }
166
167
286
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
286
        Ty first_number = 0, second_number = 0;
169
286
        size_t count = 0;
170
286
        if (reverse) {
171
62
            std::priority_queue<Node> max_heap;
172
286
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
224
                if (!_sorted_nums_vec[i].empty()) {
174
224
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
224
                                     _sorted_nums_vec[i].size() - 1);
176
224
                }
177
224
            }
178
179
260
            while (!max_heap.empty()) {
180
260
                Node node = max_heap.top();
181
260
                max_heap.pop();
182
260
                if (count == target) {
183
62
                    second_number = node.value;
184
198
                } else if (count == target + 1) {
185
62
                    first_number = node.value;
186
62
                    break;
187
62
                }
188
198
                ++count;
189
198
                if (--node.element_index >= 0) {
190
150
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
150
                    max_heap.push(node);
192
150
                }
193
198
            }
194
195
224
        } else {
196
224
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
822
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
598
                if (!_sorted_nums_vec[i].empty()) {
199
598
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
598
                }
201
598
            }
202
203
630
            while (!min_heap.empty()) {
204
630
                Node node = min_heap.top();
205
630
                min_heap.pop();
206
630
                if (count == target) {
207
224
                    first_number = node.value;
208
406
                } else if (count == target + 1) {
209
224
                    second_number = node.value;
210
224
                    break;
211
224
                }
212
406
                ++count;
213
406
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
236
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
236
                    min_heap.push(node);
216
236
                }
217
406
            }
218
224
        }
219
220
286
        return {first_number, second_number};
221
286
    }
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
6
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
6
        Ty first_number = 0, second_number = 0;
169
6
        size_t count = 0;
170
6
        if (reverse) {
171
2
            std::priority_queue<Node> max_heap;
172
6
            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
12
            while (!max_heap.empty()) {
180
12
                Node node = max_heap.top();
181
12
                max_heap.pop();
182
12
                if (count == target) {
183
2
                    second_number = node.value;
184
10
                } else if (count == target + 1) {
185
2
                    first_number = node.value;
186
2
                    break;
187
2
                }
188
10
                ++count;
189
10
                if (--node.element_index >= 0) {
190
10
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
10
                    max_heap.push(node);
192
10
                }
193
10
            }
194
195
4
        } else {
196
4
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
12
            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
26
            while (!min_heap.empty()) {
204
26
                Node node = min_heap.top();
205
26
                min_heap.pop();
206
26
                if (count == target) {
207
4
                    first_number = node.value;
208
22
                } else if (count == target + 1) {
209
4
                    second_number = node.value;
210
4
                    break;
211
4
                }
212
22
                ++count;
213
22
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
22
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
22
                    min_heap.push(node);
216
22
                }
217
22
            }
218
4
        }
219
220
6
        return {first_number, second_number};
221
6
    }
_ZN5doris6CountsIiE27_merge_sort_and_get_numbersElb
Line
Count
Source
167
186
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
186
        Ty first_number = 0, second_number = 0;
169
186
        size_t count = 0;
170
186
        if (reverse) {
171
20
            std::priority_queue<Node> max_heap;
172
76
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
56
                if (!_sorted_nums_vec[i].empty()) {
174
56
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
56
                                     _sorted_nums_vec[i].size() - 1);
176
56
                }
177
56
            }
178
179
78
            while (!max_heap.empty()) {
180
78
                Node node = max_heap.top();
181
78
                max_heap.pop();
182
78
                if (count == target) {
183
20
                    second_number = node.value;
184
58
                } else if (count == target + 1) {
185
20
                    first_number = node.value;
186
20
                    break;
187
20
                }
188
58
                ++count;
189
58
                if (--node.element_index >= 0) {
190
44
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
44
                    max_heap.push(node);
192
44
                }
193
58
            }
194
195
166
        } else {
196
166
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
604
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
438
                if (!_sorted_nums_vec[i].empty()) {
199
438
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
438
                }
201
438
            }
202
203
468
            while (!min_heap.empty()) {
204
468
                Node node = min_heap.top();
205
468
                min_heap.pop();
206
468
                if (count == target) {
207
166
                    first_number = node.value;
208
302
                } else if (count == target + 1) {
209
166
                    second_number = node.value;
210
166
                    break;
211
166
                }
212
302
                ++count;
213
302
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
194
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
194
                    min_heap.push(node);
216
194
                }
217
302
            }
218
166
        }
219
220
186
        return {first_number, second_number};
221
186
    }
_ZN5doris6CountsIlE27_merge_sort_and_get_numbersElb
Line
Count
Source
167
46
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
46
        Ty first_number = 0, second_number = 0;
169
46
        size_t count = 0;
170
46
        if (reverse) {
171
36
            std::priority_queue<Node> max_heap;
172
184
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
148
                if (!_sorted_nums_vec[i].empty()) {
174
148
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
148
                                     _sorted_nums_vec[i].size() - 1);
176
148
                }
177
148
            }
178
179
160
            while (!max_heap.empty()) {
180
160
                Node node = max_heap.top();
181
160
                max_heap.pop();
182
160
                if (count == target) {
183
36
                    second_number = node.value;
184
124
                } else if (count == target + 1) {
185
36
                    first_number = node.value;
186
36
                    break;
187
36
                }
188
124
                ++count;
189
124
                if (--node.element_index >= 0) {
190
96
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
191
96
                    max_heap.push(node);
192
96
                }
193
124
            }
194
195
36
        } else {
196
10
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
34
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
24
                if (!_sorted_nums_vec[i].empty()) {
199
24
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
24
                }
201
24
            }
202
203
32
            while (!min_heap.empty()) {
204
32
                Node node = min_heap.top();
205
32
                min_heap.pop();
206
32
                if (count == target) {
207
10
                    first_number = node.value;
208
22
                } else if (count == target + 1) {
209
10
                    second_number = node.value;
210
10
                    break;
211
10
                }
212
22
                ++count;
213
22
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
20
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
20
                    min_heap.push(node);
216
20
                }
217
22
            }
218
10
        }
219
220
46
        return {first_number, second_number};
221
46
    }
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
48
    std::pair<Ty, Ty> _merge_sort_and_get_numbers(int64_t target, bool reverse) {
168
48
        Ty first_number = 0, second_number = 0;
169
48
        size_t count = 0;
170
48
        if (reverse) {
171
4
            std::priority_queue<Node> max_heap;
172
20
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
173
16
                if (!_sorted_nums_vec[i].empty()) {
174
16
                    max_heap.emplace(_sorted_nums_vec[i][_sorted_nums_vec[i].size() - 1], i,
175
16
                                     _sorted_nums_vec[i].size() - 1);
176
16
                }
177
16
            }
178
179
10
            while (!max_heap.empty()) {
180
10
                Node node = max_heap.top();
181
10
                max_heap.pop();
182
10
                if (count == target) {
183
4
                    second_number = node.value;
184
6
                } else if (count == target + 1) {
185
4
                    first_number = node.value;
186
4
                    break;
187
4
                }
188
6
                ++count;
189
6
                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
6
            }
194
195
44
        } else {
196
44
            std::priority_queue<Node, std::vector<Node>, std::greater<Node>> min_heap;
197
172
            for (int i = 0; i < _sorted_nums_vec.size(); ++i) {
198
128
                if (!_sorted_nums_vec[i].empty()) {
199
128
                    min_heap.emplace(_sorted_nums_vec[i][0], i, 0);
200
128
                }
201
128
            }
202
203
104
            while (!min_heap.empty()) {
204
104
                Node node = min_heap.top();
205
104
                min_heap.pop();
206
104
                if (count == target) {
207
44
                    first_number = node.value;
208
60
                } else if (count == target + 1) {
209
44
                    second_number = node.value;
210
44
                    break;
211
44
                }
212
60
                ++count;
213
60
                if (++node.element_index < _sorted_nums_vec[node.array_index].size()) {
214
0
                    node.value = _sorted_nums_vec[node.array_index][node.element_index];
215
0
                    min_heap.push(node);
216
0
                }
217
60
            }
218
44
        }
219
220
48
        return {first_number, second_number};
221
48
    }
222
223
    vectorized::PODArray<Ty> _nums;
224
    std::vector<vectorized::PODArray<Ty>> _sorted_nums_vec;
225
};
226
227
} // namespace doris