Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Internal::RRawFileDavix Class Reference

The RRawFileDavix class provides read-only access to remote non-ROOT files.

It uses the Davix library for the transport layer. It instructs the RRawFile base class to buffer in larger chunks than the default for local files, assuming that remote file access has high(er) latency.

Definition at line 35 of file RRawFileDavix.hxx.

Public Types

enum class  ELineBreaks { kAuto , kSystem , kUnix , kWindows }
 kAuto detects the line break from the first line, kSystem picks the system's default More...

Public Member Functions

 RRawFileDavix (std::string_view url, RRawFile::ROptions options)
 ~RRawFileDavix ()
std::unique_ptr< RRawFileClone () const final
 Create a new RawFile that accesses the same resource. The file pointer is reset to zero.
std::uint64_t GetFilePos () const
 Returns the offset for the next Read/Readln call.
virtual RIOVecLimits GetReadVLimits ()
 Returns the limits regarding the ioVec input to ReadV for this specific file; may open the file as a side-effect.
std::uint64_t GetSize ()
 Returns the size of the file.
std::string GetUrl () const
 Returns the url of the file.
bool IsBuffering () const
bool IsOpen () const
 Once opened, the file stay open until destruction of the RRawFile object.
size_t Read (void *buffer, size_t nbytes)
 Read from fFilePos offset. Returns the actual number of bytes read.
size_t ReadAt (void *buffer, size_t nbytes, std::uint64_t offset)
 Buffered read from a random position.
bool Readln (std::string &line)
 Read the next line starting from the current value of fFilePos. Returns false if the end of the file is reached.
void ReadV (RIOVec *ioVec, unsigned int nReq)
 Opens the file if necessary and calls ReadVImpl.
void Seek (std::uint64_t offset)
 Change the cursor fFilePos.
void SetBuffering (bool value)
 Turn on/off buffered reads; if off, all scalar read requests go directly to the implementation.

Static Public Member Functions

static std::unique_ptr< RRawFileCreate (std::string_view url, ROptions options=ROptions())
 Factory method that returns a suitable concrete implementation according to the transport in the url.
static std::string GetLocation (std::string_view url)
 Returns only the file location, e.g. "server/file" for http://server/file.
static std::string GetTransport (std::string_view url)
 Returns only the transport protocol in lower case, e.g. "http" for HTTP://server/file.

Protected Member Functions

void EnsureOpen ()
 Open the file if not already open. Otherwise noop.
std::uint64_t GetSizeImpl () final
 Derived classes should return the file size.
void OpenImpl () final
 OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
size_t ReadAtImpl (void *buffer, size_t nbytes, std::uint64_t offset) final
 Derived classes should implement low-level reading without buffering.
void ReadVImpl (RIOVec *ioVec, unsigned int nReq) final
 By default implemented as a loop of ReadAt calls but can be overwritten, e.g. XRootD or DAVIX implementations.
virtual void SetDiscourageReadAheadImpl (bool)

Protected Attributes

std::uint64_t fFilePos = 0
 The current position in the file, which can be changed by Seek, Read, and Readln.
ROptions fOptions
std::string fUrl

Private Attributes

unsigned int fBlockBufferIdx = 0
 To be used modulo kNumBlockBuffers, points to the last used block buffer in fBlockBuffers.
RBlockBuffer fBlockBuffers [kNumBlockBuffers]
 An active buffer and a shadow buffer, which supports "jumping back" to a previously used location in the file.
std::unique_ptr< unsigned char[]> fBufferSpace
 Memory block containing the block buffers consecutively.
std::unique_ptr< Internal::RDavixFileDesfFileDes
std::uint64_t fFileSize = kUnknownFileSize
 The cached file size.
bool fIsBuffering = true
 Runtime switch to decide if reads are buffered or directly sent to ReadAtImpl().
bool fIsOpen = false
 Files are opened lazily and only when required; the open state is kept by this flag.

Static Private Attributes

static constexpr unsigned int kNumBlockBuffers = 2
 Don't change without adapting ReadAt().
static constexpr std::uint64_t kUnknownFileSize = std::uint64_t(-1)
 Used as a marker that the file size was not yet queried.

#include <ROOT/RRawFileDavix.hxx>

Inheritance diagram for ROOT::Internal::RRawFileDavix:
ROOT::Internal::RRawFile

Member Enumeration Documentation

◆ ELineBreaks

enum class ROOT::Internal::RRawFile::ELineBreaks
stronginherited

kAuto detects the line break from the first line, kSystem picks the system's default

Enumerator
kAuto 
kSystem 
kUnix 
kWindows 

Definition at line 46 of file RRawFile.hxx.

Constructor & Destructor Documentation

◆ RRawFileDavix()

ROOT::Internal::RRawFileDavix::RRawFileDavix ( std::string_view url,
RRawFile::ROptions options )

Definition at line 55 of file RRawFileDavix.cxx.

◆ ~RRawFileDavix()

ROOT::Internal::RRawFileDavix::~RRawFileDavix ( )

Definition at line 60 of file RRawFileDavix.cxx.

Member Function Documentation

◆ Clone()

std::unique_ptr< ROOT::Internal::RRawFile > ROOT::Internal::RRawFileDavix::Clone ( ) const
finalvirtual

Create a new RawFile that accesses the same resource. The file pointer is reset to zero.

Implements ROOT::Internal::RRawFile.

Definition at line 66 of file RRawFileDavix.cxx.

◆ Create()

std::unique_ptr< ROOT::Internal::RRawFile > ROOT::Internal::RRawFile::Create ( std::string_view url,
ROptions options = ROptions() )
staticinherited

Factory method that returns a suitable concrete implementation according to the transport in the url.

Definition at line 64 of file RRawFile.cxx.

◆ EnsureOpen()

void ROOT::Internal::RRawFile::EnsureOpen ( )
protectedinherited

Open the file if not already open. Otherwise noop.

Definition at line 88 of file RRawFile.cxx.

◆ GetFilePos()

std::uint64_t ROOT::Internal::RRawFile::GetFilePos ( ) const
inlineinherited

Returns the offset for the next Read/Readln call.

Definition at line 173 of file RRawFile.hxx.

◆ GetLocation()

std::string ROOT::Internal::RRawFile::GetLocation ( std::string_view url)
staticinherited

Returns only the file location, e.g. "server/file" for http://server/file.

Definition at line 105 of file RRawFile.cxx.

◆ GetReadVLimits()

virtual RIOVecLimits ROOT::Internal::RRawFile::GetReadVLimits ( )
inlinevirtualinherited

Returns the limits regarding the ioVec input to ReadV for this specific file; may open the file as a side-effect.

Reimplemented in ROOT::Internal::RRawFileNetXNG.

Definition at line 182 of file RRawFile.hxx.

◆ GetSize()

std::uint64_t ROOT::Internal::RRawFile::GetSize ( )
inherited

Returns the size of the file.

Definition at line 113 of file RRawFile.cxx.

◆ GetSizeImpl()

std::uint64_t ROOT::Internal::RRawFileDavix::GetSizeImpl ( )
finalprotectedvirtual

Derived classes should return the file size.

Implements ROOT::Internal::RRawFile.

Definition at line 71 of file RRawFileDavix.cxx.

◆ GetTransport()

std::string ROOT::Internal::RRawFile::GetTransport ( std::string_view url)
staticinherited

Returns only the transport protocol in lower case, e.g. "http" for HTTP://server/file.

Definition at line 127 of file RRawFile.cxx.

◆ GetUrl()

std::string ROOT::Internal::RRawFile::GetUrl ( ) const
inherited

Returns the url of the file.

Definition at line 123 of file RRawFile.cxx.

◆ IsBuffering()

bool ROOT::Internal::RRawFile::IsBuffering ( ) const
inlineinherited

Definition at line 188 of file RRawFile.hxx.

◆ IsOpen()

bool ROOT::Internal::RRawFile::IsOpen ( ) const
inlineinherited

Once opened, the file stay open until destruction of the RRawFile object.

Definition at line 194 of file RRawFile.hxx.

◆ OpenImpl()

void ROOT::Internal::RRawFileDavix::OpenImpl ( )
finalprotectedvirtual

OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.

If fOptions.fBlocksize is negative, derived classes are responsible to set a sensible value. After a call to OpenImpl(), fOptions.fBlocksize must be larger or equal to zero.

Implements ROOT::Internal::RRawFile.

Definition at line 81 of file RRawFileDavix.cxx.

◆ Read()

size_t ROOT::Internal::RRawFile::Read ( void * buffer,
size_t nbytes )
inherited

Read from fFilePos offset. Returns the actual number of bytes read.

Definition at line 137 of file RRawFile.cxx.

◆ ReadAt()

size_t ROOT::Internal::RRawFile::ReadAt ( void * buffer,
size_t nbytes,
std::uint64_t offset )
inherited

Buffered read from a random position.

Returns the actual number of bytes read. Short reads indicate the end of the file

Definition at line 144 of file RRawFile.cxx.

◆ ReadAtImpl()

size_t ROOT::Internal::RRawFileDavix::ReadAtImpl ( void * buffer,
size_t nbytes,
std::uint64_t offset )
finalprotectedvirtual

Derived classes should implement low-level reading without buffering.

Short reads indicate the end of the file, therefore derived classes should return nbytes bytes if available.

Implements ROOT::Internal::RRawFile.

Definition at line 92 of file RRawFileDavix.cxx.

◆ Readln()

bool ROOT::Internal::RRawFile::Readln ( std::string & line)
inherited

Read the next line starting from the current value of fFilePos. Returns false if the end of the file is reached.

Definition at line 208 of file RRawFile.cxx.

◆ ReadV()

void ROOT::Internal::RRawFile::ReadV ( RIOVec * ioVec,
unsigned int nReq )
inherited

Opens the file if necessary and calls ReadVImpl.

Definition at line 193 of file RRawFile.cxx.

◆ ReadVImpl()

void ROOT::Internal::RRawFileDavix::ReadVImpl ( RIOVec * ioVec,
unsigned int nReq )
finalprotectedvirtual

By default implemented as a loop of ReadAt calls but can be overwritten, e.g. XRootD or DAVIX implementations.

Reimplemented from ROOT::Internal::RRawFile.

Definition at line 102 of file RRawFileDavix.cxx.

◆ Seek()

void ROOT::Internal::RRawFile::Seek ( std::uint64_t offset)
inherited

Change the cursor fFilePos.

Definition at line 241 of file RRawFile.cxx.

◆ SetBuffering()

void ROOT::Internal::RRawFile::SetBuffering ( bool value)
inherited

Turn on/off buffered reads; if off, all scalar read requests go directly to the implementation.

Buffering also turns on and off OS read-ahead where supported: if buffering is switched, SetDiscourageReadAheadImpl() will be called accordingly.

Definition at line 199 of file RRawFile.cxx.

◆ SetDiscourageReadAheadImpl()

virtual void ROOT::Internal::RRawFile::SetDiscourageReadAheadImpl ( bool )
inlineprotectedvirtualinherited

Reimplemented in ROOT::Internal::RRawFileUnix.

Definition at line 144 of file RRawFile.hxx.

Member Data Documentation

◆ fBlockBufferIdx

unsigned int ROOT::Internal::RRawFile::fBlockBufferIdx = 0
privateinherited

To be used modulo kNumBlockBuffers, points to the last used block buffer in fBlockBuffers.

Definition at line 110 of file RRawFile.hxx.

◆ fBlockBuffers

RBlockBuffer ROOT::Internal::RRawFile::fBlockBuffers[kNumBlockBuffers]
privateinherited

An active buffer and a shadow buffer, which supports "jumping back" to a previously used location in the file.

Definition at line 112 of file RRawFile.hxx.

◆ fBufferSpace

std::unique_ptr<unsigned char[]> ROOT::Internal::RRawFile::fBufferSpace
privateinherited

Memory block containing the block buffers consecutively.

Definition at line 114 of file RRawFile.hxx.

◆ fFileDes

std::unique_ptr<Internal::RDavixFileDes> ROOT::Internal::RRawFileDavix::fFileDes
private

Definition at line 37 of file RRawFileDavix.hxx.

◆ fFilePos

std::uint64_t ROOT::Internal::RRawFile::fFilePos = 0
protectedinherited

The current position in the file, which can be changed by Seek, Read, and Readln.

Definition at line 128 of file RRawFile.hxx.

◆ fFileSize

std::uint64_t ROOT::Internal::RRawFile::fFileSize = kUnknownFileSize
privateinherited

The cached file size.

Definition at line 118 of file RRawFile.hxx.

◆ fIsBuffering

bool ROOT::Internal::RRawFile::fIsBuffering = true
privateinherited

Runtime switch to decide if reads are buffered or directly sent to ReadAtImpl().

Definition at line 122 of file RRawFile.hxx.

◆ fIsOpen

bool ROOT::Internal::RRawFile::fIsOpen = false
privateinherited

Files are opened lazily and only when required; the open state is kept by this flag.

Definition at line 120 of file RRawFile.hxx.

◆ fOptions

ROptions ROOT::Internal::RRawFile::fOptions
protectedinherited

Definition at line 126 of file RRawFile.hxx.

◆ fUrl

std::string ROOT::Internal::RRawFile::fUrl
protectedinherited

Definition at line 125 of file RRawFile.hxx.

◆ kNumBlockBuffers

unsigned int ROOT::Internal::RRawFile::kNumBlockBuffers = 2
staticconstexprprivateinherited

Don't change without adapting ReadAt().

Definition at line 92 of file RRawFile.hxx.

◆ kUnknownFileSize

std::uint64_t ROOT::Internal::RRawFile::kUnknownFileSize = std::uint64_t(-1)
staticconstexprprivateinherited

Used as a marker that the file size was not yet queried.

Definition at line 116 of file RRawFile.hxx.


The documentation for this class was generated from the following files: