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