Coverage Report

Created: 2025-04-11 14:35

/root/doris/be/src/vec/columns/column.cpp
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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Columns/IColumn.cpp
19
// and modified by Doris
20
21
#include "vec/columns/column.h"
22
23
#include "util/simd/bits.h"
24
#include "vec/columns/column_const.h"
25
#include "vec/columns/column_nullable.h"
26
#include "vec/core/sort_block.h"
27
#include "vec/data_types/data_type.h"
28
29
namespace doris::vectorized {
30
31
3.09k
std::string IColumn::dump_structure() const {
32
3.09k
    std::stringstream res;
33
3.09k
    res << get_name() << "(size = " << size();
34
35
3.09k
    ColumnCallback callback = [&](ColumnPtr& subcolumn) {
36
2.76k
        res << ", " << subcolumn->dump_structure();
37
2.76k
    };
38
39
3.09k
    const_cast<IColumn*>(this)->for_each_subcolumn(callback);
40
41
3.09k
    res << ")";
42
3.09k
    return res.str();
43
3.09k
}
44
45
0
void IColumn::insert_from(const IColumn& src, size_t n) {
46
0
    insert(src[n]);
47
0
}
48
49
void IColumn::sort_column(const ColumnSorter* sorter, EqualFlags& flags,
50
0
                          IColumn::Permutation& perms, EqualRange& range, bool last_column) const {
51
0
    sorter->sort_column(static_cast<const IColumn&>(*this), flags, perms, range, last_column);
52
0
}
53
54
void IColumn::compare_internal(size_t rhs_row_id, const IColumn& rhs, int nan_direction_hint,
55
                               int direction, std::vector<uint8>& cmp_res,
56
0
                               uint8* __restrict filter) const {
57
0
    auto sz = this->size();
58
0
    DCHECK(cmp_res.size() == sz);
59
0
    size_t begin = simd::find_zero(cmp_res, 0);
60
0
    while (begin < sz) {
61
0
        size_t end = simd::find_one(cmp_res, begin + 1);
62
0
        for (size_t row_id = begin; row_id < end; row_id++) {
63
0
            int res = this->compare_at(row_id, rhs_row_id, rhs, nan_direction_hint);
64
0
            if (res * direction < 0) {
65
0
                filter[row_id] = 1;
66
0
                cmp_res[row_id] = 1;
67
0
            } else if (res * direction > 0) {
68
0
                cmp_res[row_id] = 1;
69
0
            }
70
0
        }
71
0
        begin = simd::find_zero(cmp_res, end + 1);
72
0
    }
73
0
}
74
75
1.45k
bool is_column_nullable(const IColumn& column) {
76
1.45k
    return is_column<ColumnNullable>(column);
77
1.45k
}
78
79
272M
bool is_column_const(const IColumn& column) {
80
272M
    return is_column<ColumnConst>(column);
81
272M
}
82
83
} // namespace doris::vectorized