Coverage Report

Created: 2025-10-30 15:07

/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
1.44k
std::string IColumn::dump_structure() const {
32
1.44k
    std::stringstream res;
33
1.44k
    res << get_family_name() << "(size = " << size();
34
35
1.44k
    ColumnCallback callback = [&](ColumnPtr& subcolumn) {
36
1.37k
        res << ", " << subcolumn->dump_structure();
37
1.37k
    };
38
39
1.44k
    const_cast<IColumn*>(this)->for_each_subcolumn(callback);
40
41
1.44k
    res << ")";
42
1.44k
    return res.str();
43
1.44k
}
44
45
0
void IColumn::insert_from(const IColumn& src, size_t n) {
46
0
    insert(src[n]);
47
0
}
48
49
void IColumn::insert_from_multi_column(const std::vector<const IColumn*>& srcs,
50
0
                                       std::vector<size_t> positions) {
51
0
    for (size_t i = 0; i < srcs.size(); ++i) {
  Branch (51:24): [True: 0, False: 0]
52
0
        insert_from(*srcs[i], positions[i]);
53
0
    }
54
0
}
55
56
void IColumn::sort_column(const ColumnSorter* sorter, EqualFlags& flags,
57
0
                          IColumn::Permutation& perms, EqualRange& range, bool last_column) const {
58
0
    sorter->sort_column(static_cast<const IColumn&>(*this), flags, perms, range, last_column);
59
0
}
60
61
void IColumn::compare_internal(size_t rhs_row_id, const IColumn& rhs, int nan_direction_hint,
62
                               int direction, std::vector<uint8>& cmp_res,
63
1
                               uint8* __restrict filter) const {
64
1
    auto sz = this->size();
65
1
    DCHECK(cmp_res.size() == sz);
66
1
    size_t begin = simd::find_zero(cmp_res, 0);
67
2
    while (begin < sz) {
  Branch (67:12): [True: 1, False: 1]
68
1
        size_t end = simd::find_one(cmp_res, begin + 1);
69
2
        for (size_t row_id = begin; row_id < end; row_id++) {
  Branch (69:37): [True: 1, False: 1]
70
1
            int res = this->compare_at(row_id, rhs_row_id, rhs, nan_direction_hint);
71
1
            if (res * direction < 0) {
  Branch (71:17): [True: 0, False: 1]
72
0
                filter[row_id] = 1;
73
0
                cmp_res[row_id] = 1;
74
1
            } else if (res * direction > 0) {
  Branch (74:24): [True: 0, False: 1]
75
0
                cmp_res[row_id] = 1;
76
0
            }
77
1
        }
78
1
        begin = simd::find_zero(cmp_res, end + 1);
79
1
    }
80
1
}
81
82
747
bool is_column_nullable(const IColumn& column) {
83
747
    return check_column<ColumnNullable>(column);
84
747
}
85
86
1.92M
bool is_column_const(const IColumn& column) {
87
1.92M
    return check_column<ColumnConst>(column);
88
1.92M
}
89
90
} // namespace doris::vectorized