Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RNTuple.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTuple.hxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2023-09-19
4
5/*************************************************************************
6 * Copyright (C) 1995-2023, 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_RNTuple
14#define ROOT_RNTuple
15
16#include <Rtypes.h>
17
18#include <cstdint>
19
20class TCollection;
21class TFile;
22class TFileMergeInfo;
23
24namespace ROOT {
25
26class RNTuple;
27
28namespace Internal {
29class RPageSourceFile;
31
32RNTuple CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
33 std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader,
34 std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter,
35 std::uint64_t lenFooter, std::uint64_t maxKeySize);
36
37} // namespace Internal
38
39// clang-format off
40/**
41\class ROOT::RNTuple
42\ingroup NTuple
43\brief Representation of an RNTuple data set in a ROOT file
44
45\note This is the documentation for the RNTuple anchor class. For a generic introduction to RNTuple, see \ref NTuple "the RNTuple Introduction". For reading RNTuples, see RNTupleReader. For writing RNTuples, see RNTupleWriter.
46For exploring the contents of an RNTuple, use ROOT::RDataFrame. See \ref rosetta-stone for examples how to draw and scan the contents.
47
48The class points to the header and footer keys, which in turn have the references to the pages (via page lists).
49Only the RNTuple key will be listed in the list of keys. Like TBaskets, the pages are "invisible" keys.
50Byte offset references in the RNTuple header and footer reference directly the data part of page records,
51skipping the TFile key part.
52
53In the list of keys, this object appears as "ROOT::RNTuple".
54It is the user-facing representation of an RNTuple data set in a ROOT file and
55it provides an API entry point to an RNTuple stored in a ROOT file. Its main purpose is to
56construct a page source for an RNTuple, which in turn can be used to read an RNTuple with an RDF or
57an RNTupleReader.
58
59For instance, for an RNTuple called "Events" in a ROOT file, usage can be
60~~~ {.cpp}
61auto f = TFile::Open("data.root");
62auto ntpl = f->Get<ROOT::RNTuple>("Events");
63auto reader = RNTupleReader::Open(ntpl);
64~~~
65*/
66// clang-format on
67class RNTuple final {
70
71 friend ROOT::RNTuple
72 Internal::CreateAnchor(std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor,
73 std::uint16_t versionPatch, std::uint64_t seekHeader, std::uint64_t nbytesHeader,
74 std::uint64_t lenHeader, std::uint64_t seekFooter, std::uint64_t nbytesFooter,
75 std::uint64_t lenFooter, std::uint64_t maxKeySize);
76
77public:
78 static constexpr std::uint16_t kVersionEpoch = 1;
79 static constexpr std::uint16_t kVersionMajor = 0;
80 static constexpr std::uint16_t kVersionMinor = 2;
81 static constexpr std::uint16_t kVersionPatch = 0;
82
83 /// Returns the RNTuple version in the following form:
84 /// Epoch: 2 most significant bytes
85 /// Major: next 2 bytes
86 /// Minor: next 2 bytes
87 /// Patch: 2 least significant bytes
88 /// This integer can be compared with that of another RNTuple to determine which one has the highest overall version.
89 static constexpr std::uint64_t GetCurrentVersion()
90 {
91 return (static_cast<std::uint64_t>(kVersionEpoch) << 48) | (static_cast<std::uint64_t>(kVersionMajor) << 32) |
92 (static_cast<std::uint64_t>(kVersionMinor) << 16) | (static_cast<std::uint64_t>(kVersionPatch));
93 }
94
95private:
96 /// Version of the RNTuple binary format that the writer supports (see specification).
97 /// Changing the epoch indicates backward-incompatible changes
99 /// Changing the major version indicates forward incompatible changes; such changes should correspond to a new
100 /// bit in the feature flag of the RNTuple header.
101 /// For the pre-release epoch 0, indicates the release candidate number
103 /// Changing the minor version indicates new optional fields added to the RNTuple metadata
105 /// Changing the patch version indicates clarifications or new backported features from newer binary format versions
107 /// The file offset of the header excluding the TKey part
108 std::uint64_t fSeekHeader = 0;
109 /// The size of the compressed ntuple header
110 std::uint64_t fNBytesHeader = 0;
111 /// The size of the uncompressed ntuple header
112 std::uint64_t fLenHeader = 0;
113 /// The file offset of the footer excluding the TKey part
114 std::uint64_t fSeekFooter = 0;
115 /// The size of the compressed ntuple footer
116 std::uint64_t fNBytesFooter = 0;
117 /// The size of the uncompressed ntuple footer
118 std::uint64_t fLenFooter = 0;
119 /// The maximum size for a TKey payload. Payloads bigger than this size will be written as multiple blobs.
120 std::uint64_t fMaxKeySize = 0;
121
122 TFile *fFile = nullptr; ///<! The file from which the ntuple was streamed, registered in the custom streamer
123
124public:
125 RNTuple() = default;
126 ~RNTuple() = default;
127
128 std::uint16_t GetVersionEpoch() const { return fVersionEpoch; }
129 std::uint16_t GetVersionMajor() const { return fVersionMajor; }
130 std::uint16_t GetVersionMinor() const { return fVersionMinor; }
131 std::uint16_t GetVersionPatch() const { return fVersionPatch; }
132
133 std::uint64_t GetSeekHeader() const { return fSeekHeader; }
134 std::uint64_t GetNBytesHeader() const { return fNBytesHeader; }
135 std::uint64_t GetLenHeader() const { return fLenHeader; }
136
137 std::uint64_t GetSeekFooter() const { return fSeekFooter; }
138 std::uint64_t GetNBytesFooter() const { return fNBytesFooter; }
139 std::uint64_t GetLenFooter() const { return fLenFooter; }
140 std::uint64_t GetMaxKeySize() const { return fMaxKeySize; }
141
142 /// RNTuple implements the hadd MergeFile interface
143 /// Merge this NTuple with the input list entries
144 Long64_t Merge(TCollection *input, TFileMergeInfo *mergeInfo);
145
146 /// NOTE: if you change this version you also need to update RTFNTuple::fClassVersion in RMiniFile.cxx
148}; // class RNTuple
149
150} // namespace ROOT
151
152#endif
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
#define ClassDefNV(name, id)
Definition Rtypes.h:352
Write RNTuple data blocks in a TFile or a bare file container.
Storage provider that reads ntuple pages from a file.
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:67
Long64_t Merge(TCollection *input, TFileMergeInfo *mergeInfo)
RNTuple implements the hadd MergeFile interface Merge this NTuple with the input list entries.
std::uint64_t fSeekFooter
The file offset of the footer excluding the TKey part.
Definition RNTuple.hxx:114
std::uint64_t fNBytesFooter
The size of the compressed ntuple footer.
Definition RNTuple.hxx:116
std::uint64_t GetLenFooter() const
Definition RNTuple.hxx:139
static constexpr std::uint16_t kVersionPatch
Definition RNTuple.hxx:81
std::uint64_t GetSeekHeader() const
Definition RNTuple.hxx:133
std::uint16_t fVersionMinor
Changing the minor version indicates new optional fields added to the RNTuple metadata.
Definition RNTuple.hxx:104
static constexpr std::uint16_t kVersionMajor
Definition RNTuple.hxx:79
RNTuple()=default
std::uint16_t GetVersionMajor() const
Definition RNTuple.hxx:129
std::uint64_t fSeekHeader
The file offset of the header excluding the TKey part.
Definition RNTuple.hxx:108
std::uint64_t GetNBytesFooter() const
Definition RNTuple.hxx:138
static constexpr std::uint16_t kVersionEpoch
Definition RNTuple.hxx:78
std::uint64_t GetNBytesHeader() const
Definition RNTuple.hxx:134
std::uint64_t fMaxKeySize
The maximum size for a TKey payload. Payloads bigger than this size will be written as multiple blobs...
Definition RNTuple.hxx:120
~RNTuple()=default
std::uint16_t GetVersionMinor() const
Definition RNTuple.hxx:130
std::uint64_t fNBytesHeader
The size of the compressed ntuple header.
Definition RNTuple.hxx:110
static constexpr std::uint64_t GetCurrentVersion()
Returns the RNTuple version in the following form: Epoch: 2 most significant bytes Major: next 2 byte...
Definition RNTuple.hxx:89
std::uint64_t fLenHeader
The size of the uncompressed ntuple header.
Definition RNTuple.hxx:112
std::uint16_t GetVersionPatch() const
Definition RNTuple.hxx:131
std::uint64_t fLenFooter
The size of the uncompressed ntuple footer.
Definition RNTuple.hxx:118
std::uint64_t GetMaxKeySize() const
Definition RNTuple.hxx:140
std::uint64_t GetLenHeader() const
Definition RNTuple.hxx:135
std::uint16_t fVersionPatch
Changing the patch version indicates clarifications or new backported features from newer binary form...
Definition RNTuple.hxx:106
TFile * fFile
! The file from which the ntuple was streamed, registered in the custom streamer
Definition RNTuple.hxx:122
std::uint16_t fVersionMajor
Changing the major version indicates forward incompatible changes; such changes should correspond to ...
Definition RNTuple.hxx:102
std::uint64_t GetSeekFooter() const
Definition RNTuple.hxx:137
static constexpr std::uint16_t kVersionMinor
Definition RNTuple.hxx:80
std::uint16_t fVersionEpoch
Version of the RNTuple binary format that the writer supports (see specification).
Definition RNTuple.hxx:98
std::uint16_t GetVersionEpoch() const
Definition RNTuple.hxx:128
Collection abstract base class.
Definition TCollection.h:65
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
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:51