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
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/// Generic information about the physical location of data. Values depend on the concrete storage type. E.g.,
120/// for a local file fUrl might be unsused and fPosition might be a file offset. Objects on storage can be compressed
121/// and therefore we need to store their actual size.
122/// TODO(jblomer): should move the RNTUpleDescriptor and should be an std::variant
124 std::int64_t fPosition = 0;
125 std::uint32_t fBytesOnStorage = 0;
126 std::string fUrl;
127
128 bool operator==(const RNTupleLocator &other) const {
129 return fPosition == other.fPosition && fBytesOnStorage == other.fBytesOnStorage && fUrl == other.fUrl;
130 }
131};
132
133} // namespace Experimental
134} // namespace ROOT
135
136#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...
Definition: RNTupleUtil.hxx:95
RClusterIndex operator+(ClusterSize_t::ValueType off) const
bool operator==(const RClusterIndex &other) const
bool operator!=(const RClusterIndex &other) const
ClusterSize_t::ValueType fIndex
Definition: RNTupleUtil.hxx:98
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:74
ClusterSize_t GetIndex() const
Definition: RNTupleUtil.hxx:82
std::uint32_t GetTag() const
Definition: RNTupleUtil.hxx:83
RColumnSwitch(ClusterSize_t index, std::uint32_t tag)
Definition: RNTupleUtil.hxx:81
void PrintRNTuple(const RNTuple &ntuple, std::ostream &output)
Definition: RNTupleUtil.cxx:34
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:55
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
Definition: RNTupleUtil.hxx:45
constexpr ColumnId_t kInvalidColumnId
Definition: RNTupleUtil.hxx:88
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
Definition: RNTupleUtil.hxx:91
constexpr NTupleSize_t kInvalidNTupleIndex
Definition: RNTupleUtil.hxx:56
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
Definition: RNTupleUtil.hxx:87
constexpr ClusterSize_t kInvalidClusterIndex(std::uint32_t(-1))
constexpr DescriptorId_t kInvalidDescriptorId
Definition: RNTupleUtil.hxx:92
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:58
RClusterSize & operator=(const ValueType value)
Definition: RNTupleUtil.hxx:63
constexpr RClusterSize(ValueType value)
Definition: RNTupleUtil.hxx:62
RClusterSize & operator+=(const ValueType value)
Definition: RNTupleUtil.hxx:64
Generic information about the physical location of data.
bool operator==(const RNTupleLocator &other) const
static void output()