/root/doris/be/src/io/io_common.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/Types_types.h> |
21 | | |
22 | | namespace doris { |
23 | | |
24 | | enum class ReaderType : uint8_t { |
25 | | READER_QUERY = 0, |
26 | | READER_ALTER_TABLE = 1, |
27 | | READER_BASE_COMPACTION = 2, |
28 | | READER_CUMULATIVE_COMPACTION = 3, |
29 | | READER_CHECKSUM = 4, |
30 | | READER_COLD_DATA_COMPACTION = 5, |
31 | | READER_SEGMENT_COMPACTION = 6, |
32 | | READER_FULL_COMPACTION = 7, |
33 | | UNKNOWN = 8 |
34 | | }; |
35 | | |
36 | | namespace io { |
37 | | |
38 | | struct FileReaderStats { |
39 | | size_t read_calls = 0; |
40 | | size_t read_bytes = 0; |
41 | | int64_t read_time_ns = 0; |
42 | | size_t read_rows = 0; |
43 | | }; |
44 | | |
45 | | struct FileCacheStatistics { |
46 | | int64_t num_local_io_total = 0; |
47 | | int64_t num_remote_io_total = 0; |
48 | | int64_t num_peer_io_total = 0; |
49 | | int64_t local_io_timer = 0; |
50 | | int64_t bytes_read_from_local = 0; |
51 | | int64_t bytes_read_from_remote = 0; |
52 | | int64_t bytes_read_from_peer = 0; |
53 | | int64_t remote_io_timer = 0; |
54 | | int64_t peer_io_timer = 0; |
55 | | int64_t remote_wait_timer = 0; |
56 | | int64_t write_cache_io_timer = 0; |
57 | | int64_t bytes_write_into_cache = 0; |
58 | | int64_t num_skip_cache_io_total = 0; |
59 | | int64_t read_cache_file_directly_timer = 0; |
60 | | int64_t cache_get_or_set_timer = 0; |
61 | | int64_t lock_wait_timer = 0; |
62 | | int64_t get_timer = 0; |
63 | | int64_t set_timer = 0; |
64 | | |
65 | | int64_t inverted_index_num_local_io_total = 0; |
66 | | int64_t inverted_index_num_remote_io_total = 0; |
67 | | int64_t inverted_index_num_peer_io_total = 0; |
68 | | int64_t inverted_index_bytes_read_from_local = 0; |
69 | | int64_t inverted_index_bytes_read_from_remote = 0; |
70 | | int64_t inverted_index_bytes_read_from_peer = 0; |
71 | | int64_t inverted_index_local_io_timer = 0; |
72 | | int64_t inverted_index_remote_io_timer = 0; |
73 | | int64_t inverted_index_peer_io_timer = 0; |
74 | | int64_t inverted_index_io_timer = 0; |
75 | | |
76 | | int64_t segment_footer_index_num_local_io_total = 0; |
77 | | int64_t segment_footer_index_num_remote_io_total = 0; |
78 | | int64_t segment_footer_index_num_peer_io_total = 0; |
79 | | int64_t segment_footer_index_bytes_read_from_local = 0; |
80 | | int64_t segment_footer_index_bytes_read_from_remote = 0; |
81 | | int64_t segment_footer_index_bytes_read_from_peer = 0; |
82 | | int64_t segment_footer_index_local_io_timer = 0; |
83 | | int64_t segment_footer_index_remote_io_timer = 0; |
84 | | int64_t segment_footer_index_peer_io_timer = 0; |
85 | | |
86 | 29 | void merge_from(const FileCacheStatistics& other) { |
87 | 29 | num_local_io_total += other.num_local_io_total; |
88 | 29 | num_remote_io_total += other.num_remote_io_total; |
89 | 29 | num_peer_io_total += other.num_peer_io_total; |
90 | 29 | local_io_timer += other.local_io_timer; |
91 | 29 | bytes_read_from_local += other.bytes_read_from_local; |
92 | 29 | bytes_read_from_remote += other.bytes_read_from_remote; |
93 | 29 | bytes_read_from_peer += other.bytes_read_from_peer; |
94 | 29 | remote_io_timer += other.remote_io_timer; |
95 | 29 | peer_io_timer += other.peer_io_timer; |
96 | 29 | remote_wait_timer += other.remote_wait_timer; |
97 | 29 | write_cache_io_timer += other.write_cache_io_timer; |
98 | 29 | bytes_write_into_cache += other.bytes_write_into_cache; |
99 | 29 | num_skip_cache_io_total += other.num_skip_cache_io_total; |
100 | 29 | read_cache_file_directly_timer += other.read_cache_file_directly_timer; |
101 | 29 | cache_get_or_set_timer += other.cache_get_or_set_timer; |
102 | 29 | lock_wait_timer += other.lock_wait_timer; |
103 | 29 | get_timer += other.get_timer; |
104 | 29 | set_timer += other.set_timer; |
105 | 29 | inverted_index_num_local_io_total += other.inverted_index_num_local_io_total; |
106 | 29 | inverted_index_num_remote_io_total += other.inverted_index_num_remote_io_total; |
107 | 29 | inverted_index_num_peer_io_total += other.inverted_index_num_peer_io_total; |
108 | 29 | inverted_index_bytes_read_from_local += other.inverted_index_bytes_read_from_local; |
109 | 29 | inverted_index_bytes_read_from_remote += other.inverted_index_bytes_read_from_remote; |
110 | 29 | inverted_index_bytes_read_from_peer += other.inverted_index_bytes_read_from_peer; |
111 | 29 | inverted_index_local_io_timer += other.inverted_index_local_io_timer; |
112 | 29 | inverted_index_remote_io_timer += other.inverted_index_remote_io_timer; |
113 | 29 | inverted_index_peer_io_timer += other.inverted_index_peer_io_timer; |
114 | 29 | inverted_index_io_timer += other.inverted_index_io_timer; |
115 | 29 | segment_footer_index_num_local_io_total += other.segment_footer_index_num_local_io_total; |
116 | 29 | segment_footer_index_num_remote_io_total += other.segment_footer_index_num_remote_io_total; |
117 | 29 | segment_footer_index_num_peer_io_total += other.segment_footer_index_num_peer_io_total; |
118 | 29 | segment_footer_index_bytes_read_from_local += |
119 | 29 | other.segment_footer_index_bytes_read_from_local; |
120 | 29 | segment_footer_index_bytes_read_from_remote += |
121 | 29 | other.segment_footer_index_bytes_read_from_remote; |
122 | 29 | segment_footer_index_bytes_read_from_peer += |
123 | 29 | other.segment_footer_index_bytes_read_from_peer; |
124 | 29 | segment_footer_index_local_io_timer += other.segment_footer_index_local_io_timer; |
125 | 29 | segment_footer_index_remote_io_timer += other.segment_footer_index_remote_io_timer; |
126 | 29 | segment_footer_index_peer_io_timer += other.segment_footer_index_peer_io_timer; |
127 | 29 | } |
128 | | }; |
129 | | |
130 | | struct IOContext { |
131 | | ReaderType reader_type = ReaderType::UNKNOWN; |
132 | | // FIXME(plat1ko): Seems `is_disposable` can be inferred from the `reader_type`? |
133 | | bool is_disposable = false; |
134 | | bool is_index_data = false; |
135 | | bool read_file_cache = true; |
136 | | // TODO(lightman): use following member variables to control file cache |
137 | | bool is_persistent = false; |
138 | | // stop reader when reading, used in some interrupted operations |
139 | | bool should_stop = false; |
140 | | int64_t expiration_time = 0; |
141 | | const TUniqueId* query_id = nullptr; // Ref |
142 | | FileCacheStatistics* file_cache_stats = nullptr; // Ref |
143 | | FileReaderStats* file_reader_stats = nullptr; // Ref |
144 | | bool is_inverted_index = false; |
145 | | // if is_dryrun, read IO will download data to cache but return no data to reader |
146 | | // useful to skip cache data read from local disk to accelarate warm up |
147 | | bool is_dryrun = false; |
148 | | // if `is_warmup` == true, this I/O request is from a warm up task |
149 | | bool is_warmup {false}; |
150 | | int64_t condition_cache_filtered_rows = 0; |
151 | | // Rows removed by file-local predicate conjuncts inside FileReader/TableReader. Scanner-level |
152 | | // output filtering already records its own unselected rows; this counter carries the rows that |
153 | | // were filtered before the block returned to Scanner. |
154 | | int64_t predicate_filtered_rows = 0; |
155 | | }; |
156 | | |
157 | | } // namespace io |
158 | | } // namespace doris |