Project
Loading...
Searching...
No Matches
LocalByteSource.h
Go to the documentation of this file.
1// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_FRAMEWORK_AODNATIVE_LOCALBYTESOURCE_H_
13#define O2_FRAMEWORK_AODNATIVE_LOCALBYTESOURCE_H_
14
16#include <atomic>
17
18namespace o2::aod::native
19{
20
24{
25 public:
26 LocalByteSource(std::string path, Options const& options);
27 ~LocalByteSource() override;
28 uint64_t size() const override { return mSize; }
29 void readInto(uint64_t off, size_t len, void* dst) override;
30 void readvInto(std::span<ReadRequest> requests) override;
31 std::span<const uint8_t> tryMap(uint64_t off, size_t len) override;
32 bool canMap() const override { return mMap != nullptr; }
33 void willNeed(uint64_t off, size_t len) override;
34 void dontNeed(uint64_t off, size_t len) override;
35 uint64_t bytesRead() const override { return mBytesRead.load(std::memory_order_relaxed); }
36 uint64_t readCalls() const override { return mReadCalls.load(std::memory_order_relaxed); }
37 std::string url() const override { return mPath; }
38
39 private:
40 void checkRange(uint64_t off, size_t len) const;
41 void advise(uint64_t off, size_t len, int advice);
42
43 std::string mPath;
44 int mFd = -1;
45 uint64_t mSize = 0;
46 uint8_t const* mMap = nullptr;
47 std::atomic<uint64_t> mBytesRead = 0;
48 std::atomic<uint64_t> mReadCalls = 0;
49};
50
51} // namespace o2::aod::native
52
53#endif // O2_FRAMEWORK_AODNATIVE_LOCALBYTESOURCE_H_
void dontNeed(uint64_t off, size_t len) override
void willNeed(uint64_t off, size_t len) override
Hints that a range will be needed soon, or is no longer needed.
void readvInto(std::span< ReadRequest > requests) override
std::string url() const override
std::span< const uint8_t > tryMap(uint64_t off, size_t len) override
A view of the bytes without copying them, if the backend can provide it.
bool canMap() const override
Whether tryMap() provides every range, so that nothing needs reading.
uint64_t size() const override
void readInto(uint64_t off, size_t len, void *dst) override
Throws IoError, or CorruptData when the range is past the end of the file.
uint64_t bytesRead() const override
uint64_t readCalls() const override
GLenum GLenum dst
Definition glcorearb.h:1767
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLenum GLenum GLsizei len
Definition glcorearb.h:4232