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-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_RNTupleUtil
17#define ROOT7_RNTupleUtil
18
19#include <cstdint>
20
21#include <string>
22
23namespace ROOT {
24namespace Experimental {
25
26
27/**
28 * The fields in the ntuple model tree can carry different structural information about the type system.
29 * Leaf fields contain just data, collection fields resolve to offset columns, record root fields have no
30 * materialization on the primitive column layer.
31 */
37 // unimplemented so far
39};
40
41/// Integer type long enough to hold the maximum number of entries in a column
42using NTupleSize_t = std::uint64_t;
43constexpr NTupleSize_t kInvalidNTupleIndex = std::uint64_t(-1);
44/// Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t
46 using ValueType = std::uint32_t;
47
49 explicit constexpr RClusterSize(ValueType value) : fValue(value) {}
50 RClusterSize& operator =(const ValueType value) { fValue = value; return *this; }
51 RClusterSize& operator +=(const ValueType value) { fValue += value; return *this; }
52 RClusterSize operator++(int) { auto result = *this; fValue++; return result; }
53 operator ValueType() const { return fValue; }
54
56};
58constexpr ClusterSize_t kInvalidClusterIndex(std::uint32_t(-1));
59
60/// Holds the index and the tag of a kSwitch column
62private:
64 std::uint32_t fTag = 0;
65
66public:
67 RColumnSwitch() = default;
68 RColumnSwitch(ClusterSize_t index, std::uint32_t tag) : fIndex(index), fTag(tag) { }
69 ClusterSize_t GetIndex() const { return fIndex; }
70 std::uint32_t GetTag() const { return fTag; }
71};
72
73/// Uniquely identifies a physical column within the scope of the current process, used to tag pages
74using ColumnId_t = std::int64_t;
76
77/// Distriniguishes elements of the same type within a descriptor, e.g. different fields
78using DescriptorId_t = std::uint64_t;
79constexpr DescriptorId_t kInvalidDescriptorId = std::uint64_t(-1);
80
81/// Addresses a column element or field item relative to a particular cluster, instead of a global NTupleSize_t index
83private:
86public:
87 RClusterIndex() = default;
88 RClusterIndex(const RClusterIndex &other) = default;
89 RClusterIndex &operator =(const RClusterIndex &other) = default;
91 : fClusterId(clusterId), fIndex(index) {}
92
95 RClusterIndex operator++(int) /* postfix */ { auto r = *this; fIndex++; return r; }
96 RClusterIndex& operator++() /* prefix */ { ++fIndex; return *this; }
97 bool operator==(const RClusterIndex &other) const {
98 return fClusterId == other.fClusterId && fIndex == other.fIndex;
99 }
100 bool operator!=(const RClusterIndex &other) const { return !(*this == other); }
101
104};
105
106/// Every NTuple is identified by a UUID. TODO(jblomer): should this be a TUUID?
107using RNTupleUuid = std::string;
108
109
110/// 64 possible flags to apply to all versioned entities (so far unused).
111using NTupleFlags_t = std::uint64_t;
112/// For forward and backward compatibility, attach version information to
113/// the consitituents of the file format (column, field, cluster, ntuple).
115private:
116 /// The version used to write an entity
117 std::uint32_t fVersionUse = 0;
118 /// The minimum required version necessary to read an entity
119 std::uint32_t fVersionMin = 0;
121
122public:
123 RNTupleVersion() = default;
124 RNTupleVersion(std::uint32_t versionUse, std::uint32_t versionMin)
125 : fVersionUse(versionUse), fVersionMin(versionMin)
126 {}
127 RNTupleVersion(std::uint32_t versionUse, std::uint32_t versionMin, NTupleFlags_t flags)
128 : fVersionUse(versionUse), fVersionMin(versionMin), fFlags(flags)
129 {}
130
131 bool operator ==(const RNTupleVersion &other) const {
132 return fVersionUse == other.fVersionUse && fVersionMin == other.fVersionMin && fFlags == other.fFlags;
133 }
134
135 std::uint32_t GetVersionUse() const { return fVersionUse; }
136 std::uint32_t GetVersionMin() const { return fVersionMin; }
137 NTupleFlags_t GetFlags() const { return fFlags; }
138};
139
140} // namespace Experimental
141} // namespace ROOT
142
143#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...
Definition: RNTupleUtil.hxx:82
RClusterIndex operator+(ClusterSize_t::ValueType off) const
Definition: RNTupleUtil.hxx:93
bool operator==(const RClusterIndex &other) const
Definition: RNTupleUtil.hxx:97
bool operator!=(const RClusterIndex &other) const
ClusterSize_t::ValueType fIndex
Definition: RNTupleUtil.hxx:85
RClusterIndex operator-(ClusterSize_t::ValueType off) const
Definition: RNTupleUtil.hxx:94
RClusterIndex & operator=(const RClusterIndex &other)=default
DescriptorId_t GetClusterId() const
constexpr RClusterIndex(DescriptorId_t clusterId, ClusterSize_t::ValueType index)
Definition: RNTupleUtil.hxx:90
ClusterSize_t::ValueType GetIndex() const
RClusterIndex(const RClusterIndex &other)=default
Holds the index and the tag of a kSwitch column.
Definition: RNTupleUtil.hxx:61
ClusterSize_t GetIndex() const
Definition: RNTupleUtil.hxx:69
std::uint32_t GetTag() const
Definition: RNTupleUtil.hxx:70
RColumnSwitch(ClusterSize_t index, std::uint32_t tag)
Definition: RNTupleUtil.hxx:68
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
NTupleFlags_t GetFlags() 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
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:42
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.
Definition: RNTupleUtil.hxx:32
constexpr ColumnId_t kInvalidColumnId
Definition: RNTupleUtil.hxx:75
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
Definition: RNTupleUtil.hxx:78
constexpr NTupleSize_t kInvalidNTupleIndex
Definition: RNTupleUtil.hxx:43
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
Definition: RNTupleUtil.hxx:74
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
Definition: RNTupleUtil.hxx:79
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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:45
RClusterSize & operator=(const ValueType value)
Definition: RNTupleUtil.hxx:50
constexpr RClusterSize(ValueType value)
Definition: RNTupleUtil.hxx:49
RClusterSize & operator+=(const ValueType value)
Definition: RNTupleUtil.hxx:51