Coverage Report

Created: 2026-10-09 21:17

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