Coverage Report

Created: 2026-07-09 16:31

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
              _kv_cache(kv_cache) {
53
        _init_paimon_profile();
54
    }
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
3.84k
            : OrcReader(profile, state, params, range, batch_size, ctz, std::move(io_ctx_holder),
61
3.84k
                        meta_cache, enable_lazy_mat),
62
3.84k
              _kv_cache(kv_cache) {
63
3.84k
        _init_paimon_profile();
64
3.84k
    }
65
3.85k
    ~PaimonOrcReader() final = default;
66
67
    Status TEST_init_deletion_vector() { return _init_deletion_vector(); }
68
69
protected:
70
    Status on_before_init_reader(ReaderInitContext* ctx) override;
71
72
    Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
73
74
private:
75
    void _init_paimon_profile();
76
    Status _init_deletion_vector();
77
78
    struct PaimonProfile {
79
        RuntimeProfile::Counter* num_delete_rows = nullptr;
80
        RuntimeProfile::Counter* delete_files_read_time = nullptr;
81
        RuntimeProfile::Counter* parse_deletion_vector_time = nullptr;
82
    };
83
84
    const std::vector<int64_t>* _delete_rows = nullptr;
85
    ShardedKVCache* _kv_cache;
86
    PaimonProfile _paimon_profile;
87
};
88
89
// PaimonParquetReader: directly inherits ParquetReader (no composition wrapping).
90
class PaimonParquetReader final : public ParquetReader, public TableSchemaChangeHelper {
91
public:
92
    ENABLE_FACTORY_CREATOR(PaimonParquetReader);
93
    PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params,
94
                        const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz,
95
                        ShardedKVCache* kv_cache, io::IOContext* io_ctx, RuntimeState* state,
96
                        FileMetaCache* meta_cache = nullptr, bool enable_lazy_mat = true)
97
            : ParquetReader(profile, params, range, batch_size, ctz, io_ctx, state, meta_cache,
98
                            enable_lazy_mat),
99
              _kv_cache(kv_cache) {
100
        _init_paimon_profile();
101
    }
102
    PaimonParquetReader(RuntimeProfile* profile, const TFileScanRangeParams& params,
103
                        const TFileRangeDesc& range, size_t batch_size, const cctz::time_zone* ctz,
104
                        ShardedKVCache* kv_cache, std::shared_ptr<io::IOContext> io_ctx_holder,
105
                        RuntimeState* state, FileMetaCache* meta_cache = nullptr,
106
                        bool enable_lazy_mat = true)
107
43
            : ParquetReader(profile, params, range, batch_size, ctz, std::move(io_ctx_holder),
108
43
                            state, meta_cache, enable_lazy_mat),
109
43
              _kv_cache(kv_cache) {
110
43
        _init_paimon_profile();
111
43
    }
112
44
    ~PaimonParquetReader() final = default;
113
114
    Status TEST_init_deletion_vector() { return _init_deletion_vector(); }
115
116
protected:
117
    Status on_before_init_reader(ReaderInitContext* ctx) override;
118
119
    Status on_after_init_reader(ReaderInitContext* /*ctx*/) override;
120
121
private:
122
    void _init_paimon_profile();
123
    Status _init_deletion_vector();
124
125
    struct PaimonProfile {
126
        RuntimeProfile::Counter* num_delete_rows = nullptr;
127
        RuntimeProfile::Counter* delete_files_read_time = nullptr;
128
        RuntimeProfile::Counter* parse_deletion_vector_time = nullptr;
129
    };
130
131
    const std::vector<int64_t>* _delete_rows = nullptr;
132
    ShardedKVCache* _kv_cache;
133
    PaimonProfile _paimon_profile;
134
};
135
136
} // namespace doris