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