23#include <XrdCl/XrdClFile.hh>
24#include <XrdCl/XrdClFileSystem.hh>
25#include <XrdVersion.hh>
28constexpr int kDefaultBlockSize = 128 * 1024;
59 return std::make_unique<RRawFileNetXNG>(
fUrl,
fOptions );
64 XrdCl::StatInfo *info =
nullptr;
65 auto st =
pImpl->file.Stat(
true, info );
67 throw std::runtime_error(
"Cannot determine size of '" +
fUrl +
"', " +
68 st.ToString() +
"; " + st.GetErrorMessage() );
69 std::uint64_t ret = info->GetSize();
76 auto st =
pImpl->file.Open(
fUrl, XrdCl::OpenFlags::Read );
78 throw std::runtime_error(
"Cannot open '" +
fUrl +
"', " +
79 st.ToString() +
"; " + st.GetErrorMessage() );
85 std::uint32_t btsread = 0;
86 auto st =
pImpl->file.Read(
offset, nbytes, buffer, btsread );
88 throw std::runtime_error(
"Cannot read from '" +
fUrl +
"', " +
89 st.ToString() +
"; " + st.GetErrorMessage() );
95 XrdCl::ChunkList chunks;
96 chunks.reserve( nReq );
97 for( std::size_t
i = 0;
i < nReq; ++
i )
100 XrdCl::VectorReadInfo *info =
nullptr;
101 auto st =
pImpl->file.VectorRead( chunks,
nullptr, info );
103 throw std::runtime_error(
"Cannot do vector read from '" +
fUrl +
"', " +
104 st.ToString() +
"; " + st.GetErrorMessage() );
106 XrdCl::ChunkList &rsp = info->GetChunks();
107 for( std::size_t
i = 0;
i < nReq; ++
i )
121#if XrdVNUMBER >= 40000
122 std::string strLastURL;
123 pImpl->file.GetProperty(
"LastURL", strLastURL);
124 XrdCl::URL lastURL(strLastURL);
127 if (lastURL.GetProtocol().compare(
"file") == 0 && lastURL.GetHostId().compare(
"localhost") == 0) {
129 Info(
"GetReadVLimits",
"Local redirect, using default values");
133 std::string strDataServer;
134 if (!
pImpl->file.GetProperty(
"DataServer", strDataServer)) {
136 Info(
"GetReadVLimits",
"Cannot get DataServer property, using default values");
139 XrdCl::URL dataServer(strDataServer);
141 XrdCl::URL dataServer(
pImpl->file.GetDataServer());
144 XrdCl::FileSystem
fs(dataServer);
146 XrdCl::Buffer *response =
nullptr;
147 arg.FromString(
"readv_ior_max readv_iov_max");
149 XrdCl::XRootDStatus status =
fs.Query(XrdCl::QueryCode::Config, arg, response);
150 if (!status.IsOK()) {
153 Info(
"GetReadVLimits",
"Cannot query readv limits, using default values");
156 std::istringstream strmResponse;
157 strmResponse.str(response->ToString());
160 std::string readvIorMax;
161 std::string readvIovMax;
162 if (!std::getline(strmResponse, readvIorMax) || !std::getline(strmResponse, readvIovMax)) {
164 Info(
"GetReadVLimits",
"unexpected response from querying readv limits, using default values");
168 if (!readvIovMax.empty() && std::isdigit(readvIovMax[0])) {
169 std::size_t val = std::stoi(readvIovMax);
171 if (val == 0x7FFFFFFF)
177 if (!readvIorMax.empty() && std::isdigit(readvIorMax[0])) {
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
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 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 length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
void OpenImpl() final
OpenImpl() is called at most once and before any call to either DoReadAt or DoGetSize.
std::unique_ptr< RRawFileNetXNGImpl > pImpl
pointer to implementation
RIOVecLimits GetReadVLimits() final
Returns the limits regarding the ioVec input to ReadV for this specific file; may open the file as a ...
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::optional< RIOVecLimits > fIOVecLimits
Set by GetReadVLimits and then cached.
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.
RRawFile(std::string_view url, ROptions options)
void EnsureOpen()
Open the file if not already open. Otherwise noop.
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
Implementations may enforce limits on the use of vector reads.
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.