77 std::size_t
fMaxReqs =
static_cast<std::size_t
>(-1);
156 virtual std::unique_ptr<RRawFile>
Clone()
const = 0;
177 std::string
GetUrl()
const;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
The RRawFile provides read-only access to local and remote files.
virtual std::uint64_t GetSizeImpl()=0
Derived classes should return the file size.
std::uint64_t GetFilePos() const
Returns the offset for the next Read/Readln call.
static std::string GetLocation(std::string_view url)
Returns only the file location, e.g. "server/file" for http://server/file.
unsigned int fBlockBufferIdx
To be used modulo kNumBlockBuffers, points to the last used block buffer in fBlockBuffers.
RRawFile(std::string_view url, ROptions options)
RRawFile & operator=(const RRawFile &)=delete
std::uint64_t fFilePos
The current position in the file, which can be changed by Seek, Read, and Readln.
virtual void ReadVImpl(RIOVec *ioVec, unsigned int nReq)
By default implemented as a loop of ReadAt calls but can be overwritten, e.g. XRootD or DAVIX impleme...
static std::string GetTransport(std::string_view url)
Returns only the transport protocol in lower case, e.g. "http" for HTTP://server/file.
static constexpr unsigned int kNumBlockBuffers
Don't change without adapting ReadAt()
std::uint64_t GetSize()
Returns the size of the file.
bool fIsBuffering
Runtime switch to decide if reads are buffered or directly sent to ReadAtImpl()
static std::unique_ptr< RRawFile > Create(std::string_view url, ROptions options=ROptions())
Factory method that returns a suitable concrete implementation according to the transport in the url.
void Seek(std::uint64_t offset)
Change the cursor fFilePos.
static constexpr std::uint64_t kUnknownFileSize
Used as a marker that the file size was not yet queried.
virtual RIOVecLimits GetReadVLimits()
Returns the limits regarding the ioVec input to ReadV for this specific file; may open the file as a ...
ELineBreaks
kAuto detects the line break from the first line, kSystem picks the system's default
size_t ReadAt(void *buffer, size_t nbytes, std::uint64_t offset)
Buffered read from a random position.
bool fIsOpen
Files are opened lazily and only when required; the open state is kept by this flag.
virtual size_t ReadAtImpl(void *buffer, size_t nbytes, std::uint64_t offset)=0
Derived classes should implement low-level reading without buffering.
bool Readln(std::string &line)
Read the next line starting from the current value of fFilePos. Returns false if the end of the file ...
RRawFile(const RRawFile &)=delete
void EnsureOpen()
Open the file if not already open. Otherwise noop.
virtual void SetDiscourageReadAheadImpl(bool)
bool IsOpen() const
Once opened, the file stay open until destruction of the RRawFile object.
virtual std::unique_ptr< RRawFile > Clone() const =0
Create a new RawFile that accesses the same resource. The file pointer is reset to zero.
std::unique_ptr< unsigned char[]> fBufferSpace
Memory block containing the block buffers consecutively.
void ReadV(RIOVec *ioVec, unsigned int nReq)
Opens the file if necessary and calls ReadVImpl.
virtual void OpenImpl()=0
OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
size_t Read(void *buffer, size_t nbytes)
Read from fFilePos offset. Returns the actual number of bytes read.
void SetBuffering(bool value)
Turn on/off buffered reads; if off, all scalar read requests go directly to the implementation.
std::string GetUrl() const
Returns the url of the file.
std::uint64_t fFileSize
The cached file size.
RBlockBuffer fBlockBuffers[kNumBlockBuffers]
An active buffer and a shadow buffer, which supports "jumping back" to a previously used location in ...
virtual ~RRawFile()=default
std::uint64_t fBufferOffset
Where in the open file does fBuffer start.
RBlockBuffer(const RBlockBuffer &)=delete
unsigned char * fBuffer
Points into the I/O buffer with data from the file, not owned.
size_t CopyTo(void *buffer, size_t nbytes, std::uint64_t offset)
Tries to copy up to nbytes starting at offset from fBuffer into buffer. Returns number of bytes copie...
RBlockBuffer & operator=(const RBlockBuffer &)=delete
size_t fBufferSize
The number of currently buffered bytes in fBuffer.
Implementations may enforce limits on the use of vector reads.
std::size_t fMaxSingleSize
Maximum size in bytes of any single request in the request vector.
std::uint64_t fMaxTotalSize
Maximum size in bytes of the sum of requests in the vector.
bool HasReqsLimit() const
std::size_t fMaxReqs
Maximum number of elements in a ReadV request vector.
bool HasSizeLimit() const
Used for vector reads from multiple offsets into multiple buffers.
std::size_t fOutBytes
The number of actually read bytes, set by ReadV()
std::size_t fSize
The number of desired bytes.
void * fBuffer
The destination for reading.
std::uint64_t fOffset
The file offset.
On construction, an ROptions parameter can customize the RRawFile behavior.
static constexpr size_t kUseDefaultBlockSize
Use protocol-dependent default block size.
size_t fBlockSize
Read at least fBlockSize bytes at a time. A value of zero turns off I/O buffering.