49#ifndef R__LITTLE_ENDIAN
52#define R__LITTLE_ENDIAN 1
54#define R__LITTLE_ENDIAN 0
70 std::uint16_t fValBE = 0;
71 static std::uint16_t Swap(std::uint16_t val)
73#if R__LITTLE_ENDIAN == 1
74 return RByteSwap<
sizeof(val)>::bswap(val);
81 RUInt16BE() =
default;
82 explicit RUInt16BE(
const std::uint16_t val) : fValBE(Swap(val)) {}
83 operator std::uint16_t()
const {
return Swap(fValBE); }
84 RUInt16BE &
operator=(
const std::uint16_t val)
94 std::uint32_t fValBE = 0;
95 static std::uint32_t Swap(std::uint32_t val)
97#if R__LITTLE_ENDIAN == 1
98 return RByteSwap<
sizeof(val)>::bswap(val);
105 RUInt32BE() =
default;
106 explicit RUInt32BE(
const std::uint32_t val) : fValBE(Swap(val)) {}
107 operator std::uint32_t()
const {
return Swap(fValBE); }
108 RUInt32BE &
operator=(
const std::uint32_t val)
118 std::int32_t fValBE = 0;
119 static std::int32_t Swap(std::int32_t val)
121#if R__LITTLE_ENDIAN == 1
122 return RByteSwap<
sizeof(val)>::bswap(val);
129 RInt32BE() =
default;
130 explicit RInt32BE(
const std::int32_t val) : fValBE(Swap(val)) {}
131 operator std::int32_t()
const {
return Swap(fValBE); }
132 RInt32BE &
operator=(
const std::int32_t val)
142 std::uint64_t fValBE = 0;
143 static std::uint64_t Swap(std::uint64_t val)
145#if R__LITTLE_ENDIAN == 1
146 return RByteSwap<
sizeof(val)>::bswap(val);
153 RUInt64BE() =
default;
154 explicit RUInt64BE(
const std::uint64_t val) : fValBE(Swap(val)) {}
155 operator std::uint64_t()
const {
return Swap(fValBE); }
156 RUInt64BE &
operator=(
const std::uint64_t val)
166 unsigned char fLName{0};
168 RTFString() =
default;
169 RTFString(
const std::string &str)
174 fLName = str.length();
175 memcpy(fData, str.data(), fLName);
177 std::size_t GetSize()
const
191 auto now = std::chrono::system_clock::now();
192 auto tt = std::chrono::system_clock::to_time_t(
now);
194 fDatetime = (
tm.tm_year + 1900 - 1995) << 26 | (
tm.tm_mon + 1) << 22 |
tm.tm_mday << 17 |
tm.tm_hour << 12 |
195 tm.tm_min << 6 |
tm.tm_sec;
197 explicit RTFDatetime(RUInt32BE val) : fDatetime(val) {}
202 static constexpr unsigned kBigKeyVersion = 1000;
205 RUInt16BE fVersion{4};
206 RUInt32BE fObjLen{0};
207 RTFDatetime fDatetime;
208 RUInt16BE fKeyLen{0};
212 RUInt32BE fSeekKey{0};
213 RUInt32BE fSeekPdir{0};
216 RUInt64BE fSeekKey{0};
217 RUInt64BE fSeekPdir{0};
221 RTFKey() : fInfoLong() {}
228 fVersion = fVersion + kBigKeyVersion;
237 std::uint32_t GetSize()
const
245 std::uint32_t GetHeaderSize()
const
247 if (fVersion >= kBigKeyVersion)
248 return 18 +
sizeof(fInfoLong);
249 return 18 +
sizeof(fInfoShort);
252 std::uint64_t GetSeekKey()
const
254 if (fVersion >= kBigKeyVersion)
255 return fInfoLong.fSeekKey;
256 return fInfoShort.fSeekKey;
262 static constexpr unsigned kBEGIN = 100;
263 static constexpr unsigned kBigHeaderVersion = 1000000;
265 char fMagic[4]{
'r',
'o',
'o',
't'};
272 RUInt32BE fSeekFree{0};
273 RUInt32BE fNbytesFree{0};
275 RUInt32BE fNbytesName{0};
276 unsigned char fUnits{4};
277 RUInt32BE fCompress{0};
278 RUInt32BE fSeekInfo{0};
279 RUInt32BE fNbytesInfo{0};
283 RUInt64BE fSeekFree{0};
284 RUInt32BE fNbytesFree{0};
286 RUInt32BE fNbytesName{0};
287 unsigned char fUnits{8};
288 RUInt32BE fCompress{0};
289 RUInt64BE fSeekInfo{0};
290 RUInt32BE fNbytesInfo{0};
294 RTFHeader() : fInfoShort() {}
299 if (fVersion >= kBigHeaderVersion)
303 std::uint32_t end = fInfoShort.fEND;
304 std::uint32_t
seekFree = fInfoShort.fSeekFree;
305 std::uint32_t
nbytesFree = fInfoShort.fNbytesFree;
306 std::uint32_t
nFree = fInfoShort.fNfree;
307 std::uint32_t
nbytesName = fInfoShort.fNbytesName;
308 std::uint32_t
compress = fInfoShort.fCompress;
309 std::uint32_t
seekInfo = fInfoShort.fSeekInfo;
310 std::uint32_t
nbytesInfo = fInfoShort.fNbytesInfo;
311 fInfoLong.fEND = end;
314 fInfoLong.fNfree =
nFree;
316 fInfoLong.fUnits = 8;
320 fVersion = fVersion + kBigHeaderVersion;
326 return (fVersion >= kBigHeaderVersion) ||
327 (
offset >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max()));
330 std::uint32_t GetSize()
const
332 std::uint32_t
sizeHead =
sizeof(fMagic) +
sizeof(fVersion) +
sizeof(fBEGIN);
334 return sizeHead +
sizeof(fInfoLong);
335 return sizeHead +
sizeof(fInfoShort);
338 std::uint64_t GetEnd()
const
341 return fInfoLong.fEND;
342 return fInfoShort.fEND;
349 fInfoLong.fEND =
value;
351 fInfoShort.fEND =
value;
355 std::uint64_t GetSeekFree()
const
358 return fInfoLong.fSeekFree;
359 return fInfoShort.fSeekFree;
366 fInfoLong.fSeekFree =
value;
368 fInfoShort.fSeekFree =
value;
375 fInfoLong.fNbytesFree =
value;
377 fInfoShort.fNbytesFree =
value;
384 fInfoLong.fNbytesName =
value;
386 fInfoShort.fNbytesName =
value;
390 std::uint64_t GetSeekInfo()
const
393 return fInfoLong.fSeekInfo;
394 return fInfoShort.fSeekInfo;
401 fInfoLong.fSeekInfo =
value;
403 fInfoShort.fSeekInfo =
value;
410 fInfoLong.fNbytesInfo =
value;
412 fInfoShort.fNbytesInfo =
value;
416 void SetCompression(std::uint32_t
value)
419 fInfoLong.fCompress =
value;
421 fInfoShort.fCompress =
value;
428 static constexpr unsigned kBigFreeEntryVersion = 1000;
430 RUInt16BE fVersion{1};
442 RTFFreeEntry() : fInfoShort() {}
443 void Set(std::uint64_t first, std::uint64_t last)
445 if (last >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max())) {
446 fVersion = fVersion + kBigFreeEntryVersion;
447 fInfoLong.fFirst = first;
448 fInfoLong.fLast = last;
450 fInfoShort.fFirst = first;
451 fInfoShort.fLast = last;
454 std::uint32_t GetSize() {
return (fVersion >= kBigFreeEntryVersion) ? 18 : 10; }
460 std::uint32_t GetSize()
const {
return sizeof(RTFKeyList); }
461 explicit RTFKeyList(std::uint32_t
nKeys) : fNKeys(
nKeys) {}
466 static constexpr unsigned kBigFileVersion = 1000;
468 RUInt16BE fClassVersion{5};
471 RUInt32BE fNBytesKeys{0};
472 RUInt32BE fNBytesName{0};
476 RUInt32BE fSeekDir{RTFHeader::kBEGIN};
477 RUInt32BE fSeekParent{0};
478 RUInt32BE fSeekKeys{0};
481 RUInt64BE fSeekDir{RTFHeader::kBEGIN};
482 RUInt64BE fSeekParent{0};
483 RUInt64BE fSeekKeys{0};
487 RTFDirectory() : fInfoShort() {}
490 std::uint32_t GetSize()
const
492 if (fClassVersion >= kBigFileVersion)
493 return sizeof(RTFDirectory);
494 return 18 +
sizeof(fInfoShort);
497 std::uint64_t GetSeekKeys()
const
499 if (fClassVersion >= kBigFileVersion)
500 return fInfoLong.fSeekKeys;
501 return fInfoShort.fSeekKeys;
506 if (
seekKeys >
static_cast<unsigned int>(std::numeric_limits<std::int32_t>::max())) {
507 std::uint32_t
seekDir = fInfoShort.fSeekDir;
508 std::uint32_t
seekParent = fInfoShort.fSeekParent;
512 fClassVersion = fClassVersion + kBigFileVersion;
521 RUInt16BE fVersionClass{1};
522 unsigned char fUUID[16];
527 char *buffer =
reinterpret_cast<char *
>(
this);
529 assert(
reinterpret_cast<RTFUUID *
>(buffer) <= (
this + 1));
531 std::uint32_t GetSize()
const {
return sizeof(RTFUUID); }
540 RUInt32BE fByteCount{0x40000000 | (
sizeof(RTFNTuple) -
sizeof(fByteCount))};
541 RUInt16BE fVersionClass{2};
542 RUInt16BE fVersionEpoch{0};
543 RUInt16BE fVersionMajor{0};
544 RUInt16BE fVersionMinor{0};
545 RUInt16BE fVersionPatch{0};
546 RUInt64BE fSeekHeader{0};
547 RUInt64BE fNBytesHeader{0};
548 RUInt64BE fLenHeader{0};
549 RUInt64BE fSeekFooter{0};
550 RUInt64BE fNBytesFooter{0};
551 RUInt64BE fLenFooter{0};
552 RUInt64BE fMaxKeySize{0};
554 static constexpr std::uint32_t
GetSizePlusChecksum() {
return sizeof(RTFNTuple) +
sizeof(std::uint64_t); }
556 RTFNTuple() =
default;
571 std::uint32_t GetSize()
const {
return sizeof(RTFNTuple); }
573 std::uint32_t
GetOffsetCkData() {
return sizeof(fByteCount) +
sizeof(fVersionClass); }
579struct RBareFileHeader {
580 char fMagic[7]{
'r',
'n',
't',
'u',
'p',
'l',
'e'};
583 RUInt32BE fFormatVersion{1};
584 RUInt32BE fCompress{0};
671 if (std::string(
ident, 4) ==
"root")
680 std::string_view typeName)
693 for (
unsigned int i = 0; i <
nKeys; ++i) {
697 offset += key.GetHeaderSize();
701 if (std::string_view(
name.fData,
name.fLName) != typeName) {
709 return key.GetSeekKey();
738 auto pos = std::string::npos;
745 return R__FAIL(
"no directory named '" + std::string(
directoryName) +
"' in file '" + fRawFile->GetUrl() +
"'");
748 offset = key.GetSeekKey() + key.fKeyLen;
755 return R__FAIL(
"no RNTuple named '" + std::string(
ntupleName) +
"' in file '" + fRawFile->GetUrl() +
"'");
759 offset = key.GetSeekKey() + key.fKeyLen;
763 static_assert(
kMinNTupleSize == RTFNTuple::GetSizePlusChecksum());
765 return R__FAIL(
"invalid anchor size: " + std::to_string(key.fObjLen) +
" < " + std::to_string(
sizeof(RTFNTuple)));
768 const auto objNbytes = key.GetSize() - key.fKeyLen;
799 ckOnDisk =
static_cast<uint64_t
>(*ckOnDiskPtr);
801 return R__FAIL(
"RNTuple anchor checksum mismatch");
819 return R__FAIL(
"expected RNTuple named '" + std::string(
ntupleName) +
"' but instead found '" +
820 std::string(
foundName) +
"' in file '" + fRawFile->GetUrl() +
"'");
830 return R__FAIL(
"RNTuple bare file: anchor checksum mismatch");
840 if (fMaxKeySize == 0 ||
nbytes <= fMaxKeySize) {
848 uint8_t *
bufCur =
reinterpret_cast<uint8_t *
>(buffer);
890 unsigned char buffer[kBlobKeyLen])
917 static_assert(kHeaderBlockSize % kBlockAlign == 0,
"invalid header block size");
918 if (bufferSize % kBlockAlign != 0)
919 throw RException(
R__FAIL(
"Buffer size not a multiple of alignment: " + std::to_string(bufferSize)));
920 fBlockSize = bufferSize;
924 memset(fHeaderBlock, 0, kHeaderBlockSize);
926 memset(fBlock, 0, fBlockSize);
956 if (fBlockOffset == 0) {
981 if (fBlockOffset > 0) {
986 retval = fwrite(fHeaderBlock, 1, kHeaderBlockSize, fFile);
987 if (
retval != RFileSimple::kHeaderBlockSize)
1000 if ((
offset >= 0) && (
static_cast<std::uint64_t
>(
offset) != fFilePos)) {
1005 if (fFilePos < kHeaderBlockSize) {
1016 std::uint64_t
posInBlock = fFilePos % fBlockSize;
1024 retval = fwrite(fBlock, 1, fBlockSize, fFile);
1025 if (
retval != fBlockSize)
1029 memset(fBlock, 0, fBlockSize);
1033 std::size_t blockSize =
nbytes;
1038 buffer =
static_cast<const unsigned char *
>(buffer) + blockSize;
1040 fFilePos += blockSize;
1047 const std::string &className,
const std::string &objectName,
1048 const std::string &title)
1057 Write(&key, key.GetHeaderSize(), fKeyOffset);
1092 fDirectory->GetFile()->Seek(
offset);
1093 bool rv = fDirectory->GetFile()->WriteBuffer((
char *)(buffer),
nbytes);
1115 if (
keyBlob.WasAllocatedInAFreeSlot()) {
1133 fileSimple.fControlBlock = std::make_unique<ROOT::Internal::RTFileControlBlock>();
1141std::unique_ptr<ROOT::Internal::RNTupleFileWriter>
1145 std::string fileName(path);
1146 size_t idxDirSep = fileName.find_last_of(
"\\/");
1159 int fd = open(std::string(path).c_str(), flags, 0666);
1182 writer->fFileName = fileName;
1187 case EContainerFormat::kBare:
1191 default:
R__ASSERT(
false &&
"Internal error: unhandled container format");
1197std::unique_ptr<ROOT::Internal::RNTupleFileWriter>
1203 throw RException(
R__FAIL(
"invalid attempt to add an RNTuple to a directory that is not backed by a file"));
1230 if (
auto fileProper = std::get_if<RFileProper>(&fFile)) {
1232 fileProper->fDirectory->WriteObject(&fNTupleAnchor, fNTupleName.c_str());
1237 for (
auto [
_,
info] : fStreamerInfoMap)
1245 auto &
fileSimple = std::get<RFileSimple>(fFile);
1261 WriteTFileFreeList();
1266 RFileSimple::kHeaderBlockSize);
1268 fileSimple.fControlBlock->fFileRecord.GetSize());
1281 const std::uint64_t
maxKeySize = fNTupleAnchor.fMaxKeySize;
1285 if (
static_cast<std::uint64_t
>(
len) >
static_cast<std::uint64_t
>(std::numeric_limits<std::uint32_t>::max()))
1345 if (
auto *
fileSimple = std::get_if<RFileSimple>(&fFile)) {
1353 auto &
fileProper = std::get<RFileProper>(fFile);
1361 if (
auto *
fileSimple = std::get_if<RFileSimple>(&fFile)) {
1364 auto &
fileProper = std::get<RFileProper>(fFile);
1373 fNTupleAnchor.fNBytesHeader =
nbytes;
1374 fNTupleAnchor.fSeekHeader =
offset;
1382 fNTupleAnchor.fNBytesFooter =
nbytes;
1383 fNTupleAnchor.fSeekFooter =
offset;
1391 auto &
fileSimple = std::get<RFileSimple>(fFile);
1413 for (
auto [
_,
info] : fStreamerInfoMap) {
1426 auto &
fileSimple = std::get<RFileSimple>(fFile);
1443 fileSimple.fControlBlock->fHeader.GetSeekInfo(), RTFHeader::kBEGIN,
"TList",
"StreamerInfo",
1444 "Doubly linked list");
1446 fileSimple.fControlBlock->fHeader.GetSeekInfo());
1456 auto &
fileSimple = std::get<RFileSimple>(fFile);
1474 fileSimple.fControlBlock->fFileRecord.fNBytesKeys =
1481 auto &
fileSimple = std::get<RFileSimple>(fFile);
1491 fileSimple.fControlBlock->fHeader.GetSeekFree(), RTFHeader::kBEGIN,
"", fFileName,
"");
1493 fileSimple.fControlBlock->fHeader.GetSeekFree());
1505 auto &
fileSimple = std::get<RFileSimple>(fFile);
1508 char keyBuf[RTFNTuple::GetSizePlusChecksum()];
1515 char zipAnchor[RTFNTuple::GetSizePlusChecksum()];
1519 "ROOT::RNTuple", fNTupleName,
"");
1529 auto &
fileSimple = std::get<RFileSimple>(fFile);
1556 for (
int i = 0; i < 3; ++i)
#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.
bool WasAllocatedInAFreeSlot() const
void Reserve(size_t nbytes, std::uint64_t *seekKey)
Register a new key for a data record of size nbytes.
void ReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset)
Reads a given byte range from the file into the provided memory buffer.
RMiniFileReader()=default
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.
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...
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.
Helper class to compress data blocks in the ROOT compression frame format.
static std::size_t Zip(const void *from, std::size_t nbytes, int compression, void *to)
Returns the size of the compressed data, written into the provided output buffer.
Helper class to uncompress data blocks in the ROOT compression frame format.
static void Unzip(const void *from, size_t nbytes, size_t dataLen, void *to)
The nbytes parameter provides the size ls of the from buffer.
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.
void WriteTFileStreamerInfo(int compression)
Write the compressed streamer info record with the description of the RNTuple class.
RNTupleFileWriter(std::string_view name, std::uint64_t maxKeySize)
void WriteTFileKeysList(std::uint64_t anchorSize)
Write the TList with the RNTuple key.
std::uint64_t WriteTFileNTupleKey(int compression)
The only key that will be visible in file->ls() Returns the size on disk of the anchor object.
void WriteBareFileSkeleton(int defaultCompression)
For a bare file, which is necessarily written by a C file stream, write file header.
void Commit(int compression=RCompressionSetting::EDefaults::kUseGeneralPurpose)
Writes the RNTuple key to the file so that the header and footer keys can be found.
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...
void WriteTFileFreeList()
Last record in the file.
void WriteTFileSkeleton(int defaultCompression)
For a TFile container written by a C file stream, write the header and TFile object.
void Seek(std::uint64_t offset)
Seek a simple writer to offset.
std::variant< RFileSimple, RFileProper > fFile
RFileSimple: for simple use cases, survives without libRIO dependency RFileProper: for updating exist...
ROOT::Internal::RNTupleSerializer::StreamerInfoMap_t fStreamerInfoMap
Set of streamer info records that should be written to the file.
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 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).
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...
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.
A helper class for serializing and deserialization of the RNTuple binary format.
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
The RRawFile provides read-only access to local and remote files.
Base class for all ROOT issued exceptions.
Common user-tunable settings for storing RNTuples.
std::size_t GetWriteBufferSize() const
std::uint64_t GetMaxKeySize() const
bool GetUseDirectIO() const
std::uint32_t GetCompression() const
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 class is used as a return type for operations that can fail; wraps a value of type T or an RError...
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.
Int_t fLeft
Number of bytes left in current segment.
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.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
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)
std::unique_ptr< T[]> MakeUninitArray(std::size_t size)
Make an array of default-initialized elements.
Namespace for new ROOT classes and functions.
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 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.
void AllocateBuffers(std::size_t bufferSize)
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.
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 ...
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.
If a TFile container is written by a C stream (simple file), on dataset commit, the file header and t...
std::uint64_t fSeekFileRecord
std::uint64_t fSeekNTuple