19#include <XrdCl/XrdClFile.hh>
20#include <XrdCl/XrdClFileSystem.hh>
24constexpr int kDefaultBlockSize = 128 * 1024;
55 return std::make_unique<RRawFileNetXNG>( fUrl, fOptions );
60 XrdCl::StatInfo *info =
nullptr;
61 auto st = pImpl->file.Stat(
true, info );
63 throw std::runtime_error(
"Cannot determine size of '" + fUrl +
"', " +
64 st.ToString() +
"; " + st.GetErrorMessage() );
65 std::uint64_t ret = info->GetSize();
72 auto st = pImpl->file.Open( fUrl, XrdCl::OpenFlags::Read );
74 throw std::runtime_error(
"Cannot open '" + fUrl +
"', " +
75 st.ToString() +
"; " + st.GetErrorMessage() );
76 if( fOptions.fBlockSize < 0 ) fOptions.fBlockSize = kDefaultBlockSize;
81 std::uint32_t btsread = 0;
82 auto st = pImpl->file.Read( offset, nbytes, buffer, btsread );
84 throw std::runtime_error(
"Cannot read from '" + fUrl +
"', " +
85 st.ToString() +
"; " + st.GetErrorMessage() );
91 XrdCl::ChunkList chunks;
92 chunks.reserve( nReq );
93 for( std::size_t i = 0; i < nReq; ++i )
96 XrdCl::VectorReadInfo *info =
nullptr;
97 auto st = pImpl->file.VectorRead( chunks,
nullptr, info );
99 throw std::runtime_error(
"Cannot do vector read from '" + fUrl +
"', " +
100 st.ToString() +
"; " + st.GetErrorMessage() );
102 XrdCl::ChunkList &rsp = info->GetChunks();
103 for( std::size_t i = 0; i < nReq; ++i )
104 ioVec[i].fOutBytes = rsp[i].length;
void OpenImpl() final
OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
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 impleme...
RRawFileNetXNG(std::string_view url, RRawFile::ROptions options)
std::unique_ptr< RRawFile > Clone() const final
Create a new RawFile that accesses the same resource. The file pointer is reset to zero.
size_t ReadAtImpl(void *buffer, size_t nbytes, std::uint64_t offset) final
Derived classes should implement low-level reading without buffering.
std::uint64_t GetSizeImpl() final
Derived classes should return the file size or kUnknownFileSize.
The RRawFile provides read-only access to local and remote files.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
RRawFileNetXNGImpl()=default
RRawFileNetXNGImpl & operator=(const RRawFileNetXNGImpl &)=delete
~RRawFileNetXNGImpl()=default
RRawFileNetXNGImpl(const RRawFileNetXNGImpl &)=delete
Used for vector reads from multiple offsets into multiple buffers.
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.