Skip to content

Commit ad99a81

Browse files
committed
[ntuple] Move RNTupleView out of Experimental
1 parent 070d93e commit ad99a81

File tree

7 files changed

+68
-53
lines changed

7 files changed

+68
-53
lines changed

gui/browsable/src/RFieldProvider.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class RFieldProvider : public RProvider {
7777
}
7878

7979
template <typename T>
80-
void FillHistogramImpl(const ROOT::RFieldBase &field, ROOT::Experimental::RNTupleView<T> &view)
80+
void FillHistogramImpl(const ROOT::RFieldBase &field, ROOT::RNTupleView<T> &view)
8181
{
8282
std::string title = "Drawing of RField "s + field.GetFieldName();
8383

tree/ntuple/v7/inc/ROOT/RField.hxx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,12 @@ class TVirtualStreamerInfo;
4545
namespace ROOT {
4646

4747
class TSchemaRule;
48-
class REntry;
48+
class RNTupleCollectionView;
4949

5050
namespace Detail {
5151
class RFieldVisitor;
5252
} // namespace Detail
5353

54-
namespace Experimental {
55-
56-
class RNTupleCollectionView;
57-
58-
} // namespace Experimental
59-
6054
/// The container field for an ntuple model, which itself has no physical representation.
6155
/// Therefore, the zero field must not be connected to a page source or sink.
6256
class RFieldZero final : public RFieldBase {
@@ -317,7 +311,7 @@ public:
317311
/// It is used in the templated RField<RNTupleCardinality<SizeT>> form, which represents the collection sizes either
318312
/// as 32bit unsigned int (std::uint32_t) or as 64bit unsigned int (std::uint64_t).
319313
class RCardinalityField : public RFieldBase {
320-
friend class ROOT::Experimental::RNTupleCollectionView; // to access GetCollectionInfo()
314+
friend class ROOT::RNTupleCollectionView; // to access GetCollectionInfo()
321315

322316
private:
323317
void GetCollectionInfo(ROOT::NTupleSize_t globalIndex, RNTupleLocalIndex *collectionStart, ROOT::NTupleSize_t *size)

tree/ntuple/v7/inc/ROOT/RNTupleReader.hxx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -282,65 +282,65 @@ public:
282282
/// }
283283
/// ~~~
284284
template <typename T>
285-
RNTupleView<T> GetView(std::string_view fieldName)
285+
ROOT::RNTupleView<T> GetView(std::string_view fieldName)
286286
{
287287
return GetView<T>(RetrieveFieldId(fieldName));
288288
}
289289

290290
template <typename T>
291-
RNTupleView<T> GetView(std::string_view fieldName, std::shared_ptr<T> objPtr)
291+
ROOT::RNTupleView<T> GetView(std::string_view fieldName, std::shared_ptr<T> objPtr)
292292
{
293293
return GetView<T>(RetrieveFieldId(fieldName), objPtr);
294294
}
295295

296296
template <typename T>
297-
RNTupleView<T> GetView(std::string_view fieldName, T *rawPtr)
297+
ROOT::RNTupleView<T> GetView(std::string_view fieldName, T *rawPtr)
298298
{
299299
return GetView<T>(RetrieveFieldId(fieldName), rawPtr);
300300
}
301301

302302
template <typename T>
303-
RNTupleView<T> GetView(ROOT::DescriptorId_t fieldId)
303+
ROOT::RNTupleView<T> GetView(ROOT::DescriptorId_t fieldId)
304304
{
305-
auto field = RNTupleView<T>::CreateField(fieldId, *fSource);
306-
auto range = Internal::GetFieldRange(*field, *fSource);
307-
return RNTupleView<T>(std::move(field), range);
305+
auto field = ROOT::RNTupleView<T>::CreateField(fieldId, *fSource);
306+
auto range = ROOT::Internal::GetFieldRange(*field, *fSource);
307+
return ROOT::RNTupleView<T>(std::move(field), range);
308308
}
309309

310310
template <typename T>
311-
RNTupleView<T> GetView(ROOT::DescriptorId_t fieldId, std::shared_ptr<T> objPtr)
311+
ROOT::RNTupleView<T> GetView(ROOT::DescriptorId_t fieldId, std::shared_ptr<T> objPtr)
312312
{
313-
auto field = RNTupleView<T>::CreateField(fieldId, *fSource);
314-
auto range = Internal::GetFieldRange(*field, *fSource);
315-
return RNTupleView<T>(std::move(field), range, objPtr);
313+
auto field = ROOT::RNTupleView<T>::CreateField(fieldId, *fSource);
314+
auto range = ROOT::Internal::GetFieldRange(*field, *fSource);
315+
return ROOT::RNTupleView<T>(std::move(field), range, objPtr);
316316
}
317317

318318
template <typename T>
319-
RNTupleView<T> GetView(ROOT::DescriptorId_t fieldId, T *rawPtr)
319+
ROOT::RNTupleView<T> GetView(ROOT::DescriptorId_t fieldId, T *rawPtr)
320320
{
321-
auto field = RNTupleView<T>::CreateField(fieldId, *fSource);
322-
auto range = Internal::GetFieldRange(*field, *fSource);
323-
return RNTupleView<T>(std::move(field), range, rawPtr);
321+
auto field = ROOT::RNTupleView<T>::CreateField(fieldId, *fSource);
322+
auto range = ROOT::Internal::GetFieldRange(*field, *fSource);
323+
return ROOT::RNTupleView<T>(std::move(field), range, rawPtr);
324324
}
325325

326326
template <typename T>
327-
RNTupleDirectAccessView<T> GetDirectAccessView(std::string_view fieldName)
327+
ROOT::RNTupleDirectAccessView<T> GetDirectAccessView(std::string_view fieldName)
328328
{
329329
return GetDirectAccessView<T>(RetrieveFieldId(fieldName));
330330
}
331331

332332
template <typename T>
333-
RNTupleDirectAccessView<T> GetDirectAccessView(ROOT::DescriptorId_t fieldId)
333+
ROOT::RNTupleDirectAccessView<T> GetDirectAccessView(ROOT::DescriptorId_t fieldId)
334334
{
335-
auto field = RNTupleDirectAccessView<T>::CreateField(fieldId, *fSource);
336-
auto range = Internal::GetFieldRange(field, *fSource);
337-
return RNTupleDirectAccessView<T>(std::move(field), range);
335+
auto field = ROOT::RNTupleDirectAccessView<T>::CreateField(fieldId, *fSource);
336+
auto range = ROOT::Internal::GetFieldRange(field, *fSource);
337+
return ROOT::RNTupleDirectAccessView<T>(std::move(field), range);
338338
}
339339

340340
/// Raises an exception if:
341341
/// * there is no field with the given name or,
342342
/// * the field is not a collection
343-
RNTupleCollectionView GetCollectionView(std::string_view fieldName)
343+
ROOT::RNTupleCollectionView GetCollectionView(std::string_view fieldName)
344344
{
345345
auto fieldId = fSource->GetSharedDescriptorGuard()->FindFieldId(fieldName);
346346
if (fieldId == ROOT::kInvalidDescriptorId) {
@@ -350,9 +350,9 @@ public:
350350
return GetCollectionView(fieldId);
351351
}
352352

353-
RNTupleCollectionView GetCollectionView(ROOT::DescriptorId_t fieldId)
353+
ROOT::RNTupleCollectionView GetCollectionView(ROOT::DescriptorId_t fieldId)
354354
{
355-
return RNTupleCollectionView::Create(fieldId, fSource.get());
355+
return ROOT::RNTupleCollectionView::Create(fieldId, fSource.get());
356356
}
357357

358358
RIterator begin() { return RIterator(0); }

tree/ntuple/v7/inc/ROOT/RNTupleView.hxx

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
#include <unordered_map>
3030

3131
namespace ROOT {
32+
3233
namespace Experimental {
34+
class RNTupleReader;
35+
} // namespace Experimental
3336

3437
namespace Internal {
3538

@@ -38,13 +41,14 @@ namespace Internal {
3841
/// by the number of elements of the first principal column found in the subfields searched by BFS.
3942
/// If the field hierarchy is empty on columns, the returned field range is invalid (start and end set to
4043
/// kInvalidNTupleIndex). An attempt to use such a field range in RNTupleViewBase::GetFieldRange will throw.
41-
ROOT::RNTupleGlobalRange GetFieldRange(const ROOT::RFieldBase &field, const RPageSource &pageSource);
44+
ROOT::RNTupleGlobalRange
45+
GetFieldRange(const ROOT::RFieldBase &field, const ROOT::Experimental::Internal::RPageSource &pageSource);
4246

4347
} // namespace Internal
4448

4549
// clang-format off
4650
/**
47-
\class ROOT::Experimental::RNTupleViewBase
51+
\class ROOT::RNTupleViewBase
4852
\ingroup NTuple
4953
\brief An RNTupleView provides read-only access to a single field of an RNTuple
5054
@@ -86,7 +90,8 @@ protected:
8690
ROOT::RNTupleGlobalRange fFieldRange;
8791
ROOT::RFieldBase::RValue fValue;
8892

89-
static std::unique_ptr<ROOT::RFieldBase> CreateField(ROOT::DescriptorId_t fieldId, Internal::RPageSource &pageSource)
93+
static std::unique_ptr<ROOT::RFieldBase>
94+
CreateField(ROOT::DescriptorId_t fieldId, ROOT::Experimental::Internal::RPageSource &pageSource)
9095
{
9196
std::unique_ptr<ROOT::RFieldBase> field;
9297
{
@@ -151,14 +156,14 @@ public:
151156

152157
// clang-format off
153158
/**
154-
\class ROOT::Experimental::RNTupleView
159+
\class ROOT::RNTupleView
155160
\ingroup NTuple
156161
\brief An RNTupleView for a known type. See RNTupleViewBase.
157162
*/
158163
// clang-format on
159164
template <typename T>
160165
class RNTupleView : public RNTupleViewBase<T> {
161-
friend class RNTupleReader;
166+
friend class ROOT::Experimental::RNTupleReader;
162167
friend class RNTupleCollectionView;
163168

164169
protected:
@@ -202,14 +207,14 @@ public:
202207

203208
// clang-format off
204209
/**
205-
\class ROOT::Experimental::RNTupleView
210+
\class ROOT::RNTupleView
206211
\ingroup NTuple
207212
\brief An RNTupleView that can be used when the type is unknown at compile time. See RNTupleViewBase.
208213
*/
209214
// clang-format on
210215
template <>
211216
class RNTupleView<void> final : public RNTupleViewBase<void> {
212-
friend class RNTupleReader;
217+
friend class ROOT::Experimental::RNTupleReader;
213218
friend class RNTupleCollectionView;
214219

215220
protected:
@@ -243,21 +248,22 @@ public:
243248

244249
// clang-format off
245250
/**
246-
\class ROOT::Experimental::RNTupleDirectAccessView
251+
\class ROOT::RNTupleDirectAccessView
247252
\ingroup NTuple
248253
\brief A view variant that provides direct access to the I/O buffers. Only works for mappable fields.
249254
*/
250255
// clang-format on
251256
template <typename T>
252257
class RNTupleDirectAccessView {
253-
friend class RNTupleReader;
258+
friend class ROOT::Experimental::RNTupleReader;
254259
friend class RNTupleCollectionView;
255260

256261
protected:
257262
ROOT::RField<T> fField;
258263
ROOT::RNTupleGlobalRange fFieldRange;
259264

260-
static ROOT::RField<T> CreateField(ROOT::DescriptorId_t fieldId, Internal::RPageSource &pageSource)
265+
static ROOT::RField<T>
266+
CreateField(ROOT::DescriptorId_t fieldId, ROOT::Experimental::Internal::RPageSource &pageSource)
261267
{
262268
const auto &desc = pageSource.GetSharedDescriptorGuard().GetRef();
263269
const auto &fieldDesc = desc.GetFieldDescriptor(fieldId);
@@ -295,27 +301,28 @@ public:
295301

296302
// clang-format off
297303
/**
298-
\class ROOT::Experimental::RNTupleCollectionView
304+
\class ROOT::RNTupleCollectionView
299305
\ingroup NTuple
300306
\brief A view for a collection, that can itself generate new ntuple views for its nested fields.
301307
*/
302308
// clang-format on
303309
class RNTupleCollectionView {
304-
friend class RNTupleReader;
310+
friend class ROOT::Experimental::RNTupleReader;
305311

306312
private:
307-
Internal::RPageSource *fSource;
313+
ROOT::Experimental::Internal::RPageSource *fSource;
308314
ROOT::RField<RNTupleCardinality<std::uint64_t>> fField;
309315
ROOT::RFieldBase::RValue fValue;
310316

311-
RNTupleCollectionView(ROOT::DescriptorId_t fieldId, const std::string &fieldName, Internal::RPageSource *source)
317+
RNTupleCollectionView(ROOT::DescriptorId_t fieldId, const std::string &fieldName,
318+
ROOT::Experimental::Internal::RPageSource *source)
312319
: fSource(source), fField(fieldName), fValue(fField.CreateValue())
313320
{
314321
fField.SetOnDiskId(fieldId);
315322
ROOT::Internal::CallConnectPageSourceOnField(fField, *source);
316323
}
317324

318-
static RNTupleCollectionView Create(ROOT::DescriptorId_t fieldId, Internal::RPageSource *source)
325+
static RNTupleCollectionView Create(ROOT::DescriptorId_t fieldId, ROOT::Experimental::Internal::RPageSource *source)
319326
{
320327
std::string fieldName;
321328
{
@@ -405,6 +412,20 @@ public:
405412
}
406413
};
407414

415+
namespace Experimental {
416+
// TODO(gparolini): remove before branching ROOT v6.36
417+
template <typename T>
418+
using RNTupleViewBase [[deprecated("ROOT::Experimental::RNTupleViewBase moved to ROOT::RNTupleViewBase")]] =
419+
ROOT::RNTupleViewBase<T>;
420+
template <typename T>
421+
using RNTupleView [[deprecated("ROOT::Experimental::RNTupleView moved to ROOT::RNTupleView")]] = ROOT::RNTupleView<T>;
422+
template <typename T>
423+
using RNTupleDirectAccessView
424+
[[deprecated("ROOT::Experimental::RNTupleDirectAccessView moved to ROOT::RNTupleDirectAccessView")]] =
425+
ROOT::RNTupleDirectAccessView<T>;
426+
using RNTupleCollectionView
427+
[[deprecated("ROOT::Experimental::RNTupleCollectionView moved to ROOT::RNTupleCollectionView")]] =
428+
ROOT::RNTupleCollectionView;
408429
} // namespace Experimental
409430
} // namespace ROOT
410431

tree/ntuple/v7/src/RNTupleView.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <ROOT/RNTupleView.hxx>
2020
#include <ROOT/RPageStorage.hxx>
2121

22-
ROOT::RNTupleGlobalRange
23-
ROOT::Experimental::Internal::GetFieldRange(const ROOT::RFieldBase &field, const RPageSource &pageSource)
22+
ROOT::RNTupleGlobalRange ROOT::Internal::GetFieldRange(const ROOT::RFieldBase &field,
23+
const ROOT::Experimental::Internal::RPageSource &pageSource)
2424
{
2525
const auto &desc = pageSource.GetSharedDescriptorGuard().GetRef();
2626

tree/ntuple/v7/test/ntuple_test.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ using RPrintSchemaVisitor = ROOT::Internal::RPrintSchemaVisitor;
111111
using RRawFile = ROOT::Internal::RRawFile;
112112
using EContainerFormat = RNTupleFileWriter::EContainerFormat;
113113
template <typename T>
114-
using RNTupleView = ROOT::Experimental::RNTupleView<T>;
114+
using RNTupleView = ROOT::RNTupleView<T>;
115115

116116
using ROOT::Internal::MakeUninitArray;
117117

tree/ntuple/v7/test/ntuple_view.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,9 @@ TEST(RNTuple, ViewFrameworkUse)
425425
auto reader = RNTupleReader::Open(*ntpl);
426426
reader->EnableMetrics();
427427

428-
std::optional<ROOT::Experimental::RNTupleView<void>> viewPx;
429-
std::optional<ROOT::Experimental::RNTupleView<void>> viewPy;
430-
std::optional<ROOT::Experimental::RNTupleView<void>> viewPz;
428+
std::optional<ROOT::RNTupleView<void>> viewPx;
429+
std::optional<ROOT::RNTupleView<void>> viewPy;
430+
std::optional<ROOT::RNTupleView<void>> viewPz;
431431

432432
float px = 0, py = 0, pz = 0;
433433
for (auto i : reader->GetEntryRange()) {

0 commit comments

Comments
 (0)