Coverage Report

Created: 2026-03-16 16:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/io/fs/file_reader.cpp
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
#include "io/fs/file_reader.h"
19
20
#include <bthread/bthread.h>
21
#include <glog/logging.h>
22
23
#include "io/cache/cached_remote_file_reader.h"
24
#include "io/fs/file_system.h"
25
#include "util/async_io.h"
26
27
namespace doris::io {
28
29
const std::string FileReader::VIRTUAL_REMOTE_DATA_DIR = "virtual_remote_data_dir";
30
31
Status FileReader::read_at(size_t offset, Slice result, size_t* bytes_read,
32
353k
                           const IOContext* io_ctx) {
33
353k
    DCHECK(bthread_self() == 0);
34
353k
    Status st = read_at_impl(offset, result, bytes_read, io_ctx);
35
353k
    if (!st) {
36
7
        LOG(WARNING) << st;
37
7
    }
38
353k
    return st;
39
353k
}
40
41
Result<FileReaderSPtr> create_cached_file_reader(FileReaderSPtr raw_reader,
42
1.00k
                                                 const FileReaderOptions& opts) {
43
1.00k
    switch (opts.cache_type) {
44
1
    case io::FileCachePolicy::NO_CACHE:
45
1
        return raw_reader;
46
1.00k
    case FileCachePolicy::FILE_BLOCK_CACHE:
47
1.00k
        return std::make_shared<CachedRemoteFileReader>(std::move(raw_reader), opts);
48
0
    default:
49
0
        return ResultError(Status::InternalError("Unknown cache type: {}", opts.cache_type));
50
1.00k
    }
51
1.00k
}
52
53
} // namespace doris::io