Coverage Report

Created: 2026-03-19 11:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/unaligned.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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/base/base/unaligned.h
19
// and modified by Doris
20
21
#pragma once
22
23
#include <cstring>
24
#include <type_traits>
25
26
namespace doris {
27
28
template <typename T>
29
2.27G
T unaligned_load(const void* address) {
30
2.27G
    T res {};
31
2.27G
    memcpy(&res, address, sizeof(res));
32
2.27G
    return res;
33
2.27G
}
_ZN5doris14unaligned_loadItEET_PKv
Line
Count
Source
29
672
T unaligned_load(const void* address) {
30
672
    T res {};
31
672
    memcpy(&res, address, sizeof(res));
32
672
    return res;
33
672
}
_ZN5doris14unaligned_loadIjEET_PKv
Line
Count
Source
29
117M
T unaligned_load(const void* address) {
30
117M
    T res {};
31
117M
    memcpy(&res, address, sizeof(res));
32
117M
    return res;
33
117M
}
_ZN5doris14unaligned_loadImEET_PKv
Line
Count
Source
29
2.05G
T unaligned_load(const void* address) {
30
2.05G
    T res {};
31
2.05G
    memcpy(&res, address, sizeof(res));
32
2.05G
    return res;
33
2.05G
}
_ZN5doris14unaligned_loadIhEET_PKv
Line
Count
Source
29
7.77M
T unaligned_load(const void* address) {
30
7.77M
    T res {};
31
7.77M
    memcpy(&res, address, sizeof(res));
32
7.77M
    return res;
33
7.77M
}
_ZN5doris14unaligned_loadINS_16TimestampTzValueEEET_PKv
Line
Count
Source
29
391
T unaligned_load(const void* address) {
30
391
    T res {};
31
391
    memcpy(&res, address, sizeof(res));
32
391
    return res;
33
391
}
_ZN5doris14unaligned_loadIfEET_PKv
Line
Count
Source
29
434k
T unaligned_load(const void* address) {
30
434k
    T res {};
31
434k
    memcpy(&res, address, sizeof(res));
32
434k
    return res;
33
434k
}
_ZN5doris14unaligned_loadIlEET_PKv
Line
Count
Source
29
18.6M
T unaligned_load(const void* address) {
30
18.6M
    T res {};
31
18.6M
    memcpy(&res, address, sizeof(res));
32
18.6M
    return res;
33
18.6M
}
_ZN5doris14unaligned_loadIaEET_PKv
Line
Count
Source
29
4.47M
T unaligned_load(const void* address) {
30
4.47M
    T res {};
31
4.47M
    memcpy(&res, address, sizeof(res));
32
4.47M
    return res;
33
4.47M
}
_ZN5doris14unaligned_loadIiEET_PKv
Line
Count
Source
29
44.5M
T unaligned_load(const void* address) {
30
44.5M
    T res {};
31
44.5M
    memcpy(&res, address, sizeof(res));
32
44.5M
    return res;
33
44.5M
}
_ZN5doris14unaligned_loadIdEET_PKv
Line
Count
Source
29
6.39M
T unaligned_load(const void* address) {
30
6.39M
    T res {};
31
6.39M
    memcpy(&res, address, sizeof(res));
32
6.39M
    return res;
33
6.39M
}
_ZN5doris14unaligned_loadINS_11DateV2ValueINS_15DateV2ValueTypeEEEEET_PKv
Line
Count
Source
29
158k
T unaligned_load(const void* address) {
30
158k
    T res {};
31
158k
    memcpy(&res, address, sizeof(res));
32
158k
    return res;
33
158k
}
_ZN5doris14unaligned_loadINS_11DateV2ValueINS_19DateTimeV2ValueTypeEEEEET_PKv
Line
Count
Source
29
140k
T unaligned_load(const void* address) {
30
140k
    T res {};
31
140k
    memcpy(&res, address, sizeof(res));
32
140k
    return res;
33
140k
}
_ZN5doris14unaligned_loadIoEET_PKv
Line
Count
Source
29
14.3k
T unaligned_load(const void* address) {
30
14.3k
    T res {};
31
14.3k
    memcpy(&res, address, sizeof(res));
32
14.3k
    return res;
33
14.3k
}
_ZN5doris14unaligned_loadIsEET_PKv
Line
Count
Source
29
99.9k
T unaligned_load(const void* address) {
30
99.9k
    T res {};
31
99.9k
    memcpy(&res, address, sizeof(res));
32
99.9k
    return res;
33
99.9k
}
_ZN5doris14unaligned_loadInEET_PKv
Line
Count
Source
29
363k
T unaligned_load(const void* address) {
30
363k
    T res {};
31
363k
    memcpy(&res, address, sizeof(res));
32
363k
    return res;
33
363k
}
_ZN5doris14unaligned_loadINS_16VecDateTimeValueEEET_PKv
Line
Count
Source
29
3.07M
T unaligned_load(const void* address) {
30
3.07M
    T res {};
31
3.07M
    memcpy(&res, address, sizeof(res));
32
3.07M
    return res;
33
3.07M
}
_ZN5doris14unaligned_loadI10Elf64_NhdrEET_PKv
Line
Count
Source
29
550
T unaligned_load(const void* address) {
30
550
    T res {};
31
550
    memcpy(&res, address, sizeof(res));
32
550
    return res;
33
550
}
_ZN5doris14unaligned_loadINS_8uint24_tEEET_PKv
Line
Count
Source
29
996k
T unaligned_load(const void* address) {
30
996k
    T res {};
31
996k
    memcpy(&res, address, sizeof(res));
32
996k
    return res;
33
996k
}
_ZN5doris14unaligned_loadIbEET_PKv
Line
Count
Source
29
1.18M
T unaligned_load(const void* address) {
30
1.18M
    T res {};
31
1.18M
    memcpy(&res, address, sizeof(res));
32
1.18M
    return res;
33
1.18M
}
_ZN5doris14unaligned_loadIN4wide7integerILm256EiEEEET_PKv
Line
Count
Source
29
1.13k
T unaligned_load(const void* address) {
30
1.13k
    T res {};
31
1.13k
    memcpy(&res, address, sizeof(res));
32
1.13k
    return res;
33
1.13k
}
_ZN5doris14unaligned_loadINS_7DecimalIiEEEET_PKv
Line
Count
Source
29
5.49k
T unaligned_load(const void* address) {
30
5.49k
    T res {};
31
5.49k
    memcpy(&res, address, sizeof(res));
32
5.49k
    return res;
33
5.49k
}
_ZN5doris14unaligned_loadINS_7DecimalIlEEEET_PKv
Line
Count
Source
29
13.5M
T unaligned_load(const void* address) {
30
13.5M
    T res {};
31
13.5M
    memcpy(&res, address, sizeof(res));
32
13.5M
    return res;
33
13.5M
}
_ZN5doris14unaligned_loadINS_14DecimalV2ValueEEET_PKv
Line
Count
Source
29
9.38k
T unaligned_load(const void* address) {
30
9.38k
    T res {};
31
9.38k
    memcpy(&res, address, sizeof(res));
32
9.38k
    return res;
33
9.38k
}
_ZN5doris14unaligned_loadINS_12Decimal128V3EEET_PKv
Line
Count
Source
29
11.2k
T unaligned_load(const void* address) {
30
11.2k
    T res {};
31
11.2k
    memcpy(&res, address, sizeof(res));
32
11.2k
    return res;
33
11.2k
}
_ZN5doris14unaligned_loadINS_7DecimalIN4wide7integerILm256EiEEEEEET_PKv
Line
Count
Source
29
8.77k
T unaligned_load(const void* address) {
30
8.77k
    T res {};
31
8.77k
    memcpy(&res, address, sizeof(res));
32
8.77k
    return res;
33
8.77k
}
_ZN5doris14unaligned_loadINS_9StringRefEEET_PKv
Line
Count
Source
29
4.15M
T unaligned_load(const void* address) {
30
4.15M
    T res {};
31
4.15M
    memcpy(&res, address, sizeof(res));
32
4.15M
    return res;
33
4.15M
}
_ZN5doris14unaligned_loadINS_11decimal12_tEEET_PKv
Line
Count
Source
29
136
T unaligned_load(const void* address) {
30
136
    T res {};
31
136
    memcpy(&res, address, sizeof(res));
32
136
    return res;
33
136
}
34
35
/// We've had troubles before with wrong store size due to integral promotions
36
/// (e.g., unaligned_store(dest, uint16_t + uint16_t) stores an uint32_t).
37
/// To prevent this, make the caller specify the stored type explicitly.
38
/// To disable deduction of T, wrap the argument type with std::enable_if.
39
template <typename T>
40
4.77M
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
4.77M
    static_assert(std::is_trivially_copyable_v<T>);
42
4.77M
    memcpy(address, &src, sizeof(src));
43
4.77M
}
_ZN5doris15unaligned_storeItEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
51.1k
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
51.1k
    static_assert(std::is_trivially_copyable_v<T>);
42
51.1k
    memcpy(address, &src, sizeof(src));
43
51.1k
}
_ZN5doris15unaligned_storeIjEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
62.5k
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
62.5k
    static_assert(std::is_trivially_copyable_v<T>);
42
62.5k
    memcpy(address, &src, sizeof(src));
43
62.5k
}
_ZN5doris15unaligned_storeImEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
3.21M
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
3.21M
    static_assert(std::is_trivially_copyable_v<T>);
42
3.21M
    memcpy(address, &src, sizeof(src));
43
3.21M
}
_ZN5doris15unaligned_storeIbEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
1.18M
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
1.18M
    static_assert(std::is_trivially_copyable_v<T>);
42
1.18M
    memcpy(address, &src, sizeof(src));
43
1.18M
}
_ZN5doris15unaligned_storeIiEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
14.1k
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
14.1k
    static_assert(std::is_trivially_copyable_v<T>);
42
14.1k
    memcpy(address, &src, sizeof(src));
43
14.1k
}
_ZN5doris15unaligned_storeIfEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
192k
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
192k
    static_assert(std::is_trivially_copyable_v<T>);
42
192k
    memcpy(address, &src, sizeof(src));
43
192k
}
_ZN5doris15unaligned_storeIdEEvPvRKNSt9enable_ifILb1ET_E4typeE
Line
Count
Source
40
61.0k
void unaligned_store(void* address, const typename std::enable_if<true, T>::type& src) {
41
61.0k
    static_assert(std::is_trivially_copyable_v<T>);
42
61.0k
    memcpy(address, &src, sizeof(src));
43
61.0k
}
44
} // namespace doris