Coverage Report

Created: 2026-05-19 08:39

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
1.71k
size_t UniqueId::hash(size_t seed) const {
32
1.71k
    return doris::HashUtil::hash(this, sizeof(*this), cast_set<uint32_t>(seed));
33
1.71k
}
34
35
10.3k
std::size_t hash_value(const doris::TUniqueId& id) {
36
10.3k
    std::size_t seed = 0;
37
10.3k
    HashUtil::hash_combine(seed, id.lo);
38
10.3k
    HashUtil::hash_combine(seed, id.hi);
39
10.3k
    return seed;
40
10.3k
}
41
42
490
std::ostream& operator<<(std::ostream& os, const UniqueId& uid) {
43
490
    os << uid.to_string();
44
490
    return os;
45
490
}
46
47
0
std::string print_id(const UniqueId& id) {
48
0
    return id.to_string();
49
0
}
50
51
543k
std::string print_id(const TUniqueId& id) {
52
543k
    return fmt::format(FMT_COMPILE("{:x}-{:x}"), static_cast<uint64_t>(id.hi),
53
543k
                       static_cast<uint64_t>(id.lo));
54
543k
}
55
56
2.23k
std::string print_id(const PUniqueId& id) {
57
2.23k
    return fmt::format(FMT_COMPILE("{:x}-{:x}"), static_cast<uint64_t>(id.hi()),
58
2.23k
                       static_cast<uint64_t>(id.lo()));
59
2.23k
}
60
61
0
bool TUniqueId::operator<(const TUniqueId& rhs) const {
62
0
    if (hi < rhs.hi) {
63
0
        return true;
64
0
    }
65
0
    if (hi > rhs.hi) {
66
0
        return false;
67
0
    }
68
0
    return lo < rhs.lo;
69
0
}
70
71
} // namespace doris