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() );
80 if (fOptions.fBlockSize == ROptions::kUseDefaultBlockSize)
81 fOptions.fBlockSize = kDefaultBlockSize;
86 std::uint32_t btsread = 0;
87 auto st = pImpl->file.Read(
offset, nbytes, buffer, btsread );
89 throw std::runtime_error(
"Cannot read from '" + fUrl +
"', " +
90 st.ToString() +
"; " + st.GetErrorMessage() );
96 XrdCl::ChunkList chunks;
97 chunks.reserve( nReq );
98 for( std::size_t i = 0; i < nReq; ++i )
101 XrdCl::VectorReadInfo *info =
nullptr;
102 auto st = pImpl->file.VectorRead( chunks,
nullptr, info );
104 throw std::runtime_error(
"Cannot do vector read from '" + fUrl +
"', " +
105 st.ToString() +
"; " + st.GetErrorMessage() );
107 XrdCl::ChunkList &rsp = info->GetChunks();
108 for( std::size_t i = 0; i < nReq; ++i )
109 ioVec[i].fOutBytes = rsp[i].
length;
116 return *fIOVecLimits;
120 fIOVecLimits =
RIOVecLimits{1024, 2097136,
static_cast<std::uint64_t
>(-1)};
122#if XrdVNUMBER >= 40000
123 std::string strLastURL;
124 pImpl->file.GetProperty(
"LastURL", strLastURL);
125 XrdCl::URL lastURL(strLastURL);
128 if (lastURL.GetProtocol().compare(
"file") == 0 && lastURL.GetHostId().compare(
"localhost") == 0) {
130 Info(
"GetReadVLimits",
"Local redirect, using default values");
131 return *fIOVecLimits;
134 std::string strDataServer;
135 if (!pImpl->file.GetProperty(
"DataServer", strDataServer)) {
137 Info(
"GetReadVLimits",
"Cannot get DataServer property, using default values");
138 return *fIOVecLimits;
140 XrdCl::URL dataServer(strDataServer);
142 XrdCl::URL dataServer(pImpl->file.GetDataServer());
145 XrdCl::FileSystem
fs(dataServer);
147 XrdCl::Buffer *response =
nullptr;
148 arg.FromString(
"readv_ior_max readv_iov_max");
150 XrdCl::XRootDStatus status =
fs.Query(XrdCl::QueryCode::Config, arg, response);
151 if (!status.IsOK()) {
154 Info(
"GetReadVLimits",
"Cannot query readv limits, using default values");
155 return *fIOVecLimits;
157 std::istringstream strmResponse;
158 strmResponse.str(response->ToString());
161 std::string readvMaxSingleSize;
162 std::string readvMaxReqs;
163 if (!std::getline(strmResponse, readvMaxSingleSize) || !std::getline(strmResponse, readvMaxReqs)) {
165 Info(
"GetReadVLimits",
"unexpected response from querying readv limits, using default values");
166 return *fIOVecLimits;
169 if (!readvMaxReqs.empty() && std::isdigit(readvMaxReqs[0])) {
170 std::size_t val = std::stoi(readvMaxReqs);
172 if (val == 0x7FFFFFFF)
173 return *fIOVecLimits;
175 fIOVecLimits->fMaxReqs = val;
178 if (!readvMaxSingleSize.empty() && std::isdigit(readvMaxSingleSize[0])) {
179 fIOVecLimits->fMaxSingleSize = std::stoi(readvMaxSingleSize);
182 return *fIOVecLimits;
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.
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::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.
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
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.