48#ifndef R__LITTLE_ENDIAN
51#define R__LITTLE_ENDIAN 1
53#define R__LITTLE_ENDIAN 0
64 std::uint16_t fValBE = 0;
65 static std::uint16_t
Swap(std::uint16_t val)
67#if R__LITTLE_ENDIAN == 1
68 return RByteSwap<
sizeof(val)>::bswap(val);
75 RUInt16BE() =
default;
76 explicit RUInt16BE(
const std::uint16_t val) : fValBE(
Swap(val)) {}
77 operator std::uint16_t()
const {
return Swap(fValBE); }
78 RUInt16BE &
operator=(
const std::uint16_t val)
88 std::uint32_t fValBE = 0;
89 static std::uint32_t
Swap(std::uint32_t val)
91#if R__LITTLE_ENDIAN == 1
92 return RByteSwap<
sizeof(val)>::bswap(val);
99 RUInt32BE() =
default;
100 explicit RUInt32BE(
const std::uint32_t val) : fValBE(
Swap(val)) {}
101 operator std::uint32_t()
const {
return Swap(fValBE); }
102 RUInt32BE &
operator=(
const std::uint32_t val)
112 std::int32_t fValBE = 0;
113 static std::int32_t
Swap(std::int32_t val)
115#if R__LITTLE_ENDIAN == 1
116 return RByteSwap<
sizeof(val)>::bswap(val);
123 RInt32BE() =
default;
124 explicit RInt32BE(
const std::int32_t val) : fValBE(
Swap(val)) {}
125 operator std::int32_t()
const {
return Swap(fValBE); }
126 RInt32BE &
operator=(
const std::int32_t val)
136 std::uint64_t fValBE = 0;
137 static std::uint64_t
Swap(std::uint64_t val)
139#if R__LITTLE_ENDIAN == 1
140 return RByteSwap<
sizeof(val)>::bswap(val);
147 RUInt64BE() =
default;
148 explicit RUInt64BE(
const std::uint64_t val) : fValBE(
Swap(val)) {}
149 operator std::uint64_t()
const {
return Swap(fValBE); }
150 RUInt64BE &
operator=(
const std::uint64_t val)
160 unsigned char fLName{0};
162 RTFString() =
default;
163 RTFString(
const std::string &str)
168 fLName = str.length();
169 memcpy(fData, str.data(), fLName);
171 std::size_t GetSize()
const
185 auto now = std::chrono::system_clock::now();
186 auto tt = std::chrono::system_clock::to_time_t(
now);
188 fDatetime = (
tm.tm_year + 1900 - 1995) << 26 | (
tm.tm_mon + 1) << 22 |
tm.tm_mday << 17 |
tm.tm_hour << 12 |
189 tm.tm_min << 6 |
tm.tm_sec;
191 explicit RTFDatetime(RUInt32BE val) : fDatetime(val) {}
197 RUInt16BE fVersion{4};
198 RUInt32BE fObjLen{0};
199 RTFDatetime fDatetime;
200 RUInt16BE fKeyLen{0};
204 RUInt32BE fSeekKey{0};
205 RUInt32BE fSeekPdir{0};
208 RUInt64BE fSeekKey{0};
209 RUInt64BE fSeekPdir{0};
213 std::uint32_t fKeyHeaderSize{18 +
sizeof(fInfoShort)};
215 RTFKey() : fInfoShort() {}
222 if ((
seekKey >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max())) ||
223 (
seekPdir >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max()))) {
224 fKeyHeaderSize = 18 +
sizeof(fInfoLong);
228 fVersion = fVersion + 1000;
230 fKeyHeaderSize = 18 +
sizeof(fInfoShort);
240 if (fVersion >= 1000)
242 std::uint32_t
seekKey = fInfoShort.fSeekKey;
243 std::uint32_t
seekPdir = fInfoShort.fSeekPdir;
246 fKeyHeaderSize = fKeyHeaderSize +
sizeof(fInfoLong) -
sizeof(fInfoShort);
247 fKeyLen = fKeyLen +
sizeof(fInfoLong) -
sizeof(fInfoShort);
248 fNbytes = fNbytes +
sizeof(fInfoLong) -
sizeof(fInfoShort);
249 fVersion = fVersion + 1000;
252 std::uint32_t GetSize()
const
260 std::uint32_t GetHeaderSize()
const
262 if (fVersion >= 1000)
263 return 18 +
sizeof(fInfoLong);
264 return 18 +
sizeof(fInfoShort);
267 std::uint64_t GetSeekKey()
const
269 if (fVersion >= 1000)
270 return fInfoLong.fSeekKey;
271 return fInfoShort.fSeekKey;
277 char fMagic[4]{
'r',
'o',
'o',
't'};
280 RUInt32BE fBEGIN{100};
284 RUInt32BE fSeekFree{0};
285 RUInt32BE fNbytesFree{0};
287 RUInt32BE fNbytesName{0};
288 unsigned char fUnits{4};
289 RUInt32BE fCompress{0};
290 RUInt32BE fSeekInfo{0};
291 RUInt32BE fNbytesInfo{0};
295 RUInt64BE fSeekFree{0};
296 RUInt32BE fNbytesFree{0};
298 RUInt32BE fNbytesName{0};
299 unsigned char fUnits{8};
300 RUInt32BE fCompress{0};
301 RUInt64BE fSeekInfo{0};
302 RUInt32BE fNbytesInfo{0};
306 RTFHeader() : fInfoShort() {}
311 if (fVersion >= 1000000)
315 std::uint32_t end = fInfoShort.fEND;
316 std::uint32_t
seekFree = fInfoShort.fSeekFree;
317 std::uint32_t
nbytesFree = fInfoShort.fNbytesFree;
318 std::uint32_t
nFree = fInfoShort.fNfree;
319 std::uint32_t
nbytesName = fInfoShort.fNbytesName;
320 std::uint32_t
compress = fInfoShort.fCompress;
321 std::uint32_t
seekInfo = fInfoShort.fSeekInfo;
322 std::uint32_t
nbytesInfo = fInfoShort.fNbytesInfo;
323 fInfoLong.fEND = end;
326 fInfoLong.fNfree =
nFree;
328 fInfoLong.fUnits = 8;
332 fVersion = fVersion + 1000000;
338 return (fVersion >= 1000000) || (
offset >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max()));
341 std::uint32_t GetSize()
const
343 std::uint32_t
sizeHead = 4 +
sizeof(fVersion) +
sizeof(fBEGIN);
345 return sizeHead +
sizeof(fInfoLong);
346 return sizeHead +
sizeof(fInfoShort);
349 std::uint64_t GetEnd()
const
352 return fInfoLong.fEND;
353 return fInfoShort.fEND;
360 fInfoLong.fEND =
value;
362 fInfoShort.fEND =
value;
366 std::uint64_t GetSeekFree()
const
369 return fInfoLong.fSeekFree;
370 return fInfoShort.fSeekFree;
377 fInfoLong.fSeekFree =
value;
379 fInfoShort.fSeekFree =
value;
386 fInfoLong.fNbytesFree =
value;
388 fInfoShort.fNbytesFree =
value;
395 fInfoLong.fNbytesName =
value;
397 fInfoShort.fNbytesName =
value;
401 std::uint64_t GetSeekInfo()
const
404 return fInfoLong.fSeekInfo;
405 return fInfoShort.fSeekInfo;
412 fInfoLong.fSeekInfo =
value;
414 fInfoShort.fSeekInfo =
value;
421 fInfoLong.fNbytesInfo =
value;
423 fInfoShort.fNbytesInfo =
value;
427 void SetCompression(std::uint32_t
value)
430 fInfoLong.fCompress =
value;
432 fInfoShort.fCompress =
value;
439 RUInt16BE fVersion{1};
451 RTFFreeEntry() : fInfoShort() {}
452 void Set(std::uint64_t first, std::uint64_t last)
454 if (last >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max())) {
455 fVersion = fVersion + 1000;
456 fInfoLong.fFirst = first;
457 fInfoLong.fLast = last;
459 fInfoShort.fFirst = first;
460 fInfoShort.fLast = last;
463 std::uint32_t GetSize() {
return (fVersion >= 1000) ? 18 : 10; }
469 std::uint32_t GetSize()
const {
return sizeof(RTFKeyList); }
470 explicit RTFKeyList(std::uint32_t
nKeys) : fNKeys(
nKeys) {}
475 RUInt16BE fClassVersion{5};
478 RUInt32BE fNBytesKeys{0};
479 RUInt32BE fNBytesName{0};
483 RUInt32BE fSeekDir{100};
484 RUInt32BE fSeekParent{0};
485 RUInt32BE fSeekKeys{0};
488 RUInt64BE fSeekDir{100};
489 RUInt64BE fSeekParent{0};
490 RUInt64BE fSeekKeys{0};
494 RTFDirectory() : fInfoShort() {}
497 std::uint32_t GetSize()
const
499 if (fClassVersion >= 1000)
500 return sizeof(RTFDirectory);
501 return 18 +
sizeof(fInfoShort);
504 std::uint64_t GetSeekKeys()
const
506 if (fClassVersion >= 1000)
507 return fInfoLong.fSeekKeys;
508 return fInfoShort.fSeekKeys;
513 if (
seekKeys >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max())) {
514 std::uint32_t
seekDir = fInfoShort.fSeekDir;
515 std::uint32_t
seekParent = fInfoShort.fSeekParent;
519 fClassVersion = fClassVersion + 1000;
528 RUInt16BE fVersionClass{1};
529 unsigned char fUUID[16] = {0};
532 std::uint32_t GetSize()
const {
return sizeof(RTFUUID); }
541 RUInt32BE fByteCount{0x40000000 | (
sizeof(RTFNTuple) -
sizeof(fByteCount))};
542 RUInt16BE fVersionClass{2};
543 RUInt16BE fVersionEpoch{0};
544 RUInt16BE fVersionMajor{0};
545 RUInt16BE fVersionMinor{0};
546 RUInt16BE fVersionPatch{0};
547 RUInt64BE fSeekHeader{0};
548 RUInt64BE fNBytesHeader{0};
549 RUInt64BE fLenHeader{0};
550 RUInt64BE fSeekFooter{0};
551 RUInt64BE fNBytesFooter{0};
552 RUInt64BE fLenFooter{0};
553 RUInt64BE fMaxKeySize{0};
555 static constexpr std::uint32_t
GetSizePlusChecksum() {
return sizeof(RTFNTuple) +
sizeof(std::uint64_t); }
557 RTFNTuple() =
default;
572 std::uint32_t GetSize()
const {
return sizeof(RTFNTuple); }
574 std::uint32_t
GetOffsetCkData() {
return sizeof(fByteCount) +
sizeof(fVersionClass); }
580struct RBareFileHeader {
581 char fMagic[7]{
'r',
'n',
't',
'u',
'p',
'l',
'e'};
584 RUInt32BE fFormatVersion{1};
585 RUInt32BE fCompress{0};
599namespace Experimental {
673 if (std::string(
ident, 4) ==
"root")
683 std::string_view typeName)
696 for (
unsigned int i = 0; i <
nKeys; ++i) {
700 offset += key.GetHeaderSize();
704 if (std::string_view(
name.fData,
name.fLName) != typeName) {
712 return key.GetSeekKey();
742 auto pos = std::string::npos;
749 return R__FAIL(
"no directory named '" + std::string(
directoryName) +
"' in file '" + fRawFile->GetUrl() +
"'");
752 offset = key.GetSeekKey() + key.fKeyLen;
759 return R__FAIL(
"no RNTuple named '" + std::string(
ntupleName) +
"' in file '" + fRawFile->GetUrl() +
"'");
763 offset = key.GetSeekKey() + key.fKeyLen;
767 static_assert(
kMinNTupleSize == RTFNTuple::GetSizePlusChecksum());
769 return R__FAIL(
"invalid anchor size: " + std::to_string(key.fObjLen) +
" < " + std::to_string(
sizeof(RTFNTuple)));
773 auto bufAnchor = std::make_unique<unsigned char[]>(std::max<size_t>(key.fObjLen,
sizeof(RTFNTuple)));
776 auto objNbytes = key.GetSize() - key.fKeyLen;
785 auto lenCkData = key.fObjLen -
ntuple->GetOffsetCkData() -
sizeof(uint64_t);
789 RUInt64BE *
ckOnDiskPtr =
reinterpret_cast<RUInt64BE *
>(
bufAnchor.get() + key.fObjLen -
sizeof(uint64_t));
790 ckOnDisk =
static_cast<uint64_t
>(*ckOnDiskPtr);
792 return R__FAIL(
"RNTuple anchor checksum mismatch");
811 return R__FAIL(
"expected RNTuple named '" + std::string(
ntupleName) +
"' but instead found '" +
812 std::string(
foundName) +
"' in file '" + fRawFile->GetUrl() +
"'");
822 return R__FAIL(
"RNTuple bare file: anchor checksum mismatch");
832 if (fMaxKeySize == 0 ||
nbytes <= fMaxKeySize) {
840 uint8_t *
bufCur =
reinterpret_cast<uint8_t *
>(buffer);
883 static_assert(kHeaderBlockSize % kBlockAlign == 0,
"invalid header block size");
884 if (bufferSize % kBlockAlign != 0)
885 throw RException(
R__FAIL(
"Buffer size not a multiple of alignment: " + std::to_string(bufferSize)));
886 fBlockSize = bufferSize;
890 memset(fHeaderBlock, 0, kHeaderBlockSize);
892 memset(fBlock, 0, fBlockSize);
922 if (fBlockOffset == 0) {
947 if (fBlockOffset > 0) {
952 retval = fwrite(fHeaderBlock, 1, kHeaderBlockSize, fFile);
953 if (
retval != RFileSimple::kHeaderBlockSize)
967 if ((
offset >= 0) && (
static_cast<std::uint64_t
>(
offset) != fFilePos)) {
972 if (fFilePos < kHeaderBlockSize) {
983 std::uint64_t
posInBlock = fFilePos % fBlockSize;
991 retval = fwrite(fBlock, 1, fBlockSize, fFile);
996 memset(fBlock, 0, fBlockSize);
1000 std::size_t blockSize =
nbytes;
1005 buffer =
static_cast<const unsigned char *
>(buffer) + blockSize;
1007 fFilePos += blockSize;
1013 const std::string &className,
const std::string &objectName,
const std::string &title)
1022 Write(&key, key.fKeyHeaderSize, fKeyOffset);
1040 fDirectory->GetFile()->Seek(
offset);
1041 bool rv = fDirectory->GetFile()->WriteBuffer((
char *)(buffer),
nbytes);
1091std::unique_ptr<ROOT::Experimental::Internal::RNTupleFileWriter>
1096 std::string fileName(path);
1097 size_t idxDirSep = fileName.find_last_of(
"\\/");
1110 int fd = open(std::string(path).c_str(), flags, 0666);
1127 writer->fFileName = fileName;
1132 case EContainerFormat::kBare:
1136 default:
R__ASSERT(
false &&
"Internal error: unhandled container format");
1142std::unique_ptr<ROOT::Experimental::Internal::RNTupleFileWriter>
1148 throw RException(
R__FAIL(
"invalid attempt to add an RNTuple to a directory that is not backed by a file"));
1166 fFileProper.fDirectory->WriteObject(&fNTupleAnchor, fNTupleName.c_str());
1170 buf.
SetParent(fFileProper.fDirectory->GetFile());
1171 for (
auto [
_,
info] : fStreamerInfoMap)
1174 fFileProper.fDirectory->GetFile()->Write();
1188 fFileSimple.Flush();
1192 WriteTFileNTupleKey();
1193 WriteTFileKeysList();
1194 WriteTFileStreamerInfo();
1195 WriteTFileFreeList();
1198 memcpy(fFileSimple.fHeaderBlock, &fFileSimple.fControlBlock->fHeader, fFileSimple.fControlBlock->fHeader.GetSize());
1199 R__ASSERT(fFileSimple.fControlBlock->fSeekFileRecord + fFileSimple.fControlBlock->fFileRecord.GetSize() <
1200 RFileSimple::kHeaderBlockSize);
1201 memcpy(fFileSimple.fHeaderBlock + fFileSimple.fControlBlock->fSeekFileRecord,
1202 &fFileSimple.fControlBlock->fFileRecord, fFileSimple.fControlBlock->fFileRecord.GetSize());
1204 fFileSimple.Flush();
1213 offset = fFileSimple.fKeyOffset;
1214 fFileSimple.Write(payload,
nBytes);
1215 fFileSimple.fKeyOffset +=
nBytes;
1225 const std::uint64_t
maxKeySize = fNTupleAnchor.fMaxKeySize;
1229 if (
static_cast<std::uint64_t
>(
len) >
static_cast<std::uint64_t
>(std::numeric_limits<std::uint32_t>::max()))
1290 offset = fFileSimple.fKeyOffset;
1291 fFileSimple.fKeyOffset +=
nbytes;
1316 fNTupleAnchor.fNBytesHeader =
nbytes;
1317 fNTupleAnchor.fSeekHeader =
offset;
1326 fNTupleAnchor.fNBytesFooter =
nbytes;
1327 fNTupleAnchor.fSeekFooter =
offset;
1341 fFileSimple.fControlBlock->fSeekNTuple = fFileSimple.fFilePos;
1345 fFileSimple.fKeyOffset = fFileSimple.fFilePos;
1356 for (
auto [
_,
info] : fStreamerInfoMap) {
1369 fFileSimple.fControlBlock->fHeader.SetSeekInfo(fFileSimple.fKeyOffset);
1386 fFileSimple.fControlBlock->fHeader.GetSeekInfo(), 100,
"TList",
"StreamerInfo",
1387 "Doubly linked list");
1388 fFileSimple.fControlBlock->fHeader.SetNbytesInfo(fFileSimple.fFilePos -
1389 fFileSimple.fControlBlock->fHeader.GetSeekInfo());
1400 RTFNTuple::GetSizePlusChecksum());
1402 fFileSimple.fControlBlock->fFileRecord.SetSeekKeys(fFileSimple.fKeyOffset);
1406 fFileSimple.Write(&
keyKeyList,
keyKeyList.fKeyHeaderSize, fFileSimple.fControlBlock->fFileRecord.GetSeekKeys());
1416 fFileSimple.fControlBlock->fFileRecord.fNBytesKeys =
1417 fFileSimple.fFilePos - fFileSimple.fControlBlock->fFileRecord.GetSeekKeys();
1418 fFileSimple.fKeyOffset = fFileSimple.fFilePos;
1423 fFileSimple.fControlBlock->fHeader.SetSeekFree(fFileSimple.fKeyOffset);
1429 std::uint64_t
firstFree = fFileSimple.fControlBlock->fHeader.GetSeekFree() +
keyFreeList.GetSize();
1432 fFileSimple.fControlBlock->fHeader.GetSeekFree(), 100,
"", fFileName,
"");
1433 fFileSimple.fControlBlock->fHeader.SetNbytesFree(fFileSimple.fFilePos -
1434 fFileSimple.fControlBlock->fHeader.GetSeekFree());
1435 fFileSimple.fControlBlock->fHeader.SetEnd(fFileSimple.fFilePos);
1446 fFileSimple.fControlBlock->fSeekNTuple = fFileSimple.fKeyOffset;
1448 char keyBuf[RTFNTuple::GetSizePlusChecksum()];
1454 fFileSimple.WriteKey(
keyBuf,
sizeof(
keyBuf),
sizeof(
keyBuf), fFileSimple.fControlBlock->fSeekNTuple, 100,
1455 "ROOT::RNTuple", fNTupleName,
"");
1472 fFileSimple.fControlBlock->fFileRecord.fNBytesName =
nbytesName;
1473 fFileSimple.fControlBlock->fHeader.SetNbytesName(
nbytesName);
1484 fFileSimple.fControlBlock->fSeekFileRecord = fFileSimple.fFilePos;
1485 fFileSimple.Write(&fFileSimple.fControlBlock->fFileRecord, fFileSimple.fControlBlock->fFileRecord.GetSize());
1486 fFileSimple.Write(&uuid, uuid.GetSize());
1490 for (
int i = 0; i < 3; ++i)
1492 fFileSimple.fKeyOffset = fFileSimple.fFilePos;
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
static size_t ComputeNumChunks(size_t nbytes, size_t maxChunkSize)
#define ROOT_VERSION_CODE
#define ClassDefInlineOverride(name, id)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
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 length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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
Binding & operator=(OUT(*fun)(void))
void ReadBuffer(char *&buffer) override
The RKeyBlob writes an invisible key into a TFile.
void Reserve(size_t nbytes, std::uint64_t *seekKey)
Register a new key for a data record of size nbytes.
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...
RMiniFileReader()=default
RResult< RNTuple > GetNTupleBare(std::string_view ntupleName)
Used when the file container turns out to be a bare file.
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.
void ReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset)
Reads a given byte range from the file into the provided memory buffer.
Helper class to compress data blocks in the ROOT compression frame format.
Helper class to uncompress data blocks in the ROOT compression frame format.
Write RNTuple data blocks in a TFile or a bare file container.
RNTupleFileWriter(std::string_view name, std::uint64_t maxKeySize)
std::uint64_t WriteBlob(const void *data, size_t nbytes, size_t len)
Writes a new record as an RBlob key into the file.
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...
void WriteTFileKeysList()
Write the TList with the RNTuple key.
void UpdateStreamerInfos(const RNTupleSerializer::StreamerInfoMap_t &streamerInfos)
Ensures that the streamer info records passed as argument are written to the file.
void Commit()
Writes the RNTuple key to the file so that the header and footer keys can be found.
std::uint64_t ReserveBlob(size_t nbytes, size_t len)
Reserves a new record as an RBlob key in the file.
RFileSimple fFileSimple
For simple use cases, survives without libRIO dependency.
void WriteTFileNTupleKey()
The only key that will be visible in file->ls()
void WriteTFileFreeList()
Last record in the file.
EContainerFormat
For testing purposes, RNTuple data can be written into a bare file container instead of a ROOT file.
static std::unique_ptr< RNTupleFileWriter > Recreate(std::string_view ntupleName, std::string_view path, EContainerFormat containerFormat, const RNTupleWriteOptions &options)
Create or truncate the local file given by path with the new empty RNTuple identified by ntupleName.
static std::unique_ptr< RNTupleFileWriter > Append(std::string_view ntupleName, TDirectory &fileOrDirectory, std::uint64_t maxKeySize)
The directory parameter can also be a TFile object (TFile inherits from TDirectory).
void WriteTFileSkeleton(int defaultCompression)
For a TFile container written by a C file stream, write the header and TFile object.
void WriteBareFileSkeleton(int defaultCompression)
For a bare file, which is necessarily written by a C file stream, write file header.
void WriteTFileStreamerInfo()
Write the compressed streamer info record with the description of the RNTuple class.
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...
RNTuple fNTupleAnchor
Header and footer location of the ntuple, written on Commit()
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...
RNTupleSerializer::StreamerInfoMap_t fStreamerInfoMap
Set of streamer info records that should be written to the file.
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
Base class for all ROOT issued exceptions.
Common user-tunable settings for storing ntuples.
std::size_t GetWriteBufferSize() const
int GetCompression() const
bool GetUseDirectIO() const
std::uint64_t GetMaxKeySize() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
The RRawFile provides read-only access to local and remote files.
Representation of an RNTuple data set in a ROOT file.
std::uint64_t fMaxKeySize
The maximum size for a TKey payload. Payloads bigger than this size will be written as multiple blobs...
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
void TagStreamerInfo(TVirtualStreamerInfo *info) override
Mark the classindex of the current file as using this TStreamerInfo.
void SetParent(TObject *parent)
Set parent owning this buffer.
void SetBufferOffset(Int_t offset=0)
Describe directory structure in memory.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Int_t Sizeof() const override
Return the size in bytes of the key header structure.
Int_t fVersion
Key version identifier.
Short_t fKeylen
Number of bytes for the key itself.
Long64_t fSeekKey
Location of object on file.
virtual void Create(Int_t nbytes, TFile *f=nullptr)
Create a TKey object of specified size.
TString fClassName
Object Class name.
RNTuple CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor, std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader, std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter, std::uint64_t lenFooter, std::uint64_t maxKeySize)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Helper templated class for swapping bytes; specializations for N={2,4,8} are provided below.
void Write(const void *buffer, size_t nbytes, std::int64_t offset)
Low-level writing using a TFile.
std::uint64_t WriteKey(const void *buffer, size_t nbytes, size_t len)
Writes an RBlob opaque key with the provided buffer as data record and returns the offset of the reco...
void AllocateBuffers(std::size_t bufferSize)
std::unique_ptr< ROOT::Experimental::Internal::RTFileControlBlock > fControlBlock
Keeps track of TFile control structures, which need to be updated on committing the data set.
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.
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 ...
If a TFile container is written by a C stream (simple file), on dataset commit, the file header and t...
std::uint64_t fSeekNTuple
std::uint64_t fSeekFileRecord