Coverage Report

Created: 2026-03-13 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/segment/page_pointer.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
18
#pragma once
19
20
#include <gen_cpp/segment_v2.pb.h>
21
22
#include <cstdint>
23
#include <string>
24
25
#include "util/coding.h"
26
#include "util/faststring.h"
27
28
namespace doris {
29
namespace segment_v2 {
30
31
struct PagePointer {
32
    uint64_t offset;
33
    uint32_t size;
34
35
92.8M
    PagePointer() : offset(0), size(0) {}
36
    PagePointer(uint64_t offset_, uint32_t size_) : offset(offset_), size(size_) {}
37
36.3M
    PagePointer(const PagePointerPB& from) : offset(from.offset()), size(from.size()) {}
38
39
0
    void reset() {
40
0
        offset = 0;
41
0
        size = 0;
42
0
    }
43
44
2.23M
    void to_proto(PagePointerPB* to) {
45
2.23M
        to->set_offset(offset);
46
2.23M
        to->set_size(size);
47
2.23M
    }
48
49
0
    const uint8_t* decode_from(const uint8_t* data, const uint8_t* limit) {
50
0
        data = decode_varint64_ptr(data, limit, &offset);
51
0
        if (data == nullptr) {
52
0
            return nullptr;
53
0
        }
54
0
        return decode_varint32_ptr(data, limit, &size);
55
0
    }
56
57
3.25M
    bool decode_from(Slice* input) {
58
3.25M
        bool result = get_varint64(input, &offset);
59
3.25M
        if (!result) {
60
0
            return false;
61
0
        }
62
3.25M
        return get_varint32(input, &size);
63
3.25M
    }
64
65
1.94M
    void encode_to(faststring* dst) const { put_varint64_varint32(dst, offset, size); }
66
67
0
    void encode_to(std::string* dst) const { put_varint64_varint32(dst, offset, size); }
68
69
109
    bool operator==(const PagePointer& other) const {
70
109
        return offset == other.offset && size == other.size;
71
109
    }
72
73
101
    bool operator!=(const PagePointer& other) const { return !(*this == other); }
74
};
75
76
inline std::ostream& operator<<(std::ostream& os, const PagePointer& pp) {
77
    os << "PagePointer { offset=" << pp.offset << " size=" << pp.size << " }";
78
    return os;
79
}
80
81
} // namespace segment_v2
82
} // namespace doris