Coverage Report

Created: 2024-11-20 21:14

/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
10
std::string IColumn::dump_structure() const {
32
10
    std::stringstream res;
33
10
    res << get_name() << "(size = " << size();
34
35
10
    ColumnCallback callback = [&](ColumnPtr& subcolumn) {
36
2
        res << ", " << subcolumn->dump_structure();
37
2
    };
38
39
10
    const_cast<IColumn*>(this)->for_each_subcolumn(callback);
40
41
10
    res << ")";
42
10
    return res.str();
43
10
}
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) {
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
0
                               uint8* __restrict filter) const {
64
0
    auto sz = this->size();
65
0
    DCHECK(cmp_res.size() == sz);
66
0
    size_t begin = simd::find_zero(cmp_res, 0);
67
0
    while (begin < sz) {
68
0
        size_t end = simd::find_one(cmp_res, begin + 1);
69
0
        for (size_t row_id = begin; row_id < end; row_id++) {
70
0
            int res = this->compare_at(row_id, rhs_row_id, rhs, nan_direction_hint);
71
0
            if (res * direction < 0) {
72
0
                filter[row_id] = 1;
73
0
                cmp_res[row_id] = 1;
74
0
            } else if (res * direction > 0) {
75
0
                cmp_res[row_id] = 1;
76
0
            }
77
0
        }
78
0
        begin = simd::find_zero(cmp_res, end + 1);
79
0
    }
80
0
}
81
82
495
bool is_column_nullable(const IColumn& column) {
83
495
    return check_column<ColumnNullable>(column);
84
495
}
85
86
195k
bool is_column_const(const IColumn& column) {
87
195k
    return check_column<ColumnConst>(column);
88
195k
}
89
90
} // namespace doris::vectorized