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 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/// Holds the index and the tag of a kSwitch column
68private:
70 std::uint32_t fTag = 0;
71
72public:
73 RColumnSwitch() = default;
74 RColumnSwitch(ClusterSize_t index, std::uint32_t tag) : fIndex(index), fTag(tag) { }
75 ClusterSize_t GetIndex() const { return fIndex; }
76 std::uint32_t GetTag() const { return fTag; }
77};
78
79/// Uniquely identifies a physical column within the scope of the current process, used to tag pages
80using ColumnId_t = std::int64_t;
82
83/// Distriniguishes elements of the same type within a descriptor, e.g. different fields
84using DescriptorId_t = std::uint64_t;
85constexpr DescriptorId_t kInvalidDescriptorId = std::uint64_t(-1);
86
87/// Addresses a column element or field item relative to a particular cluster, instead of a global NTupleSize_t index
89private:
92public:
93 RClusterIndex() = default;
94 RClusterIndex(const RClusterIndex &other) = default;
95 RClusterIndex &operator =(const RClusterIndex &other) = default;
97 : fClusterId(clusterId), fIndex(index) {}
98
101 RClusterIndex operator++(int) /* postfix */ { auto r = *this; fIndex++; return r; }
102 RClusterIndex& operator++() /* prefix */ { ++fIndex; return *this; }
103 bool operator==(const RClusterIndex &other) const {
104 return fClusterId == other.fClusterId && fIndex == other.fIndex;
105 }
106 bool operator!=(const RClusterIndex &other) const { return !(*this == other); }
107
110};
111
112/// RNTupleLocator payload that is common for object stores using 64bit location information.
113/// This might not contain the full location of the content. In particular, for page locators this information may be
114/// used in conjunction with the cluster and column ID.
116 std::uint64_t fLocation = 0;
117 bool operator==(const RNTupleLocatorObject64 &other) const { return fLocation == other.fLocation; }
118};
119
120/// Generic information about the physical location of data. Values depend on the concrete storage type. E.g.,
121/// for a local file `fPosition` might be a 64bit file offset. Referenced objects on storage can be compressed
122/// and therefore we need to store their actual size.
123/// TODO(jblomer): consider moving this to `RNTupleDescriptor`
125 /// Values for the _Type_ field in non-disk locators; see `doc/specifications.md` for details
126 enum ELocatorType : std::uint8_t {
127 kTypeFile = 0x00,
128 kTypeURI = 0x01,
129 kTypeDAOS = 0x02,
130 };
131
132 /// Simple on-disk locators consisting of a 64-bit offset use variant type `uint64_t`; extended locators have
133 /// `fPosition.index()` > 0
134 std::variant<std::uint64_t, std::string, RNTupleLocatorObject64> fPosition;
135 std::uint32_t fBytesOnStorage = 0;
136 /// For non-disk locators, the value for the _Type_ field. This makes it possible to have different type values even
137 /// if the payload structure is identical.
139 /// Reserved for use by concrete storage backends
140 std::uint8_t fReserved = 0;
141
142 bool operator==(const RNTupleLocator &other) const {
143 return fPosition == other.fPosition && fBytesOnStorage == other.fBytesOnStorage && fType == other.fType;
144 }
145 template <typename T>
146 const T &GetPosition() const
147 {
148 return std::get<T>(fPosition);
149 }
150};
151
152} // namespace Experimental
153} // namespace ROOT
154
155#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.
ClusterSize_t GetIndex() const
RColumnSwitch(ClusterSize_t index, std::uint32_t tag)
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
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::uint32_t(-1))
constexpr DescriptorId_t kInvalidDescriptorId
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...
RClusterSize & operator=(const ValueType value)
constexpr RClusterSize(ValueType value)
RClusterSize & operator+=(const 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; 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...