Coverage Report

Created: 2026-04-02 09:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/uid_util.cpp
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
#include "util/uid_util.h"
19
20
#include <fmt/compile.h>
21
#include <gen_cpp/Types_types.h>
22
#include <gen_cpp/types.pb.h>
23
#include <glog/logging.h>
24
25
#include <cstdlib>
26
27
#include "common/cast_set.h"
28
#include "util/hash_util.hpp"
29
30
namespace doris {
31
#include "common/compile_check_begin.h"
32
535k
size_t UniqueId::hash(size_t seed) const {
33
535k
    return doris::HashUtil::hash(this, sizeof(*this), cast_set<uint32_t>(seed));
34
535k
}
35
36
3.11M
std::size_t hash_value(const doris::TUniqueId& id) {
37
3.11M
    std::size_t seed = 0;
38
3.11M
    HashUtil::hash_combine(seed, id.lo);
39
3.11M
    HashUtil::hash_combine(seed, id.hi);
40
3.11M
    return seed;
41
3.11M
}
42
43
218k
std::ostream& operator<<(std::ostream& os, const UniqueId& uid) {
44
218k
    os << uid.to_string();
45
218k
    return os;
46
218k
}
47
48
85
std::string print_id(const UniqueId& id) {
49
85
    return id.to_string();
50
85
}
51
52
13.5M
std::string print_id(const TUniqueId& id) {
53
13.5M
    return fmt::format(FMT_COMPILE("{:x}-{:x}"), static_cast<uint64_t>(id.hi),
54
13.5M
                       static_cast<uint64_t>(id.lo));
55
13.5M
}
56
57
264k
std::string print_id(const PUniqueId& id) {
58
264k
    return fmt::format(FMT_COMPILE("{:x}-{:x}"), static_cast<uint64_t>(id.hi()),
59
264k
                       static_cast<uint64_t>(id.lo()));
60
264k
}
61
62
79.7k
bool TUniqueId::operator<(const TUniqueId& rhs) const {
63
79.7k
    if (hi < rhs.hi) {
64
5.21k
        return true;
65
5.21k
    }
66
74.5k
    if (hi > rhs.hi) {
67
1.33k
        return false;
68
1.33k
    }
69
73.1k
    return lo < rhs.lo;
70
74.5k
}
71
72
#include "common/compile_check_end.h"
73
} // namespace doris