Coverage Report

Created: 2026-04-20 14:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/load/group_commit/wal/wal_reader.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
#include "format/table/table_format_reader.h"
20
#include "load/group_commit/wal/wal_file_reader.h"
21
#include "runtime/descriptors.h"
22
23
namespace doris {
24
struct ScannerCounter;
25
26
/// WAL-specific initialization context.
27
/// Extends ReaderInitContext with output tuple descriptor (unique to WAL reader).
28
struct WalInitContext final : public ReaderInitContext {
29
    const TupleDescriptor* output_tuple_descriptor = nullptr;
30
};
31
32
class WalReader : public TableFormatReader {
33
    ENABLE_FACTORY_CREATOR(WalReader);
34
35
public:
36
    WalReader(RuntimeState* state);
37
0
    ~WalReader() override = default;
38
    Status init_reader(const TupleDescriptor* tuple_descriptor);
39
    Status _do_get_next_block(Block* block, size_t* read_rows, bool* eof) override;
40
    Status _get_columns_impl(std::unordered_map<std::string, DataTypePtr>* name_to_type) override;
41
42
0
    Status close() override {
43
0
        if (_wal_reader) {
44
0
            return _wal_reader->finalize();
45
0
        }
46
0
        return Status::OK();
47
0
    }
48
49
protected:
50
    // ---- Unified init_reader(ReaderInitContext*) overrides ----
51
    Status _open_file_reader(ReaderInitContext* ctx) override;
52
    Status _do_init_reader(ReaderInitContext* ctx) override;
53
54
private:
55
    RuntimeState* _state = nullptr;
56
    int64_t _wal_id;
57
    std::string _wal_path;
58
    std::shared_ptr<doris::WalFileReader> _wal_reader = nullptr;
59
    const TupleDescriptor* _tuple_descriptor = nullptr;
60
    // column_id, column_pos
61
    std::map<int64_t, int64_t> _column_pos_map;
62
    int64_t _column_id_count;
63
    uint32_t _version = 0;
64
};
65
} // namespace doris