Coverage Report

Created: 2026-10-20 12:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/segment/page_decoder.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 "common/status.h" // for Status
21
#include "core/column/column.h"
22
#include "storage/olap_define.h" // for DISALLOW_COPY_AND_ASSIGN
23
#include "storage/segment/common.h"
24
25
namespace doris {
26
namespace segment_v2 {
27
28
// PageDecoder is used to decode page.
29
class PageDecoder {
30
public:
31
6.35M
    PageDecoder() {}
32
    PageDecoder(const PageDecoder&) = delete;
33
    PageDecoder& operator=(const PageDecoder&) = delete;
34
35
6.40M
    virtual ~PageDecoder() {}
36
37
    // Call this to do some preparation for decoder.
38
    // eg: parse data page header
39
    virtual Status init() = 0;
40
41
    // Seek the decoder to the given positional index of the page.
42
    // For example, seek_to_position_in_page(0) seeks to the first
43
    // stored entry.
44
    //
45
    // It is an error to call this with a value larger than Count().
46
    // Doing so has undefined results.
47
    virtual Status seek_to_position_in_page(size_t pos) = 0;
48
49
    // Seek the decoder to the given value in the page, or the
50
    // lowest value which is greater than the given value.
51
    //
52
    // If the decoder was able to locate an exact match, then
53
    // sets *exact_match to true. Otherwise sets *exact_match to
54
    // false, to indicate that the seeked value is _after_ the
55
    // requested value.
56
    //
57
    // If the given value is less than the lowest value in the page,
58
    // seeks to the start of the page. If it is higher than the highest
59
    // value in the page, then returns Status::Error<ENTRY_NOT_FOUND>
60
    //
61
    // This will only return valid results when the data page
62
    // consists of values in sorted order.
63
0
    virtual Status seek_at_or_after_value(const void* value, bool* exact_match) {
64
0
        return Status::NotSupported("seek_at_or_after_value"); // FIXME
65
0
    }
66
67
    virtual Status next_batch(size_t* n, MutableColumnPtr& dst) = 0;
68
69
    virtual Status read_by_rowids(const rowid_t* rowids, ordinal_t page_first_ordinal, size_t* n,
70
0
                                  MutableColumnPtr& dst) {
71
0
        return Status::NotSupported("not implement vec op now");
72
0
    }
73
74
    // Same as `next_batch` except for not moving forward the cursor.
75
    // When read array's ordinals in `ArrayFileColumnIterator`, we want to read one extra ordinal
76
    // but do not want to move forward the cursor.
77
0
    virtual Status peek_next_batch(size_t* n, MutableColumnPtr& dst) {
78
0
        return Status::NotSupported("not implement vec op now");
79
0
    }
80
81
    // Return the number of elements in this page.
82
    virtual size_t count() const = 0;
83
84
    // Return the position within the page of the currently seeked
85
    // entry (ie the entry that will next be returned by next_vector())
86
    virtual size_t current_index() const = 0;
87
88
0
    bool has_remaining() const { return current_index() < count(); }
89
90
0
    virtual Status get_dict_word_info(StringRef* dict_word_info) {
91
0
        return Status::NotSupported("get_dict_word_info not implement");
92
0
    }
93
};
94
95
} // namespace segment_v2
96
} // namespace doris