Project
Loading...
Searching...
No Matches
ByteSource.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_BYTESOURCE_H_
13#define O2_FRAMEWORK_AODNATIVE_BYTESOURCE_H_
14
15#include <cstddef>
16#include <cstdint>
17#include <memory>
18#include <span>
19#include <string>
20
21namespace o2::aod::native
22{
23
26struct Options {
27 enum struct LocalIO { MMap,
28 PRead };
29 enum struct RemoteIO { Prefetch,
30 Stream };
31 enum struct HttpVersion { Auto,
32 Http1_1,
33 Http2 };
36 int threads = 1;
38 size_t coalesceGap = 64 * 1024;
39 double spanFraction = 0.8;
41 size_t streamWindowBytes = 2 * 1024 * 1024;
44};
45
47 uint64_t offset;
48 size_t length;
49 void* dst;
50};
51
56{
57 public:
58 virtual ~ByteSource();
59 virtual uint64_t size() const = 0;
61 virtual void readInto(uint64_t off, size_t len, void* dst) = 0;
62 virtual void readvInto(std::span<ReadRequest> requests) = 0;
64 virtual std::span<const uint8_t> tryMap(uint64_t off, size_t len) { return {}; }
66 virtual bool canMap() const { return false; }
68 virtual bool isRemote() const { return false; }
70 virtual void willNeed(uint64_t off, size_t len) {}
71 virtual void dontNeed(uint64_t off, size_t len) {}
72 virtual uint64_t bytesRead() const = 0;
73 virtual uint64_t readCalls() const = 0;
74 virtual std::string url() const = 0;
75 static std::unique_ptr<ByteSource> open(std::string url, const Options&);
76};
77
78} // namespace o2::aod::native
79
80#endif // O2_FRAMEWORK_AODNATIVE_BYTESOURCE_H_
static std::unique_ptr< ByteSource > open(std::string url, const Options &)
virtual std::string url() const =0
virtual uint64_t bytesRead() const =0
virtual uint64_t size() const =0
virtual bool isRemote() const
Whether each read is a network round trip, worth hiding behind decoding.
Definition ByteSource.h:68
virtual bool canMap() const
Whether tryMap() provides every range, so that nothing needs reading.
Definition ByteSource.h:66
virtual void readInto(uint64_t off, size_t len, void *dst)=0
Throws IoError, or CorruptData when the range is past the end of the file.
virtual void dontNeed(uint64_t off, size_t len)
Definition ByteSource.h:71
virtual uint64_t readCalls() const =0
virtual void willNeed(uint64_t off, size_t len)
Hints that a range will be needed soon, or is no longer needed.
Definition ByteSource.h:70
virtual std::span< const uint8_t > tryMap(uint64_t off, size_t len)
A view of the bytes without copying them, if the backend can provide it.
Definition ByteSource.h:64
virtual void readvInto(std::span< ReadRequest > requests)=0
GLenum GLenum dst
Definition glcorearb.h:1767
GLenum GLenum GLsizei len
Definition glcorearb.h:4232