Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTuple.cxx
Go to the documentation of this file.
1/// \file RNTuple.cxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2023-09-19
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#include <ROOT/RError.hxx>
17#include <ROOT/RNTuple.hxx>
18#include <ROOT/RPageStorage.hxx>
20
21#include <TBuffer.h>
22#include <TError.h>
23#include <TFile.h>
24
25#include <xxhash.h>
26
28{
29 if (buf.IsReading()) {
30 // Skip byte count and class version
31 auto offCkData = buf.Length() + sizeof(UInt_t) + sizeof(Version_t);
33 std::uint64_t expectedChecksum = XXH3_64bits(buf.Buffer() + offCkData, buf.Length() - offCkData);
34
35 std::uint64_t onDiskChecksum;
36 if (static_cast<std::size_t>(buf.BufferSize()) < buf.Length() + sizeof(onDiskChecksum))
37 throw RException(R__FAIL("the buffer containing RNTuple is too small to contain the checksum!"));
38 buf >> onDiskChecksum;
39
41 throw RException(R__FAIL("checksum mismatch in RNTuple anchor"));
42
43 R__ASSERT(buf.GetParent() && buf.GetParent()->InheritsFrom("TFile"));
44 fFile = static_cast<TFile *>(buf.GetParent());
45 } else {
46 auto offCkData = buf.Length() + sizeof(UInt_t) + sizeof(Version_t);
48 std::uint64_t checksum = XXH3_64bits(buf.Buffer() + offCkData, buf.Length() - offCkData);
49 buf << checksum;
50 }
51}
52
54 std::uint16_t versionMinor, std::uint16_t versionPatch,
55 std::uint64_t seekHeader, std::uint64_t nbytesHeader,
56 std::uint64_t lenHeader, std::uint64_t seekFooter,
57 std::uint64_t nbytesFooter, std::uint64_t lenFooter,
58 std::uint64_t maxKeySize)
59{
61 ntuple.fVersionEpoch = versionEpoch;
62 ntuple.fVersionMajor = versionMajor;
63 ntuple.fVersionMinor = versionMinor;
64 ntuple.fVersionPatch = versionPatch;
65 ntuple.fSeekHeader = seekHeader;
66 ntuple.fNBytesHeader = nbytesHeader;
67 ntuple.fLenHeader = lenHeader;
68 ntuple.fSeekFooter = seekFooter;
69 ntuple.fNBytesFooter = nbytesFooter;
70 ntuple.fLenFooter = lenFooter;
71 ntuple.fMaxKeySize = maxKeySize;
72 return ntuple;
73}
#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:69
void Streamer(TBuffer &)
Definition RNTuple.cxx:27
static TClass * Class()
TFile * fFile
! The file from which the ntuple was streamed, registered in the custom streamer
Definition RNTuple.hxx:111
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:542
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:53