Logo ROOT  
Reference Guide
RPage.hxx
Go to the documentation of this file.
1/// \file ROOT/RPage.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-09
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_RPage
17#define ROOT7_RPage
18
19#include <ROOT/RNTupleUtil.hxx>
20
21#include <cstddef>
22#include <cstdint>
23
24namespace ROOT {
25namespace Experimental {
26
27namespace Detail {
28
29// clang-format off
30/**
31\class ROOT::Experimental::Detail::RPage
32\ingroup NTuple
33\brief A page is a slice of a column that is mapped into memory
34
35The page provides an opaque memory buffer for uncompressed, unpacked data. It does not interpret
36the contents but it does now about the size (and thus the number) of the elements inside as well as the element
37number range within the backing column/cluster. The memory buffer is not managed by the page. It is normally registered
38with the page pool and allocated/freed by the page storage.
39*/
40// clang-format on
41class RPage {
42public:
43 /**
44 * Stores information about the cluster in which this page resides.
45 */
47 private:
48 /// The cluster number
50 /// The first element index of the column in this cluster
52 public:
53 RClusterInfo() = default;
54 RClusterInfo(NTupleSize_t id, NTupleSize_t indexOffset) : fId(id), fIndexOffset(indexOffset) {}
55 NTupleSize_t GetId() const { return fId; }
57 };
58
59private:
61 void *fBuffer;
64 /// The capacity of the page in number of elements
68
69public:
72 {}
73 RPage(ColumnId_t columnId, void* buffer, ClusterSize_t::ValueType elementSize, ClusterSize_t::ValueType maxElements)
74 : fColumnId(columnId), fBuffer(buffer), fElementSize(elementSize), fNElements(0), fMaxElements(maxElements),
76 {}
77 ~RPage() = default;
78
79 ColumnId_t GetColumnId() const { return fColumnId; }
80 /// The space taken by column elements in the buffer
90 }
91 const RClusterInfo& GetClusterInfo() const { return fClusterInfo; }
92
93 bool Contains(NTupleSize_t globalIndex) const {
94 return (globalIndex >= fRangeFirst) && (globalIndex < fRangeFirst + NTupleSize_t(fNElements));
95 }
96
97 bool Contains(const RClusterIndex &clusterIndex) const {
98 if (fClusterInfo.GetId() != clusterIndex.GetClusterId())
99 return false;
100 auto clusterRangeFirst = ClusterSize_t(fRangeFirst - fClusterInfo.GetIndexOffset());
101 return (clusterIndex.GetIndex() >= clusterRangeFirst) &&
102 (clusterIndex.GetIndex() < clusterRangeFirst + fNElements);
103 }
104
105 void* GetBuffer() const { return fBuffer; }
106 /// Called during writing: returns a pointer after the last element and increases the element counter
107 /// in anticipation of the caller filling nElements in the page. It is the responsibility of the caller
108 /// to prevent page overflows, i.e. that fNElements + nElements <= fMaxElements
110 auto offset = GetNBytes();
111 fNElements += nElements;
112 return static_cast<unsigned char *>(fBuffer) + offset;
113 }
114 /// Seek the page to a certain position of the column
115 void SetWindow(const NTupleSize_t rangeFirst, const RClusterInfo &clusterInfo) {
116 fClusterInfo = clusterInfo;
117 fRangeFirst = rangeFirst;
118 }
119 /// Forget all currently stored elements (size == 0) and set a new starting index.
120 void Reset(NTupleSize_t rangeFirst) { fNElements = 0; fRangeFirst = rangeFirst; }
121 void ResetCluster(const RClusterInfo &clusterInfo) { fNElements = 0; fClusterInfo = clusterInfo; }
122
123 /// Used by virtual page sources to map the physical column and cluster IDs to ther virtual counterparts
124 void ChangeIds(DescriptorId_t columnId, DescriptorId_t clusterId)
125 {
126 fColumnId = columnId;
128 }
129
130 bool IsNull() const { return fBuffer == nullptr; }
131 bool IsEmpty() const { return fNElements == 0; }
132 bool operator ==(const RPage &other) const { return fBuffer == other.fBuffer; }
133 bool operator !=(const RPage &other) const { return !(*this == other); }
134};
135
136} // namespace Detail
137
138} // namespace Experimental
139} // namespace ROOT
140
141#endif
XFontStruct * id
Definition: TGX11.cxx:109
Stores information about the cluster in which this page resides.
Definition: RPage.hxx:46
DescriptorId_t fId
The cluster number.
Definition: RPage.hxx:49
RClusterInfo(NTupleSize_t id, NTupleSize_t indexOffset)
Definition: RPage.hxx:54
NTupleSize_t fIndexOffset
The first element index of the column in this cluster.
Definition: RPage.hxx:51
A page is a slice of a column that is mapped into memory.
Definition: RPage.hxx:41
ClusterSize_t::ValueType GetClusterRangeLast() const
Definition: RPage.hxx:88
ClusterSize_t::ValueType GetElementSize() const
Definition: RPage.hxx:82
ClusterSize_t::ValueType GetMaxElements() const
Definition: RPage.hxx:84
ClusterSize_t::ValueType GetNElements() const
Definition: RPage.hxx:83
ColumnId_t GetColumnId() const
Definition: RPage.hxx:79
void ChangeIds(DescriptorId_t columnId, DescriptorId_t clusterId)
Used by virtual page sources to map the physical column and cluster IDs to ther virtual counterparts.
Definition: RPage.hxx:124
RPage(ColumnId_t columnId, void *buffer, ClusterSize_t::ValueType elementSize, ClusterSize_t::ValueType maxElements)
Definition: RPage.hxx:73
ClusterSize_t::ValueType GetNBytes() const
The space taken by column elements in the buffer.
Definition: RPage.hxx:81
bool Contains(NTupleSize_t globalIndex) const
Definition: RPage.hxx:93
void * GrowUnchecked(ClusterSize_t::ValueType nElements)
Called during writing: returns a pointer after the last element and increases the element counter in ...
Definition: RPage.hxx:109
const RClusterInfo & GetClusterInfo() const
Definition: RPage.hxx:91
ClusterSize_t::ValueType fNElements
Definition: RPage.hxx:63
bool operator==(const RPage &other) const
Definition: RPage.hxx:132
void SetWindow(const NTupleSize_t rangeFirst, const RClusterInfo &clusterInfo)
Seek the page to a certain position of the column.
Definition: RPage.hxx:115
void ResetCluster(const RClusterInfo &clusterInfo)
Definition: RPage.hxx:121
ClusterSize_t::ValueType fElementSize
Definition: RPage.hxx:62
void Reset(NTupleSize_t rangeFirst)
Forget all currently stored elements (size == 0) and set a new starting index.
Definition: RPage.hxx:120
NTupleSize_t GetGlobalRangeFirst() const
Definition: RPage.hxx:85
bool Contains(const RClusterIndex &clusterIndex) const
Definition: RPage.hxx:97
NTupleSize_t GetGlobalRangeLast() const
Definition: RPage.hxx:86
ClusterSize_t::ValueType GetClusterRangeFirst() const
Definition: RPage.hxx:87
bool operator!=(const RPage &other) const
Definition: RPage.hxx:133
ClusterSize_t::ValueType fMaxElements
The capacity of the page in number of elements.
Definition: RPage.hxx:65
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
DescriptorId_t GetClusterId() const
ClusterSize_t::ValueType GetIndex() const
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:77
RClusterSize ClusterSize_t
Definition: RNTupleUtil.hxx:92
constexpr ColumnId_t kInvalidColumnId
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...