Coverage Report

Created: 2026-07-13 21:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format_v2/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 <utility>
21
22
#include "format_v2/table_reader.h"
23
24
namespace doris {
25
struct DeleteFileDesc;
26
}
27
namespace doris::format::paimon {
28
29
class PaimonReader final : public format::TableReader {
30
public:
31
    ENABLE_FACTORY_CREATOR(PaimonReader);
32
6
    ~PaimonReader() final = default;
33
    Status prepare_split(const format::SplitReadOptions& options) override;
34
35
#ifdef BE_TEST
36
3
    void TEST_set_scan_params(TFileScanRangeParams* params) { _scan_params = params; }
37
4
    format::TableColumnMappingMode TEST_mapping_mode() const { return mapping_mode(); }
38
2
    Status TEST_annotate_file_schema(std::vector<format::ColumnDefinition>* file_schema) {
39
2
        return annotate_file_schema(file_schema);
40
2
    }
41
    Status TEST_parse_deletion_vector_file(const TTableFormatFileDesc& t_desc, DeleteFileDesc* desc,
42
3
                                           bool* has_delete_file) {
43
3
        return _parse_deletion_vector_file(t_desc, desc, has_delete_file);
44
3
    }
45
#endif
46
47
protected:
48
    format::TableColumnMappingMode mapping_mode() const override;
49
    Status annotate_file_schema(std::vector<format::ColumnDefinition>* file_schema) override;
50
51
    Status _parse_deletion_vector_file(const TTableFormatFileDesc& t_desc, DeleteFileDesc* desc,
52
                                       bool* has_delete_file) override;
53
54
private:
55
    int64_t _split_schema_id = -1;
56
};
57
58
// Paimon scans can contain both native data-file splits and serialized JNI splits in the same
59
// SplitSource. FileScannerV2 owns one table reader for the scanner lifetime, so this reader keeps
60
// native and JNI child readers internally and dispatches each split to the matching child reader.
61
class PaimonHybridReader final : public format::TableReader {
62
public:
63
2
    ~PaimonHybridReader() override = default;
64
65
    Status init(format::TableReadOptions&& options) override;
66
    Status prepare_split(const format::SplitReadOptions& options) override;
67
    Status get_block(Block* block, bool* eos) override;
68
    bool current_split_pruned() const override;
69
    Status abort_split() override;
70
    Status close() override;
71
    void set_batch_size(size_t batch_size) override;
72
73
#ifdef BE_TEST
74
3
    static bool TEST_is_jni_split(const TFileRangeDesc& range) { return _is_jni_split(range); }
75
    static Status TEST_to_file_format(const TFileRangeDesc& range,
76
3
                                      format::FileFormat* file_format) {
77
3
        return _to_file_format(range, file_format);
78
3
    }
79
1
    void TEST_install_batch_size_children() {
80
1
        _native_reader = std::make_unique<format::TableReader>();
81
1
        _jni_reader = std::make_unique<format::TableReader>();
82
1
    }
83
1
    std::pair<size_t, size_t> TEST_child_batch_sizes() const {
84
1
        return {_native_reader->TEST_batch_size(), _jni_reader->TEST_batch_size()};
85
1
    }
86
#endif
87
88
private:
89
    Status _ensure_current_split_reader(const format::SplitReadOptions& options);
90
    Status _init_child_reader(format::TableReader* reader, format::FileFormat file_format);
91
    Status _clone_conjuncts(VExprContextSPtrs* conjuncts) const;
92
    static bool _is_jni_split(const TFileRangeDesc& range);
93
    static Status _to_file_format(const TFileRangeDesc& range, format::FileFormat* file_format);
94
95
    std::unique_ptr<format::TableReader> _native_reader; // handle parquet/orc native splits
96
    std::unique_ptr<format::TableReader> _jni_reader;    // handle serialized JNI splits
97
    format::TableReader* _current_split_reader = nullptr;
98
};
99
100
} // namespace doris::format::paimon