Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTuple.cxx
Go to the documentation of this file.
1/// \file RNTuple.cxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2023-09-19
5
6/*************************************************************************
7 * Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#include <ROOT/RError.hxx>
15#include <ROOT/RNTuple.hxx>
16#include <ROOT/RPageStorage.hxx>
18
19#include <TBuffer.h>
20#include <TError.h>
21#include <TFile.h>
22
23#include <xxhash.h>
24
26{
27 if (buf.IsReading()) {
28 // Skip byte count and class version
29 auto offCkData = buf.Length() + sizeof(UInt_t) + sizeof(Version_t);
31 std::uint64_t expectedChecksum = XXH3_64bits(buf.Buffer() + offCkData, buf.Length() - offCkData);
32
33 std::uint64_t onDiskChecksum;
34 if (static_cast<std::size_t>(buf.BufferSize()) < buf.Length() + sizeof(onDiskChecksum))
35 throw RException(R__FAIL("the buffer containing RNTuple is too small to contain the checksum!"));
36 buf >> onDiskChecksum;
37
39 throw RException(R__FAIL("checksum mismatch in RNTuple anchor"));
40
41 R__ASSERT(buf.GetParent() && buf.GetParent()->InheritsFrom("TFile"));
42 fFile = static_cast<TFile *>(buf.GetParent());
43 } else {
44 auto offCkData = buf.Length() + sizeof(UInt_t) + sizeof(Version_t);
46 std::uint64_t checksum = XXH3_64bits(buf.Buffer() + offCkData, buf.Length() - offCkData);
47 buf << checksum;
48 }
49}
50
52ROOT::Internal::CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
53 std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader,
54 std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter,
55 std::uint64_t lenFooter, std::uint64_t maxKeySize)
56{
58 ntuple.fVersionEpoch = versionEpoch;
59 ntuple.fVersionMajor = versionMajor;
60 ntuple.fVersionMinor = versionMinor;
61 ntuple.fVersionPatch = versionPatch;
62 ntuple.fSeekHeader = seekHeader;
63 ntuple.fNBytesHeader = nbytesHeader;
64 ntuple.fLenHeader = lenHeader;
65 ntuple.fSeekFooter = seekFooter;
66 ntuple.fNBytesFooter = nbytesFooter;
67 ntuple.fLenFooter = lenFooter;
68 ntuple.fMaxKeySize = maxKeySize;
69 return ntuple;
70}
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:299
short Version_t
Definition RtypesCore.h:65
unsigned int UInt_t
Definition RtypesCore.h:46
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.
Definition TError.h:125
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:67
void Streamer(TBuffer &)
Definition RNTuple.cxx:25
static TClass * Class()
TFile * fFile
! The file from which the ntuple was streamed, registered in the custom streamer
Definition RNTuple.hxx:110
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TObject * GetParent() const
Return pointer to parent of this buffer.
Definition TBuffer.cxx:262
Int_t BufferSize() const
Definition TBuffer.h:98
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Int_t Length() const
Definition TBuffer.h:100
char * Buffer() const
Definition TBuffer.h:96
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
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)
Definition RNTuple.cxx:52