Coverage Report

Created: 2026-07-07 17:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/paimon_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 <gen_cpp/PlanNodes_types.h>
21
22
#include <memory>
23
#include <string>
24
#include <utility>
25
#include <vector>
26
27
#include "common/status.h"
28
#include "format/orc/vorc_reader.h"
29
#include "format/parquet/vparquet_reader.h"
30
#include "format/table/table_schema_change_helper.h"
31
32
namespace doris {
33
class ShardedKVCache;
34
35
std::string build_paimon_deletion_vector_cache_key(const TPaimonDeletionFileDesc& deletion_file);
36
37
Status decode_paimon_deletion_vector_buffer(const char* buf, size_t buffer_size,
38
                                            std::vector<int64_t>* delete_rows);
39
40
// PaimonOrcReader: directly inherits OrcReader (no composition wrapping).
41
// Schema mapping in on_before_init_reader, deletion vector reading in on_after_init_reader.
42
class PaimonOrcReader final : public OrcReader, public TableSchemaChangeHelper {
43
public:
44
    ENABLE_FACTORY_CREATOR(PaimonOrcReader);
45
    PaimonOrcReader(RuntimeProfile* profile, RuntimeState* state,
46
                    const TFileScanRangeParams& params, const TFileRangeDesc& range,
47
                    size_t batch_size, const std::string& ctz, ShardedKVCache* kv_cache,
48
                    io::IOContext* io_ctx, FileMetaCache* meta_cache = nullptr,
49
                    bool enable_lazy_mat = true)
50
            : OrcReader(profile, state, params, range, batch_size, ctz, io_ctx, meta_cache,
51
                        enable_lazy_mat),
52
0
              _kv_cache(kv_cache) {
53
0
        _init_paimon_profile();
54
0
    }
55
    PaimonOrcReader(RuntimeProfile* profile, RuntimeState* state,
56
                    const TFileScanRangeParams& params, const TFileRangeDesc& range,
57
                    size_t batch_size, const std::string& ctz, ShardedKVCache* kv_cache,
58
                    std::shared_ptr<io::IOContext> io_ctx_holder,
59
                    FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true)
60
0
            : OrcReader(profile, state, params, range, batch_size, ctz, std::move(io_ctx_holder),
61
0
                        meta_cache, enable_lazy_mat),
62
0
              _kv_cache(kv_cache) {
63
0
        _init_paimon_profile();
64
0
    }
65
0
    ~PaimonOrcReader() final = default;
66
67
protected:
68
    Status on_before_init_reader(ReaderInitContext* ctx) override;
69
70
    Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
71
72
private:
73
    void _init_paimon_profile();
74
    Status _init_deletion_vector();
75
76
    struct PaimonProfile {
77
        RuntimeProfile::Counter* num_delete_rows = nullptr;
78
        RuntimeProfile::Counter* delete_files_read_time = nullptr;
79
        RuntimeProfile::Counter* parse_deletion_vector_time = nullptr;
80
    };
81
82
    const std::vector<int64_t>* _delete_rows = nullptr;
83
    ShardedKVCache* _kv_cache;
84
    PaimonProfile _paimon_profile;
85
};
86
87
// PaimonParquetReader: directly inherits ParquetReader (no composition wrapping).
88
class PaimonParquetReader final : public ParquetReader, public TableSchemaChangeHelper {
89
public:
90
    ENABLE_FACTORY_CREATOR(PaimonParquetReader);
91
    PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params,
92
                        const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz,
93
                        ShardedKVCache* kv_cache, io::IOContext* io_ctx, RuntimeState* state,
94
                        FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true)
95
            : ParquetReader(profile, params, range, batch_size, ctz, io_ctx, state, meta_cache,
96
                            enable_lazy_mat),
97
0
              _kv_cache(kv_cache) {
98
0
        _init_paimon_profile();
99
0
    }
100
    PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params,
101
                        const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz,
102
                        ShardedKVCache* kv_cache, std::shared_ptr<io::IOContext> io_ctx_holder,
103
                        RuntimeState* state, FileMetaCache* meta_cache = nullptr,
104
                        bool enable_lazy_mat = true)
105
0
            : ParquetReader(profile, params, range, batch_size, ctz, std::move(io_ctx_holder),
106
0
                            state, meta_cache, enable_lazy_mat),
107
0
              _kv_cache(kv_cache) {
108
0
        _init_paimon_profile();
109
0
    }
110
0
    ~PaimonParquetReader() final = default;
111
112
protected:
113
    Status on_before_init_reader(ReaderInitContext* ctx) override;
114
115
    Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
116
117
private:
118
    void _init_paimon_profile();
119
    Status _init_deletion_vector();
120
121
    struct PaimonProfile {
122
        RuntimeProfile::Counter* num_delete_rows = nullptr;
123
        RuntimeProfile::Counter* delete_files_read_time = nullptr;
124
        RuntimeProfile::Counter* parse_deletion_vector_time = nullptr;
125
    };
126
127
    const std::vector<int64_t>* _delete_rows = nullptr;
128
    ShardedKVCache* _kv_cache;
129
    PaimonProfile _paimon_profile;
130
};
131
132
} // namespace doris