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
23#include <ROOT/RLogger.hxx>
24
25namespace ROOT {
26namespace Experimental {
27
28class RLogChannel;
29/// Log channel for RNTuple diagnostics.
30RLogChannel &NTupleLog();
31
32struct RNTuple;
33
34namespace Internal {
35
36void PrintRNTuple(const RNTuple& ntuple, std::ostream& output);
37
38} // namespace Internal
39
40/**
41 * The fields in the ntuple model tree can carry different structural information about the type system.
42 * Leaf fields contain just data, collection fields resolve to offset columns, record fields have no
43 * materialization on the primitive column layer.
44 */
50 kReference, // unimplemented so far
52};
53
54/// Integer type long enough to hold the maximum number of entries in a column
55using NTupleSize_t = std::uint64_t;
56constexpr NTupleSize_t kInvalidNTupleIndex = std::uint64_t(-1);
57/// Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t
59 using ValueType = std::uint32_t;
60
62 explicit constexpr RClusterSize(ValueType value) : fValue(value) {}
63 RClusterSize& operator =(const ValueType value) { fValue = value; return *this; }
64 RClusterSize& operator +=(const ValueType value) { fValue += value; return *this; }
65 RClusterSize operator++(int) { auto result = *this; fValue++; return result; }
66 operator ValueType() const { return fValue; }
67
69};
71constexpr ClusterSize_t kInvalidClusterIndex(std::uint32_t(-1));
72
73/// Holds the index and the tag of a kSwitch column
75private:
77 std::uint32_t fTag = 0;
78
79public:
80 RColumnSwitch() = default;
81 RColumnSwitch(ClusterSize_t index, std::uint32_t tag) : fIndex(index), fTag(tag) { }
82 ClusterSize_t GetIndex() const { return fIndex; }
83 std::uint32_t GetTag() const { return fTag; }
84};
85
86/// Uniquely identifies a physical column within the scope of the current process, used to tag pages
87using ColumnId_t = std::int64_t;
89
90/// Distriniguishes elements of the same type within a descriptor, e.g. different fields
91using DescriptorId_t = std::uint64_t;
92constexpr DescriptorId_t kInvalidDescriptorId = std::uint64_t(-1);
93
94/// Addresses a column element or field item relative to a particular cluster, instead of a global NTupleSize_t index
96private:
99public:
100 RClusterIndex() = default;
101 RClusterIndex(const RClusterIndex &other) = default;
102 RClusterIndex &operator =(const RClusterIndex &other) = default;
104 : fClusterId(clusterId), fIndex(index) {}
105
108 RClusterIndex operator++(int) /* postfix */ { auto r = *this; fIndex++; return r; }
109 RClusterIndex& operator++() /* prefix */ { ++fIndex; return *this; }
110 bool operator==(const RClusterIndex &other) const {
111 return fClusterId == other.fClusterId && fIndex == other.fIndex;
112 }
113 bool operator!=(const RClusterIndex &other) const { return !(*this == other); }
114
117};
118
119/// Every NTuple is identified by a UUID. TODO(jblomer): should this be a TUUID?
120using RNTupleUuid = std::string;
121
122
123/// 64 possible flags to apply to all versioned entities (so far unused).
124using NTupleFlags_t = std::uint64_t;
125/// For forward and backward compatibility, attach version information to
126/// the consitituents of the file format (column, field, cluster, ntuple).
128private:
129 /// The version used to write an entity
130 std::uint32_t fVersionUse = 0;
131 /// The minimum required version necessary to read an entity
132 std::uint32_t fVersionMin = 0;
134
135public:
136 RNTupleVersion() = default;
137 RNTupleVersion(std::uint32_t versionUse, std::uint32_t versionMin)
138 : fVersionUse(versionUse), fVersionMin(versionMin)
139 {}
140 RNTupleVersion(std::uint32_t versionUse, std::uint32_t versionMin, NTupleFlags_t flags)
141 : fVersionUse(versionUse), fVersionMin(versionMin), fFlags(flags)
142 {}
143
144 bool operator ==(const RNTupleVersion &other) const {
145 return fVersionUse == other.fVersionUse && fVersionMin == other.fVersionMin && fFlags == other.fFlags;
146 }
147
148 std::uint32_t GetVersionUse() const { return fVersionUse; }
149 std::uint32_t GetVersionMin() const { return fVersionMin; }
150 NTupleFlags_t GetFlags() const { return fFlags; }
151};
152
153} // namespace Experimental
154} // namespace ROOT
155
156#endif
ROOT::R::TRInterface & r
Definition Object.C:4
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)
For forward and backward compatibility, attach version information to the consitituents of the file f...
bool operator==(const RNTupleVersion &other) const
std::uint32_t fVersionMin
The minimum required version necessary to read an entity.
RNTupleVersion(std::uint32_t versionUse, std::uint32_t versionMin)
std::uint32_t GetVersionUse() const
RNTupleVersion(std::uint32_t versionUse, std::uint32_t versionMin, NTupleFlags_t flags)
std::uint32_t fVersionUse
The version used to write an entity.
std::uint32_t GetVersionMin() const
void PrintRNTuple(const RNTuple &ntuple, std::ostream &output)
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.
std::uint64_t NTupleFlags_t
64 possible flags to apply to all versioned entities (so far unused).
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.
std::string RNTupleUuid
Every NTuple is identified by a UUID. TODO(jblomer): should this be a TUUID?
constexpr ClusterSize_t kInvalidClusterIndex(std::uint32_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 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)
static void output(int code)
Definition gifencode.c:226