Logo ROOT  
Reference Guide
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 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t
52 using ValueType = std::uint32_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::uint32_t(-1));
65
66/// Helper type to present an offset column as array of collection sizes. See RField<RNTupleCardinality> for details.
68 using ValueType = std::size_t;
69
71 explicit constexpr RNTupleCardinality(ValueType value) : fValue(value) {}
73 {
74 fValue = value;
75 return *this;
76 }
77 operator ValueType() const { return fValue; }
78
80};
81
82/// Holds the index and the tag of a kSwitch column
84private:
86 std::uint32_t fTag = 0;
87
88public:
89 RColumnSwitch() = default;
90 RColumnSwitch(ClusterSize_t index, std::uint32_t tag) : fIndex(index), fTag(tag) { }
91 ClusterSize_t GetIndex() const { return fIndex; }
92 std::uint32_t GetTag() const { return fTag; }
93};
94
95/// Uniquely identifies a physical column within the scope of the current process, used to tag pages
96using ColumnId_t = std::int64_t;
98
99/// Distriniguishes elements of the same type within a descriptor, e.g. different fields
100using DescriptorId_t = std::uint64_t;
101constexpr DescriptorId_t kInvalidDescriptorId = std::uint64_t(-1);
102
103/// Addresses a column element or field item relative to a particular cluster, instead of a global NTupleSize_t index
105private:
108public:
109 RClusterIndex() = default;
110 RClusterIndex(const RClusterIndex &other) = default;
111 RClusterIndex &operator =(const RClusterIndex &other) = default;
113 : fClusterId(clusterId), fIndex(index) {}
114
117 RClusterIndex operator++(int) /* postfix */ { auto r = *this; fIndex++; return r; }
118 RClusterIndex& operator++() /* prefix */ { ++fIndex; return *this; }
119 bool operator==(const RClusterIndex &other) const {
120 return fClusterId == other.fClusterId && fIndex == other.fIndex;
121 }
122 bool operator!=(const RClusterIndex &other) const { return !(*this == other); }
123
126};
127
128/// RNTupleLocator payload that is common for object stores using 64bit location information.
129/// This might not contain the full location of the content. In particular, for page locators this information may be
130/// used in conjunction with the cluster and column ID.
132 std::uint64_t fLocation = 0;
133 bool operator==(const RNTupleLocatorObject64 &other) const { return fLocation == other.fLocation; }
134};
135
136/// Generic information about the physical location of data. Values depend on the concrete storage type. E.g.,
137/// for a local file `fPosition` might be a 64bit file offset. Referenced objects on storage can be compressed
138/// and therefore we need to store their actual size.
139/// TODO(jblomer): consider moving this to `RNTupleDescriptor`
141 /// Values for the _Type_ field in non-disk locators; see `doc/specifications.md` for details
142 enum ELocatorType : std::uint8_t {
143 kTypeFile = 0x00,
144 kTypeURI = 0x01,
145 kTypeDAOS = 0x02,
146 };
147
148 /// Simple on-disk locators consisting of a 64-bit offset use variant type `uint64_t`; extended locators have
149 /// `fPosition.index()` > 0
150 std::variant<std::uint64_t, std::string, RNTupleLocatorObject64> fPosition;
151 std::uint32_t fBytesOnStorage = 0;
152 /// For non-disk locators, the value for the _Type_ field. This makes it possible to have different type values even
153 /// if the payload structure is identical.
155 /// Reserved for use by concrete storage backends
156 std::uint8_t fReserved = 0;
157
158 bool operator==(const RNTupleLocator &other) const {
159 return fPosition == other.fPosition && fBytesOnStorage == other.fBytesOnStorage && fType == other.fType;
160 }
161 template <typename T>
162 const T &GetPosition() const
163 {
164 return std::get<T>(fPosition);
165 }
166};
167
168} // namespace Experimental
169} // namespace ROOT
170
171#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
bool operator==(const RClusterIndex &other) const
bool operator!=(const RClusterIndex &other) const
ClusterSize_t::ValueType fIndex
RClusterIndex operator-(ClusterSize_t::ValueType off) const
RClusterIndex & operator=(const RClusterIndex &other)=default
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.
Definition: RNTupleUtil.hxx:83
ClusterSize_t GetIndex() const
Definition: RNTupleUtil.hxx:91
std::uint32_t GetTag() const
Definition: RNTupleUtil.hxx:92
RColumnSwitch(ClusterSize_t index, std::uint32_t tag)
Definition: RNTupleUtil.hxx:90
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
Definition: RNTupleUtil.cxx:24
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:48
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
Definition: RNTupleUtil.hxx:38
constexpr ColumnId_t kInvalidColumnId
Definition: RNTupleUtil.hxx:97
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
Definition: RNTupleUtil.hxx:49
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
Definition: RNTupleUtil.hxx:96
constexpr ClusterSize_t kInvalidClusterIndex(std::uint32_t(-1))
constexpr DescriptorId_t kInvalidDescriptorId
double T(double x)
Definition: ChebyshevPol.h:34
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...
Definition: RNTupleUtil.hxx:51
RClusterSize & operator=(const ValueType value)
Definition: RNTupleUtil.hxx:56
constexpr RClusterSize(ValueType value)
Definition: RNTupleUtil.hxx:55
RClusterSize & operator+=(const ValueType value)
Definition: RNTupleUtil.hxx:57
Helper type to present an offset column as array of collection sizes. See RField<RNTupleCardinality> ...
Definition: RNTupleUtil.hxx:67
RNTupleCardinality & operator=(const ValueType value)
Definition: RNTupleUtil.hxx:72
constexpr RNTupleCardinality(ValueType value)
Definition: RNTupleUtil.hxx:71
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; see doc/specifications.md for details.
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...