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 <butil/macros.h> |
21 | | #include <gen_cpp/AgentService_types.h> |
22 | | #include <gen_cpp/Exprs_types.h> |
23 | | |
24 | | #include <cstdint> |
25 | | #include <memory> |
26 | | #include <string> |
27 | | #include <vector> |
28 | | |
29 | | #include "common/factory_creator.h" |
30 | | #include "common/object_pool.h" |
31 | | #include "common/status.h" |
32 | | #include "core/block/block.h" |
33 | | #include "runtime/runtime_state.h" |
34 | | #include "storage/olap_common.h" |
35 | | #include "storage/olap_scan_common.h" |
36 | | #include "storage/rowset/pending_rowset_helper.h" |
37 | | #include "storage/rowset/rowset_fwd.h" |
38 | | #include "storage/tablet/tablet_fwd.h" |
39 | | |
40 | | namespace doris { |
41 | | |
42 | | namespace format { |
43 | | class LoadTableReader; |
44 | | } |
45 | | |
46 | | class DescriptorTbl; |
47 | | class RuntimeProfile; |
48 | | class TBrokerScanRange; |
49 | | class TDescriptorTable; |
50 | | class TTabletInfo; |
51 | | class StorageEngine; |
52 | | |
53 | | class VExprContext; |
54 | | |
55 | | class PushHandler { |
56 | | public: |
57 | 0 | PushHandler(StorageEngine& engine) : _engine(engine) {} |
58 | 0 | ~PushHandler() = default; |
59 | | |
60 | | // Load local data file into specified tablet. |
61 | | Status process_streaming_ingestion(TabletSharedPtr tablet, const TPushReq& request, |
62 | | PushType push_type, |
63 | | std::vector<TTabletInfo>* tablet_info_vec); |
64 | | |
65 | 0 | int64_t write_bytes() const { return _write_bytes; } |
66 | 0 | int64_t write_rows() const { return _write_rows; } |
67 | | |
68 | | private: |
69 | | Status _convert_v2(TabletSharedPtr cur_tablet, RowsetSharedPtr* cur_rowset, |
70 | | TabletSchemaSPtr tablet_schema, PushType push_type); |
71 | | |
72 | | Status _do_streaming_ingestion(TabletSharedPtr tablet, const TPushReq& request, |
73 | | PushType push_type, std::vector<TTabletInfo>* tablet_info_vec); |
74 | | |
75 | | StorageEngine& _engine; |
76 | | |
77 | | // mainly tablet_id, version and delta file path |
78 | | TPushReq _request; |
79 | | |
80 | | ObjectPool _pool; |
81 | | DescriptorTbl* _desc_tbl = nullptr; |
82 | | |
83 | | int64_t _write_bytes = 0; |
84 | | int64_t _write_rows = 0; |
85 | | PendingRowsetGuard _pending_rs_guard; |
86 | | }; |
87 | | |
88 | | class PushBrokerReader { |
89 | | ENABLE_FACTORY_CREATOR(PushBrokerReader); |
90 | | |
91 | | public: |
92 | | PushBrokerReader(const TBrokerScanRange& t_scan_range, const TDescriptorTable& t_desc_tbl); |
93 | | ~PushBrokerReader(); |
94 | | Status init(); |
95 | | Status next(Block* block); |
96 | | void print_profile(); |
97 | | |
98 | | Status close(); |
99 | 24 | bool eof() const { return _eof; } |
100 | | |
101 | | private: |
102 | | Status _get_next_reader(); |
103 | | |
104 | | bool _ready; |
105 | | bool _eof; |
106 | | size_t _next_range; |
107 | | const TDescriptorTable& _t_desc_tbl; |
108 | | const TupleDescriptor* _dest_tuple_desc = nullptr; |
109 | | std::unique_ptr<RuntimeState> _runtime_state; |
110 | | RuntimeProfile* _runtime_profile = nullptr; |
111 | | std::unique_ptr<format::LoadTableReader> _cur_reader; |
112 | | bool _cur_reader_eof; |
113 | | const TBrokerScanRangeParams& _params; |
114 | | const std::vector<TBrokerRangeDesc>& _ranges; |
115 | | TFileScanRangeParams _file_params; |
116 | | std::vector<TFileRangeDesc> _file_ranges; |
117 | | std::unique_ptr<io::FileCacheStatistics> _file_cache_statistics; |
118 | | std::unique_ptr<io::FileReaderStats> _file_reader_stats; |
119 | | std::shared_ptr<io::IOContext> _io_ctx; |
120 | | }; |
121 | | |
122 | | } // namespace doris |