Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RMiniFile.hxx
Go to the documentation of this file.
1/// \file ROOT/RMiniFile.hxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2019-12-22
4
5/*************************************************************************
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_RMiniFile
14#define ROOT_RMiniFile
15
16#include <ROOT/RError.hxx>
17#include <ROOT/RNTuple.hxx>
19#include <ROOT/RSpan.hxx>
20#include <Compression.h>
21#include <string_view>
22
23#include <cstdint>
24#include <cstdio>
25#include <memory>
26#include <string>
27#include <variant>
28
29class TDirectory;
30class TFileMergeInfo;
32
33namespace ROOT {
34
35class RNTupleWriteOptions;
36
37namespace Experimental {
38
39class RFile;
40
41}
42
43namespace Internal {
44
45class RRawFile;
46
47/// Holds status information of an open ROOT file during writing
48struct RTFileControlBlock;
49
50// clang-format off
51/**
52\class ROOT::Internal::RMiniFileReader
53\ingroup NTuple
54\brief Read RNTuple data blocks from a TFile container, provided by a RRawFile
55
56A RRawFile is used for the byte access. The class implements a minimal subset of TFile, enough to extract
57RNTuple data keys.
58*/
59// clang-format on
61private:
62 /// The raw file used to read byte ranges
64 /// Indicates whether the file is a TFile container or an RNTuple bare file
65 bool fIsBare = false;
66 /// If `fMaxKeySize > 0` and ReadBuffer attempts to read `nbytes > maxKeySize`, it will assume the
67 /// blob being read is chunked and read all the chunks into the buffer. This is symmetrical to
68 /// what happens in `RNTupleFileWriter::WriteBlob()`.
69 std::uint64_t fMaxKeySize = 0;
70
71 /// Information about the streamer info record cache on file open from the TFile header. Used in LoadStreamerInfo.
72 std::uint64_t fSeekKeyInfo = 0;
73 std::uint64_t fNbytesKeyAndInfo = 0;
74
75 /// Used when the file container turns out to be a bare file
77 /// Used when the file turns out to be a TFile container. The ntuplePath variable is either the ntuple name
78 /// or an ntuple name preceded by a directory (`myNtuple` or `foo/bar/myNtuple` or `/foo/bar/myNtuple`)
80
81 /// Searches for a key with the given name and type in the key index of the directory starting at offsetDir.
82 /// The offset points to the start of the TDirectory DATA section, without the key and without the name and title
83 /// of the TFile record (the root directory).
84 /// Return 0 if the key was not found. Otherwise returns the offset of found key.
85 std::uint64_t SearchInDirectory(std::uint64_t &offsetDir, std::string_view keyName, std::string_view typeName);
86
87public:
88 RMiniFileReader() = default;
89 /// Uses the given raw file to read byte ranges
91 /// Extracts header and footer location for the RNTuple identified by ntupleName
92 RResult<RNTuple> GetNTuple(std::string_view ntupleName);
93 /// Loads an RNTuple anchor from a TFile at the given file offset (unzipping it if necessary).
95 GetNTupleProperAtOffset(std::uint64_t payloadOffset, std::uint64_t compSize, std::uint64_t uncompLen);
96 /// Reads a given byte range from the file into the provided memory buffer.
97 /// If `nbytes > fMaxKeySize` it will perform chunked read from multiple blobs,
98 /// whose addresses are listed at the end of the first chunk.
99 /// \throw ROOT::RException if the read fails.
100 void ReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset);
101 /// Like ReadBuffer but returns a RResult instead of throwing.
102 ROOT::RResult<void> TryReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset);
103 /// Load the streamer info from the file into the global list of streamer infos
104 void LoadStreamerInfo();
105
106 std::uint64_t GetMaxKeySize() const { return fMaxKeySize; }
107 /// If the reader is not used to retrieve the anchor, we need to set the max key size manually
109};
110
111// clang-format off
112/**
113\class ROOT::Internal::RNTupleFileWriter
114\ingroup NTuple
115\brief Write RNTuple data blocks in a TFile or a bare file container
116
117The writer can create a new TFile container for an RNTuple or add an RNTuple to an existing TFile.
118Creating a single RNTuple in a new TFile container can be done with a C file stream without a TFile class.
119Updating an existing TFile requires a proper TFile object. Also, writing a remote file requires a proper TFile object.
120A stand-alone version of RNTuple can remove the TFile based writer.
121*/
122// clang-format on
124public:
125 /// The key length of a blob. It is always a big key (version > 1000) with class name RBlob.
126 static constexpr std::size_t kBlobKeyLen = 42;
127
128private:
129 struct RImplTFile {
130 /// A sub directory in fFile or nullptr if the data is stored in the root directory of the file
132 /// Low-level writing using a TFile
133 void Write(const void *buffer, size_t nbytes, std::int64_t offset);
134 /// Reserves an RBlob opaque key as data record and returns the offset of the record. If keyBuffer is specified,
135 /// it must be written *before* the returned offset. (Note that the array type is purely documentation, the
136 /// argument is actually just a pointer.)
137 std::uint64_t ReserveBlobKey(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen] = nullptr);
138 operator bool() const { return fDirectory; }
139 };
140
141 struct RImplRFile {
143 std::string fDir;
144 /// Low-level writing using a TFile
145 void Write(const void *buffer, size_t nbytes, std::int64_t offset);
146 /// Reserves an RBlob opaque key as data record and returns the offset of the record. If keyBuffer is specified,
147 /// it must be written *before* the returned offset. (Note that the array type is purely documentation, the
148 /// argument is actually just a pointer.)
149 std::uint64_t ReserveBlobKey(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen] = nullptr);
150 operator bool() const { return fFile; }
151 };
152
153 struct RImplSimple {
154 /// Direct I/O requires that all buffers and write lengths are aligned. It seems 512 byte alignment is the minimum
155 /// for Direct I/O to work, but further testing showed that it results in worse performance than 4kB.
156 static constexpr int kBlockAlign = 4096;
157 /// During commit, WriteTFileKeysList() updates fNBytesKeys and fSeekKeys of the RTFFile located at
158 /// fSeekFileRecord. Given that the TFile key starts at offset 100 and the file name, which is written twice,
159 /// is shorter than 255 characters, we should need at most ~600 bytes. However, the header also needs to be
160 /// aligned to kBlockAlign...
161 static constexpr std::size_t kHeaderBlockSize = 4096;
162
163 /// Data that is shared between a "main" RImplSimple and all its clones.
164 /// Note that only the main file will write the header and footer, while all the clones are only
165 /// used to (sequentially) push data into the same underlying file from multiple locations.
166 struct RSharedData {
167 /// For the simplest cases, a C file stream can be used for writing
168 FILE *fFile = nullptr;
169 /// Keeps track of the seek offset
170 std::uint64_t fFilePos = 0;
171 /// Keeps track of the next key offset
172 std::uint64_t fKeyOffset = 0;
173 /// Whether the C file stream has been opened with Direct I/O, introducing alignment requirements.
174 bool fDirectIO = false;
175
176 // fHeaderBlock and fBlock are raw pointers because we have to manually call operator new and delete.
177 unsigned char *fHeaderBlock = nullptr;
178 std::size_t fBlockSize = 0;
179 std::uint64_t fBlockOffset = 0;
180 unsigned char *fBlock = nullptr;
181
182 /// Keeps track of TFile control structures, which need to be updated on committing the data set
183 std::unique_ptr<ROOT::Internal::RTFileControlBlock> fControlBlock;
184
185 explicit RSharedData(FILE *file);
186 ~RSharedData();
187 };
188 std::shared_ptr<RSharedData> fShared;
189
191 RImplSimple(const RImplSimple &other) = delete;
195
196 void AllocateBuffers(std::size_t bufferSize);
197 void Flush();
198
199 /// Writes bytes in the open stream, either at fFilePos or at the given offset
200 void Write(const void *buffer, size_t nbytes, std::int64_t offset = -1);
201 /// Writes a TKey including the data record, given by buffer, into fFile; returns the file offset to the payload.
202 /// The payload is already compressed
203 std::uint64_t WriteKey(const void *buffer, std::size_t nbytes, std::size_t len, std::int64_t offset = -1,
204 std::uint64_t directoryOffset = 100, const std::string &className = "",
205 const std::string &objectName = "", const std::string &title = "");
206 /// Reserves an RBlob opaque key as data record and returns the offset of the record. If keyBuffer is specified,
207 /// it must be written *before* the returned offset. (Note that the array type is purely documentation, the
208 /// argument is actually just a pointer.)
209 std::uint64_t ReserveBlobKey(std::size_t nbytes, std::size_t len, unsigned char keyBuffer[kBlobKeyLen] = nullptr);
210 operator bool() const { return fShared->fFile; }
211 };
212
213 template <typename T>
214 static std::uint64_t
215 ReserveBlobKey(T &caller, TFile &file, std::size_t nbytes, std::size_t len, unsigned char keyBuffer[kBlobKeyLen]);
216
217 /// RImplSimple: for simple use cases, survives without libRIO dependency
218 /// RImplTFile: for updating existing files and for storing more than just an RNTuple in the file
219 /// RImplRFile: like RImplTFile but using RFile instead of TFile.
220 using FileType_t = std::variant<RImplSimple, RImplTFile, RImplRFile>;
222
223 /// A simple file can either be written as TFile container or as NTuple bare file
224 bool fIsBare = false;
225 /// True if this RNTuple's anchor must be stored as a hidden key (this is the case e.g. for attribute RNTuples).
226 bool fIsHidden = false;
227 /// The identifier of the RNTuple; A single writer object can only write a single RNTuple but multiple
228 /// writers can operate on the same file if (and only if) they use a proper TFile object for writing.
229 std::string fNTupleName;
230 /// The file name without parent directory; only required when writing with a C file stream
231 std::string fFileName;
232 /// Header and footer location of the ntuple, written on Commit()
234 /// Set of streamer info records that should be written to the file.
235 /// The RNTuple class description is always present.
237
238 /// Private constructor used by all factory methods.
239 /// Note that, in case of "owned" files (those created via Recreate) there must be exactly one non-hidden
240 /// RNTupleFileWriter which is responsible for serializing the ROOT file metadata.
241 /// This is enforced by the public API, as the only way to create a hidden FileWriter is via CloneAsHidden (which
242 /// creates a secondary hidden writer over the same file) and Append (which never writes the file metadata because
243 /// they are already handled by the "real" TFile).
244 explicit RNTupleFileWriter(std::string_view name, std::uint64_t maxKeySize, bool isHidden);
245
246 /// For a TFile container written by a C file stream, write the header and TFile object
248 /// The only key that will be visible in file->ls()
249 /// Returns the link to the RNTuple anchor.
251 /// Write the TList with the RNTuple key
252 void WriteTFileKeysList(std::uint64_t anchorSize);
253 /// Write the compressed streamer info record with the description of the RNTuple class
255 /// Last record in the file
256 void WriteTFileFreeList();
257 /// For a bare file, which is necessarily written by a C file stream, write file header
259
260public:
261 /// For testing purposes, RNTuple data can be written into a bare file container instead of a ROOT file
262 enum class EContainerFormat {
263 kTFile, // ROOT TFile
264 kBare, // A thin envelope supporting a single RNTuple only
265 };
266
267 /// Create or truncate the local file given by path with the new empty RNTuple identified by ntupleName.
268 /// Uses a C stream for writing
269 static std::unique_ptr<RNTupleFileWriter> Recreate(std::string_view ntupleName, std::string_view path,
271 const ROOT::RNTupleWriteOptions &options);
272 /// The directory parameter can also be a TFile object (TFile inherits from TDirectory).
273 static std::unique_ptr<RNTupleFileWriter>
274 Append(std::string_view ntupleName, TDirectory &fileOrDirectory, std::uint64_t maxKeySize, bool isHidden);
275
276 static std::unique_ptr<RNTupleFileWriter> Append(std::string_view ntupleName, ROOT::Experimental::RFile &file,
277 std::string_view dirPath, std::uint64_t maxKeySize);
278
284
285 /// Creates a new RNTupleFileWriter with the same underlying TDirectory as this but writing to a different
286 /// RNTuple named `ntupleName`. Only one of the two writers can safely write to the file at the same time.
287 /// The RNTuple written by this cloned writer will be stored in a hidden key (this is a convenient assumption we
288 /// make now since this method is only used to create attribute RNTuples).
289 /// This method is currently only supported for TFile-based Writers and will throw an exception if that's not the
290 /// case.
291 std::unique_ptr<RNTupleFileWriter> CloneAsHidden(std::string_view ntupleName) const;
292
293 /// Seek a simple writer to offset. Note that previous data is not flushed immediately, but only by the next write
294 /// (if necessary).
295 void Seek(std::uint64_t offset);
296
297 /// Writes the compressed header and registeres its location; lenHeader is the size of the uncompressed header.
298 std::uint64_t WriteNTupleHeader(const void *data, size_t nbytes, size_t lenHeader);
299 /// Writes the compressed footer and registeres its location; lenFooter is the size of the uncompressed footer.
300 std::uint64_t WriteNTupleFooter(const void *data, size_t nbytes, size_t lenFooter);
301 /// Writes a new record as an RBlob key into the file
302 std::uint64_t WriteBlob(const void *data, size_t nbytes, size_t len);
303
304 /// Prepares buffer for a new record as an RBlob key at offset.
305 /// (Note that the array type is purely documentation, the argument is actually just a pointer.)
306 static void PrepareBlobKey(std::int64_t offset, size_t nbytes, size_t len, unsigned char buffer[kBlobKeyLen]);
307
308 /// Reserves a new record as an RBlob key in the file. If keyBuffer is specified, it must be written *before* the
309 /// returned offset. (Note that the array type is purely documentation, the argument is actually just a pointer.)
310 std::uint64_t ReserveBlob(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen] = nullptr);
311 /// Write into a reserved record; the caller is responsible for making sure that the written byte range is in the
312 /// previously reserved key.
313 void WriteIntoReservedBlob(const void *buffer, size_t nbytes, std::int64_t offset);
314 /// Ensures that the streamer info records passed as argument are written to the file
316
317 /// Writes the RNTuple key to the file so that the header and footer keys can be found.
318 /// \return information about the committed anchor.
320
321 std::string_view GetNTupleName() const { return fNTupleName; }
322};
323
324} // namespace Internal
325} // namespace ROOT
326
327#endif
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition TGX11.cxx:142
An interface to read from, or write to, a ROOT file, as well as performing other common operations.
Definition RFile.hxx:252
Read RNTuple data blocks from a TFile container, provided by a RRawFile.
Definition RMiniFile.hxx:60
std::uint64_t fSeekKeyInfo
Information about the streamer info record cache on file open from the TFile header....
Definition RMiniFile.hxx:72
void ReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset)
Reads a given byte range from the file into the provided memory buffer.
void LoadStreamerInfo()
Load the streamer info from the file into the global list of streamer infos.
std::uint64_t GetMaxKeySize() const
void SetMaxKeySize(std::uint64_t maxKeySize)
If the reader is not used to retrieve the anchor, we need to set the max key size manually.
RResult< RNTuple > GetNTupleProperAtOffset(std::uint64_t payloadOffset, std::uint64_t compSize, std::uint64_t uncompLen)
Loads an RNTuple anchor from a TFile at the given file offset (unzipping it if necessary).
RResult< RNTuple > GetNTupleBare(std::string_view ntupleName)
Used when the file container turns out to be a bare file.
ROOT::RResult< void > TryReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset)
Like ReadBuffer but returns a RResult instead of throwing.
std::uint64_t SearchInDirectory(std::uint64_t &offsetDir, std::string_view keyName, std::string_view typeName)
Searches for a key with the given name and type in the key index of the directory starting at offsetD...
ROOT::Internal::RRawFile * fRawFile
The raw file used to read byte ranges.
Definition RMiniFile.hxx:63
RResult< RNTuple > GetNTuple(std::string_view ntupleName)
Extracts header and footer location for the RNTuple identified by ntupleName.
RResult< RNTuple > GetNTupleProper(std::string_view ntuplePath)
Used when the file turns out to be a TFile container.
bool fIsBare
Indicates whether the file is a TFile container or an RNTuple bare file.
Definition RMiniFile.hxx:65
std::uint64_t fMaxKeySize
If fMaxKeySize > 0 and ReadBuffer attempts to read nbytes > maxKeySize, it will assume the blob being...
Definition RMiniFile.hxx:69
Write RNTuple data blocks in a TFile or a bare file container.
std::uint64_t ReserveBlob(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen]=nullptr)
Reserves a new record as an RBlob key in the file.
std::variant< RImplSimple, RImplTFile, RImplRFile > FileType_t
RImplSimple: for simple use cases, survives without libRIO dependency RImplTFile: for updating existi...
ROOT::Internal::RNTupleLink WriteTFileNTupleKey(int compression)
The only key that will be visible in file->ls() Returns the link to the RNTuple anchor.
void WriteTFileStreamerInfo(int compression)
Write the compressed streamer info record with the description of the RNTuple class.
std::string_view GetNTupleName() const
std::string fNTupleName
The identifier of the RNTuple; A single writer object can only write a single RNTuple but multiple wr...
void WriteTFileKeysList(std::uint64_t anchorSize)
Write the TList with the RNTuple key.
RNTupleFileWriter(const RNTupleFileWriter &other)=delete
void WriteBareFileSkeleton(int defaultCompression)
For a bare file, which is necessarily written by a C file stream, write file header.
RNTupleFileWriter & operator=(const RNTupleFileWriter &other)=delete
RNTupleFileWriter(RNTupleFileWriter &&other)=delete
std::uint64_t WriteNTupleHeader(const void *data, size_t nbytes, size_t lenHeader)
Writes the compressed header and registeres its location; lenHeader is the size of the uncompressed h...
std::string fFileName
The file name without parent directory; only required when writing with a C file stream.
static std::uint64_t ReserveBlobKey(T &caller, TFile &file, std::size_t nbytes, std::size_t len, unsigned char keyBuffer[kBlobKeyLen])
static std::unique_ptr< RNTupleFileWriter > Append(std::string_view ntupleName, TDirectory &fileOrDirectory, std::uint64_t maxKeySize, bool isHidden)
The directory parameter can also be a TFile object (TFile inherits from TDirectory).
void WriteTFileFreeList()
Last record in the file.
std::unique_ptr< RNTupleFileWriter > CloneAsHidden(std::string_view ntupleName) const
Creates a new RNTupleFileWriter with the same underlying TDirectory as this but writing to a differen...
void WriteTFileSkeleton(int defaultCompression)
For a TFile container written by a C file stream, write the header and TFile object.
RNTupleFileWriter(std::string_view name, std::uint64_t maxKeySize, bool isHidden)
Private constructor used by all factory methods.
void Seek(std::uint64_t offset)
Seek a simple writer to offset.
bool fIsBare
A simple file can either be written as TFile container or as NTuple bare file.
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfoMap
Set of streamer info records that should be written to the file.
RNTupleFileWriter & operator=(RNTupleFileWriter &&other)=delete
std::uint64_t WriteBlob(const void *data, size_t nbytes, size_t len)
Writes a new record as an RBlob key into the file.
static std::unique_ptr< RNTupleFileWriter > Recreate(std::string_view ntupleName, std::string_view path, EContainerFormat containerFormat, const ROOT::RNTupleWriteOptions &options)
Create or truncate the local file given by path with the new empty RNTuple identified by ntupleName.
void WriteIntoReservedBlob(const void *buffer, size_t nbytes, std::int64_t offset)
Write into a reserved record; the caller is responsible for making sure that the written byte range i...
static constexpr std::size_t kBlobKeyLen
The key length of a blob. It is always a big key (version > 1000) with class name RBlob.
RNTupleLink Commit(int compression=RCompressionSetting::EDefaults::kUseGeneralPurpose)
Writes the RNTuple key to the file so that the header and footer keys can be found.
static void PrepareBlobKey(std::int64_t offset, size_t nbytes, size_t len, unsigned char buffer[kBlobKeyLen])
Prepares buffer for a new record as an RBlob key at offset.
std::uint64_t WriteNTupleFooter(const void *data, size_t nbytes, size_t lenFooter)
Writes the compressed footer and registeres its location; lenFooter is the size of the uncompressed f...
bool fIsHidden
True if this RNTuple's anchor must be stored as a hidden key (this is the case e.g....
void UpdateStreamerInfos(const ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t &streamerInfos)
Ensures that the streamer info records passed as argument are written to the file.
RNTuple fNTupleAnchor
Header and footer location of the ntuple, written on Commit()
EContainerFormat
For testing purposes, RNTuple data can be written into a bare file container instead of a ROOT file.
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
The RRawFile provides read-only access to local and remote files.
Definition RRawFile.hxx:43
Common user-tunable settings for storing RNTuples.
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:67
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:222
Describe directory structure in memory.
Definition TDirectory.h:45
A class to pass information from the TFileMerger to the objects being merged.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
Abstract Interface class describing Streamer information for one class.
void Write(const void *buffer, size_t nbytes, std::int64_t offset)
Low-level writing using a TFile.
std::uint64_t ReserveBlobKey(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen]=nullptr)
Reserves an RBlob opaque key as data record and returns the offset of the record.
Data that is shared between a "main" RImplSimple and all its clones.
FILE * fFile
For the simplest cases, a C file stream can be used for writing.
std::uint64_t fFilePos
Keeps track of the seek offset.
std::uint64_t fKeyOffset
Keeps track of the next key offset.
std::unique_ptr< ROOT::Internal::RTFileControlBlock > fControlBlock
Keeps track of TFile control structures, which need to be updated on committing the data set.
bool fDirectIO
Whether the C file stream has been opened with Direct I/O, introducing alignment requirements.
void AllocateBuffers(std::size_t bufferSize)
RImplSimple & operator=(RImplSimple &&other)=delete
std::uint64_t WriteKey(const void *buffer, std::size_t nbytes, std::size_t len, std::int64_t offset=-1, std::uint64_t directoryOffset=100, const std::string &className="", const std::string &objectName="", const std::string &title="")
Writes a TKey including the data record, given by buffer, into fFile; returns the file offset to the ...
RImplSimple & operator=(const RImplSimple &other)=delete
static constexpr int kBlockAlign
Direct I/O requires that all buffers and write lengths are aligned.
void Write(const void *buffer, size_t nbytes, std::int64_t offset=-1)
Writes bytes in the open stream, either at fFilePos or at the given offset.
static constexpr std::size_t kHeaderBlockSize
During commit, WriteTFileKeysList() updates fNBytesKeys and fSeekKeys of the RTFFile located at fSeek...
std::shared_ptr< RSharedData > fShared
RImplSimple(const RImplSimple &other)=delete
std::uint64_t ReserveBlobKey(std::size_t nbytes, std::size_t len, unsigned char keyBuffer[kBlobKeyLen]=nullptr)
Reserves an RBlob opaque key as data record and returns the offset of the record.
TDirectory * fDirectory
A sub directory in fFile or nullptr if the data is stored in the root directory of the file.
void Write(const void *buffer, size_t nbytes, std::int64_t offset)
Low-level writing using a TFile.
std::uint64_t ReserveBlobKey(size_t nbytes, size_t len, unsigned char keyBuffer[kBlobKeyLen]=nullptr)
Reserves an RBlob opaque key as data record and returns the offset of the record.
@ kUseGeneralPurpose
Use the new recommended general-purpose setting; it is a best trade-off between compression ratio/dec...
Definition Compression.h:58