YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/util/file_system_posix.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_UTIL_FILE_SYSTEM_POSIX_H
15
#define YB_UTIL_FILE_SYSTEM_POSIX_H
16
17
#include "yb/util/file_system.h"
18
19
namespace yb {
20
21
#if defined(__linux__)
22
size_t GetUniqueIdFromFile(int fd, uint8_t* id);
23
#endif // __linux__
24
25
class PosixSequentialFile : public SequentialFile {
26
 public:
27
  PosixSequentialFile(const std::string& fname, FILE* f, const FileSystemOptions& options);
28
  virtual ~PosixSequentialFile();
29
30
  CHECKED_STATUS Read(size_t n, Slice* result, uint8_t* scratch) override;
31
  CHECKED_STATUS Skip(uint64_t n) override;
32
  CHECKED_STATUS InvalidateCache(size_t offset, size_t length) override;
33
34
0
  const std::string& filename() const override { return filename_; }
35
36
 private:
37
  std::string filename_;
38
  FILE* file_;
39
  int fd_;
40
  bool use_os_buffer_;
41
};
42
43
// pread() based random-access file.
44
class PosixRandomAccessFile : public RandomAccessFile {
45
 public:
46
  PosixRandomAccessFile(const std::string& fname, int fd,
47
                        const FileSystemOptions& options);
48
  virtual ~PosixRandomAccessFile();
49
50
  virtual CHECKED_STATUS Read(uint64_t offset, size_t n, Slice* result,
51
                      uint8_t* scratch) const override;
52
53
  Result<uint64_t> Size() const override;
54
55
  Result<uint64_t> INode() const override;
56
57
116
  const std::string& filename() const override { return filename_; }
58
59
  size_t memory_footprint() const override;
60
61
#ifdef __linux__
62
  virtual size_t GetUniqueId(char* id) const override;
63
#endif
64
  virtual void Hint(AccessPattern pattern) override;
65
  virtual CHECKED_STATUS InvalidateCache(size_t offset, size_t length) override;
66
67
 private:
68
  std::string filename_;
69
  int fd_;
70
  bool use_os_buffer_;
71
};
72
73
} // namespace yb
74
75
#endif  // YB_UTIL_FILE_SYSTEM_POSIX_H