Coverage Report

Created: 2026-06-04 13:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/paimon_cpp_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
20
#include <cstddef>
21
#include <map>
22
#include <memory>
23
#include <optional>
24
#include <string>
25
#include <unordered_map>
26
#include <unordered_set>
27
#include <vector>
28
29
#include "cctz/time_zone.h"
30
#include "common/status.h"
31
#include "format/generic_reader.h"
32
#include "paimon/reader/batch_reader.h"
33
#include "paimon/table/source/split.h"
34
#include "storage/olap_scan_common.h"
35
36
namespace paimon {
37
class TableRead;
38
class Predicate;
39
} // namespace paimon
40
41
namespace doris {
42
class RuntimeProfile;
43
class RuntimeState;
44
class SlotDescriptor;
45
} // namespace doris
46
47
namespace doris {
48
49
class Block;
50
51
class PaimonCppReader : public GenericReader {
52
    ENABLE_FACTORY_CREATOR(PaimonCppReader);
53
54
public:
55
    PaimonCppReader(const std::vector<SlotDescriptor*>& file_slot_descs, RuntimeState* state,
56
                    RuntimeProfile* profile, const TFileRangeDesc& range,
57
                    const TFileScanRangeParams* range_params);
58
    ~PaimonCppReader() override;
59
60
    Status init_reader();
61
    Status _do_get_next_block(Block* block, size_t* read_rows, bool* eof) override;
62
    Status _get_columns_impl(std::unordered_map<std::string, DataTypePtr>* name_to_type) override;
63
    Status close() override;
64
0
    void set_predicate(std::shared_ptr<paimon::Predicate> predicate) {
65
0
        _predicate = std::move(predicate);
66
0
    }
67
68
protected:
69
    Status on_before_init_reader(ReaderInitContext* ctx) override;
70
    Status on_after_read_block(Block* block, size_t* read_rows) override;
71
0
    Status _do_init_reader(ReaderInitContext* /*ctx*/) override { return init_reader(); }
72
73
private:
74
    Status _fill_partition_columns(Block* block, size_t num_rows);
75
    Status _init_paimon_reader();
76
    Status _decode_split(std::shared_ptr<paimon::Split>* split);
77
    // Resolve paimon table root path for schema/manifest lookup.
78
    std::optional<std::string> _resolve_table_path() const;
79
    std::vector<std::string> _build_read_columns() const;
80
    std::map<std::string, std::string> _build_options() const;
81
82
    const std::vector<SlotDescriptor*>& _file_slot_descs;
83
    RuntimeState* _state = nullptr;
84
    [[maybe_unused]] RuntimeProfile* _profile = nullptr;
85
    const TFileRangeDesc& _range;
86
    const TFileScanRangeParams* _range_params = nullptr;
87
88
    std::shared_ptr<paimon::Split> _split;
89
    std::unique_ptr<paimon::TableRead> _table_read;
90
    std::unique_ptr<paimon::BatchReader> _batch_reader;
91
    std::shared_ptr<paimon::Predicate> _predicate;
92
93
    std::unordered_map<std::string, std::tuple<std::string, const SlotDescriptor*>>
94
            _partition_values;
95
    std::unordered_map<std::string, bool> _partition_value_is_null;
96
    std::unordered_map<std::string, uint32_t> _col_name_to_block_idx;
97
    int64_t _remaining_table_level_row_count = -1;
98
    cctz::time_zone _ctzz;
99
};
100
101
} // namespace doris