Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleUtil.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleUtil.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-04
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-2020, 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_RNTupleUtil
17#define ROOT7_RNTupleUtil
18
19#include <cstdint>
20
21#include <string>
22#include <variant>
23
24#include <ROOT/RLogger.hxx>
25
26namespace ROOT {
27namespace Experimental {
28
29class RLogChannel;
30/// Log channel for RNTuple diagnostics.
31RLogChannel &NTupleLog();
32
33/**
34 * The fields in the ntuple model tree can carry different structural information about the type system.
35 * Leaf fields contain just data, collection fields resolve to offset columns, record fields have no
36 * materialization on the primitive column layer.
37 */
43 kReference, // unimplemented so far
45};
46
47/// Integer type long enough to hold the maximum number of entries in a column
48using NTupleSize_t = std::uint64_t;
49constexpr NTupleSize_t kInvalidNTupleIndex = std::uint64_t(-1);
50/// Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t
52 using ValueType = std::uint64_t;
53
55 explicit constexpr RClusterSize(ValueType value) : fValue(value) {}
56 RClusterSize& operator =(const ValueType value) { fValue = value; return *this; }
57 RClusterSize& operator +=(const ValueType value) { fValue += value; return *this; }
58 RClusterSize operator++(int) { auto result = *this; fValue++; return result; }
59 operator ValueType() const { return fValue; }
60
62};
64constexpr ClusterSize_t kInvalidClusterIndex(std::uint64_t(-1));
65
66constexpr int kUnknownCompressionSettings = -1;
67
68/// Helper types to present an offset column as array of collection sizes.
69/// See RField<RNTupleCardinality<SizeT>> for details.
70template <typename SizeT>
72 static_assert(std::is_same_v<SizeT, std::uint32_t> || std::is_same_v<SizeT, std::uint64_t>,
73 "RNTupleCardinality is only supported with std::uint32_t or std::uint64_t template parameters");
74
75 using ValueType = SizeT;
76
78 explicit constexpr RNTupleCardinality(ValueType value) : fValue(value) {}
80 {
81 fValue = value;
82 return *this;
83 }
84 operator ValueType() const { return fValue; }
85
87};
88
89/// Holds the index and the tag of a kSwitch column
91private:
93 std::uint32_t fTag = 0;
94
95public:
96 RColumnSwitch() = default;
97 RColumnSwitch(ClusterSize_t index, std::uint32_t tag) : fIndex(index), fTag(tag) { }
98 ClusterSize_t GetIndex() const { return fIndex; }
99 std::uint32_t GetTag() const { return fTag; }
100};
101
102/// Uniquely identifies a physical column within the scope of the current process, used to tag pages
103using ColumnId_t = std::int64_t;
105
106/// Distriniguishes elements of the same type within a descriptor, e.g. different fields
107using DescriptorId_t = std::uint64_t;
108constexpr DescriptorId_t kInvalidDescriptorId = std::uint64_t(-1);
109
110/// Addresses a column element or field item relative to a particular cluster, instead of a global NTupleSize_t index
112private:
115public:
116 RClusterIndex() = default;
117 RClusterIndex(const RClusterIndex &other) = default;
118 RClusterIndex &operator =(const RClusterIndex &other) = default;
120 : fClusterId(clusterId), fIndex(index) {}
121
124 RClusterIndex operator++(int) /* postfix */ { auto r = *this; fIndex++; return r; }
125 RClusterIndex& operator++() /* prefix */ { ++fIndex; return *this; }
126 bool operator==(RClusterIndex other) const { return fClusterId == other.fClusterId && fIndex == other.fIndex; }
127 bool operator!=(RClusterIndex other) const { return !(*this == other); }
128
131};
132
133/// RNTupleLocator payload that is common for object stores using 64bit location information.
134/// This might not contain the full location of the content. In particular, for page locators this information may be
135/// used in conjunction with the cluster and column ID.
137 std::uint64_t fLocation = 0;
138 bool operator==(const RNTupleLocatorObject64 &other) const { return fLocation == other.fLocation; }
139};
140
141/// Generic information about the physical location of data. Values depend on the concrete storage type. E.g.,
142/// for a local file `fPosition` might be a 64bit file offset. Referenced objects on storage can be compressed
143/// and therefore we need to store their actual size.
144/// TODO(jblomer): consider moving this to `RNTupleDescriptor`
146 /// Values for the _Type_ field in non-disk locators. Serializable types must have the MSb == 0; see
147 /// `doc/specifications.md` for details
148 enum ELocatorType : std::uint8_t {
149 kTypeFile = 0x00,
150 kTypeURI = 0x01,
151 kTypeDAOS = 0x02,
152
155 };
156
157 /// Simple on-disk locators consisting of a 64-bit offset use variant type `uint64_t`; extended locators have
158 /// `fPosition.index()` > 0
159 std::variant<std::uint64_t, std::string, RNTupleLocatorObject64> fPosition;
160 std::uint32_t fBytesOnStorage = 0;
161 /// For non-disk locators, the value for the _Type_ field. This makes it possible to have different type values even
162 /// if the payload structure is identical.
164 /// Reserved for use by concrete storage backends
165 std::uint8_t fReserved = 0;
166
167 bool operator==(const RNTupleLocator &other) const {
168 return fPosition == other.fPosition && fBytesOnStorage == other.fBytesOnStorage && fType == other.fType;
169 }
170 template <typename T>
171 const T &GetPosition() const
172 {
173 return std::get<T>(fPosition);
174 }
175};
176
177namespace Internal {
178template <typename T>
179auto MakeAliasedSharedPtr(T *rawPtr)
180{
181 const static std::shared_ptr<T> fgRawPtrCtrlBlock;
182 return std::shared_ptr<T>(fgRawPtrCtrlBlock, rawPtr);
183}
184} // namespace Internal
185
186} // namespace Experimental
187} // namespace ROOT
188
189#endif
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 r
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
RClusterIndex operator+(ClusterSize_t::ValueType off) const
ClusterSize_t::ValueType fIndex
RClusterIndex operator-(ClusterSize_t::ValueType off) const
bool operator==(RClusterIndex other) const
RClusterIndex & operator=(const RClusterIndex &other)=default
bool operator!=(RClusterIndex other) const
DescriptorId_t GetClusterId() const
constexpr RClusterIndex(DescriptorId_t clusterId, ClusterSize_t::ValueType index)
ClusterSize_t::ValueType GetIndex() const
RClusterIndex(const RClusterIndex &other)=default
Holds the index and the tag of a kSwitch column.
ClusterSize_t GetIndex() const
RColumnSwitch(ClusterSize_t index, std::uint32_t tag)
auto MakeAliasedSharedPtr(T *rawPtr)
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
constexpr ColumnId_t kInvalidColumnId
constexpr int kUnknownCompressionSettings
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
constexpr ClusterSize_t kInvalidClusterIndex(std::uint64_t(-1))
constexpr DescriptorId_t kInvalidDescriptorId
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t.
RClusterSize & operator=(const ValueType value)
constexpr RClusterSize(ValueType value)
RClusterSize & operator+=(const ValueType value)
Helper types to present an offset column as array of collection sizes.
RNTupleCardinality & operator=(const ValueType value)
constexpr RNTupleCardinality(ValueType value)
RNTupleLocator payload that is common for object stores using 64bit location information.
bool operator==(const RNTupleLocatorObject64 &other) const
Generic information about the physical location of data.
ELocatorType
Values for the Type field in non-disk locators.
std::uint8_t fReserved
Reserved for use by concrete storage backends.
ELocatorType fType
For non-disk locators, the value for the Type field.
bool operator==(const RNTupleLocator &other) const
std::variant< std::uint64_t, std::string, RNTupleLocatorObject64 > fPosition
Simple on-disk locators consisting of a 64-bit offset use variant type uint64_t; extended locators ha...