be/src/io/fs/tracing_file_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 | | #include "common/status.h" |
20 | | #include "io/fs/file_reader.h" |
21 | | #include "runtime/runtime_profile.h" |
22 | | |
23 | | namespace doris { |
24 | | |
25 | | namespace io { |
26 | | |
27 | | class TracingFileReader : public FileReader { |
28 | | public: |
29 | | TracingFileReader(doris::io::FileReaderSPtr inner, FileReaderStats* stats) |
30 | 1.23k | : _inner(std::move(inner)), _stats(stats) {} |
31 | | |
32 | | Status read_at_impl(size_t offset, Slice result, size_t* bytes_read, |
33 | 5.54k | const IOContext* io_ctx) override { |
34 | 5.54k | SCOPED_RAW_TIMER(&_stats->read_time_ns); |
35 | 5.54k | Status st = _inner->read_at(offset, result, bytes_read, io_ctx); |
36 | 5.54k | _stats->read_calls++; |
37 | 5.54k | _stats->read_bytes += *bytes_read; |
38 | 5.54k | return st; |
39 | 5.54k | } |
40 | | |
41 | 286 | Status close() override { return _inner->close(); } |
42 | 1.17k | const doris::io::Path& path() const override { return _inner->path(); } |
43 | 1.54k | size_t size() const override { return _inner->size(); } |
44 | 0 | bool closed() const override { return _inner->closed(); } |
45 | 0 | const std::string& get_data_dir_path() override { return _inner->get_data_dir_path(); } |
46 | | |
47 | 0 | void _collect_profile_at_runtime() override { return _inner->collect_profile_at_runtime(); } |
48 | 212 | void _collect_profile_before_close() override { return _inner->collect_profile_before_close(); } |
49 | | |
50 | 1.05k | int64_t mtime() const override { return _inner->mtime(); } |
51 | | |
52 | 0 | FileReaderStats* stats() const { return _stats; } |
53 | 1.05k | doris::io::FileReaderSPtr inner_reader() { return _inner; } |
54 | | |
55 | | private: |
56 | | doris::io::FileReaderSPtr _inner; |
57 | | FileReaderStats* _stats; |
58 | | }; |
59 | | |
60 | | } // namespace io |
61 | | } // namespace doris |