Coverage Report

Created: 2026-03-14 20:54

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