Logo ROOT   6.18/05
Reference Guide
RNTupleDescriptor.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleDescriptor.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-07-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-2019, 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#ifndef ROOT7_RNTupleDescriptor
17#define ROOT7_RNTupleDescriptor
18
19#include <ROOT/RColumnModel.hxx>
20#include <ROOT/RNTupleUtil.hxx>
21#include <ROOT/RStringView.hxx>
22
23#include <vector>
24#include <string>
25#include <unordered_map>
26
27namespace ROOT {
28namespace Experimental {
29
30class RNTupleDescriptorBuilder;
31
34
35private:
39 /// The leaf name, not including parent fields
40 std::string fFieldName;
41 /// The C++ type that was used when writing the field
42 std::string fTypeName;
43 /// The structural information carried by this field in the data model tree
45 /// Establishes sub field trees, such as classes and collections
47 /// For pointers and optional/variant fields, the pointee field(s)
48 std::vector<DescriptorId_t> fLinkIds;
49
50public:
51 DescriptorId_t GetId() const { return fFieldId; }
54 std::string GetFieldName() const { return fFieldName; }
55 std::string GetTypeName() const { return fTypeName; }
58 std::vector<DescriptorId_t> GetLinkIds() const { return fLinkIds; }
59};
60
61
64
65private:
69 /// Every column belongs to one and only one field
71 /// Pointer to the parent column with offsets
73 /// For index and offset columns of collections, pointers and variants, the pointee field(s)
74 std::vector<DescriptorId_t> fLinkIds;
75
76public:
77 DescriptorId_t GetId() const { return fColumnId; }
79 RColumnModel GetModel() const { return fModel; }
82 std::vector<DescriptorId_t> GetLinkIds() { return fLinkIds; }
83};
84
85
88
89public:
90 struct RColumnInfo {
94 };
95
96private:
101 std::unordered_map<DescriptorId_t, RColumnInfo> fColumnInfos;
102
103public:
104 DescriptorId_t GetId() const { return fClusterId; }
108 RColumnInfo GetColumnInfo(DescriptorId_t columnId) const { return fColumnInfos.at(columnId); }
109};
110
111
112/**
113 * Represents the on-disk (on storage) information about an ntuple. This can, for instance, be used
114 * by 3rd party utilies.
115 */
118
119private:
121 std::string fName;
122
123 std::unordered_map<DescriptorId_t, RFieldDescriptor> fFieldDescriptors;
124 std::unordered_map<DescriptorId_t, RColumnDescriptor> fColumnDescriptors;
125 std::unordered_map<DescriptorId_t, RClusterDescriptor> fClusterDescriptors;
126
127public:
128 const RFieldDescriptor& GetFieldDescriptor(DescriptorId_t fieldId) const { return fFieldDescriptors.at(fieldId); }
130 return fColumnDescriptors.at(columnId);
131 }
133 return fClusterDescriptors.at(clusterId);
134 }
135 std::string GetName() const { return fName; }
136};
137
138
139/**
140 * Used by RPageStorage implementations in order to construct the RNTupleDescriptor from the various header parts.
141 */
143private:
145
146public:
147 const RNTupleDescriptor& GetDescriptor() const { return fDescriptor; }
148
149 void SetNTuple(std::string_view name, const RNTupleVersion &version);
150
151 void AddField(DescriptorId_t fieldId, const RNTupleVersion &fieldVersion, const RNTupleVersion &typeVersion,
152 std::string_view fieldName, std::string_view typeName, ENTupleStructure structure);
153 void SetFieldParent(DescriptorId_t fieldId, DescriptorId_t parentId);
154 void AddFieldLink(DescriptorId_t fieldId, DescriptorId_t linkId);
155
156 void AddColumn(DescriptorId_t columnId, DescriptorId_t fieldId,
157 const RNTupleVersion &version, const RColumnModel &model);
158 void SetColumnOffset(DescriptorId_t columnId, DescriptorId_t offsetId);
159 void AddColumnLink(DescriptorId_t columnId, DescriptorId_t linkId);
160
161 void AddCluster(DescriptorId_t clusterId, RNTupleVersion version,
162 NTupleSize_t firstEntryIndex, ClusterSize_t nEntries);
164};
165
166} // namespace Experimental
167} // namespace ROOT
168
169#endif
char name[80]
Definition: TGX11.cxx:109
std::unordered_map< DescriptorId_t, RColumnInfo > fColumnInfos
RColumnInfo GetColumnInfo(DescriptorId_t columnId) const
std::vector< DescriptorId_t > GetLinkIds()
DescriptorId_t fFieldId
Every column belongs to one and only one field.
std::vector< DescriptorId_t > fLinkIds
For index and offset columns of collections, pointers and variants, the pointee field(s)
DescriptorId_t fOffsetId
Pointer to the parent column with offsets.
Holds the static meta-data of a column in a tree.
std::vector< DescriptorId_t > fLinkIds
For pointers and optional/variant fields, the pointee field(s)
std::vector< DescriptorId_t > GetLinkIds() const
std::string fFieldName
The leaf name, not including parent fields.
DescriptorId_t fParentId
Establishes sub field trees, such as classes and collections.
ENTupleStructure fStructure
The structural information carried by this field in the data model tree.
std::string fTypeName
The C++ type that was used when writing the field.
Used by RPageStorage implementations in order to construct the RNTupleDescriptor from the various hea...
void AddCluster(DescriptorId_t clusterId, RNTupleVersion version, NTupleSize_t firstEntryIndex, ClusterSize_t nEntries)
void AddColumnLink(DescriptorId_t columnId, DescriptorId_t linkId)
void AddFieldLink(DescriptorId_t fieldId, DescriptorId_t linkId)
void AddColumn(DescriptorId_t columnId, DescriptorId_t fieldId, const RNTupleVersion &version, const RColumnModel &model)
const RNTupleDescriptor & GetDescriptor() const
void AddField(DescriptorId_t fieldId, const RNTupleVersion &fieldVersion, const RNTupleVersion &typeVersion, std::string_view fieldName, std::string_view typeName, ENTupleStructure structure)
void AddClusterColumnInfo(DescriptorId_t clusterId, const RClusterDescriptor::RColumnInfo &columnInfo)
void SetFieldParent(DescriptorId_t fieldId, DescriptorId_t parentId)
void SetColumnOffset(DescriptorId_t columnId, DescriptorId_t offsetId)
void SetNTuple(std::string_view name, const RNTupleVersion &version)
Represents the on-disk (on storage) information about an ntuple.
std::unordered_map< DescriptorId_t, RClusterDescriptor > fClusterDescriptors
std::unordered_map< DescriptorId_t, RColumnDescriptor > fColumnDescriptors
const RClusterDescriptor & GetClusterDescriptor(DescriptorId_t clusterId) const
std::unordered_map< DescriptorId_t, RFieldDescriptor > fFieldDescriptors
const RColumnDescriptor & GetColumnDescriptor(DescriptorId_t columnId) const
const RFieldDescriptor & GetFieldDescriptor(DescriptorId_t fieldId) const
For forward and backward compatibility, attach version information to the consitituents of the file f...
Definition: RNTupleUtil.hxx:73
basic_string_view< char > string_view
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:44
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
Definition: RNTupleUtil.hxx:33
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
Definition: RNTupleUtil.hxx:65
constexpr NTupleSize_t kInvalidNTupleIndex
Definition: RNTupleUtil.hxx:45
constexpr ClusterSize_t kInvalidClusterIndex(std::uint32_t(-1))
constexpr DescriptorId_t kInvalidDescriptorId
Definition: RNTupleUtil.hxx:66
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...
Definition: RNTupleUtil.hxx:47