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 <functional>
18#include <memory>
19#include <span>
20#include <string>
21#include <vector>
22
23namespace o2::aod::native
24{
25
28struct Options {
29 enum struct LocalIO { MMap,
30 PRead };
31 enum struct RemoteIO { Prefetch,
32 Stream };
33 enum struct HttpVersion { Auto,
34 Http1_1,
35 Http2 };
38 int threads = 1;
40 size_t coalesceGap = 64 * 1024;
44 static constexpr size_t kAutoBufferBudget = SIZE_MAX;
46 double spanFraction = 0.8;
48 size_t streamWindowBytes = 2 * 1024 * 1024;
55 int readRetries = 2;
56 double retryDelay = 2.0;
60 size_t remoteInFlightBytes = 32 * 1024 * 1024;
61};
62
65struct Replica {
66 std::string url;
67 std::string label;
68};
69
72 size_t length;
73 void* dst;
74};
75
80{
81 public:
82 virtual ~ByteSource();
83 virtual uint64_t size() const = 0;
85 virtual void readInto(uint64_t off, size_t len, void* dst) = 0;
86 virtual void readvInto(std::span<ReadRequest> requests) = 0;
88 virtual std::span<const uint8_t> tryMap(uint64_t off, size_t len) { return {}; }
90 virtual bool canMap() const { return false; }
92 virtual bool isRemote() const { return false; }
94 virtual void willNeed(uint64_t off, size_t len) {}
95 virtual void dontNeed(uint64_t off, size_t len) {}
96 virtual uint64_t bytesRead() const = 0;
97 virtual uint64_t readCalls() const = 0;
98 virtual std::string url() const = 0;
100 virtual std::string replicaLabel() const { return {}; }
101 static std::unique_ptr<ByteSource> open(std::string url, const Options&);
106 static std::unique_ptr<ByteSource> openReplicas(std::vector<Replica> replicas, const Options&,
107 std::function<void(std::string const&)> log = {});
108};
109
110} // namespace o2::aod::native
111
112#endif // O2_FRAMEWORK_AODNATIVE_BYTESOURCE_H_
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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:92
static std::unique_ptr< ByteSource > openReplicas(std::vector< Replica > replicas, const Options &, std::function< void(std::string const &)> log={})
virtual std::string replicaLabel() const
The label of the replica being read, for a source opened with openReplicas().
Definition ByteSource.h:100
virtual bool canMap() const
Whether tryMap() provides every range, so that nothing needs reading.
Definition ByteSource.h:90
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:95
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:94
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:88
virtual void readvInto(std::span< ReadRequest > requests)=0
GLenum GLenum dst
Definition glcorearb.h:1767
GLenum GLenum GLsizei len
Definition glcorearb.h:4232
static constexpr size_t kAutoBufferBudget
Definition ByteSource.h:44