Coverage Report

Created: 2026-06-27 16:55

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