Logo ROOT  
Reference Guide
RField.hxx
Go to the documentation of this file.
1/// \file ROOT/RField.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_RField
17#define ROOT7_RField
18
19#include <ROOT/RColumn.hxx>
20#include <ROOT/RError.hxx>
22#include <ROOT/RFieldValue.hxx>
23#include <ROOT/RNTupleUtil.hxx>
24#include <ROOT/RSpan.hxx>
25#include <ROOT/RStringView.hxx>
26#include <ROOT/RVec.hxx>
27#include <ROOT/TypeTraits.hxx>
28
29#include <TGenericClassInfo.h>
30
31#include <algorithm>
32#include <array>
33#include <cstddef>
34#include <iostream>
35#include <iterator>
36#include <memory>
37#include <string>
38#include <type_traits>
39#include <typeinfo>
40#include <variant>
41#include <vector>
42#include <utility>
43
44class TClass;
45
46namespace ROOT {
47namespace Experimental {
48
49class RCollectionField;
50class RCollectionNTupleWriter;
51class REntry;
52class RNTupleModel;
53
54namespace Detail {
55
56class RFieldVisitor;
57class RPageStorage;
58
59// clang-format off
60/**
61\class ROOT::Experimental::RFieldBase
62\ingroup NTuple
63\brief A field translates read and write calls from/to underlying columns to/from tree values
64
65A field is a serializable C++ type or a container for a collection of sub fields. The RFieldBase and its
66type-safe descendants provide the object to column mapper. They map C++ objects to primitive columns. The
67mapping is trivial for simple types such as 'double'. Complex types resolve to multiple primitive columns.
68The field knows based on its type and the field name the type(s) and name(s) of the columns.
69*/
70// clang-format on
72 friend class ROOT::Experimental::RCollectionField; // to move the fields from the collection model
73
74private:
75 /// The field name relative to its parent field
76 std::string fName;
77 /// The C++ type captured by this field
78 std::string fType;
79 /// The role of this field in the data model structure
81 /// For fixed sized arrays, the array length
82 std::size_t fNRepetitions;
83 /// A field on a trivial type that maps as-is to a single column
85 /// When the columns are connected to a page source or page sink, the field represents a field id in the
86 /// corresponding RNTuple descriptor. This on-disk ID is set in RPageSink::Create() for writing and by
87 /// RFieldDescriptor::CreateField() when recreating a field / model from the stored descriptor.
89 /// Free text set by the user
90 std::string fDescription;
91
92protected:
93 /// Collections and classes own sub fields
94 std::vector<std::unique_ptr<RFieldBase>> fSubFields;
95 /// Sub fields point to their mother field
97 /// Points into fColumns. All fields that have columns have a distinct main column. For simple fields
98 /// (float, int, ...), the principal column corresponds to the field type. For collection fields expect std::array,
99 /// the main column is the offset field. Class fields have no column of their own.
101 /// The columns are connected either to a sink or to a source (not to both); they are owned by the field.
102 std::vector<std::unique_ptr<RColumn>> fColumns;
103
104 /// Creates the backing columns corresponsing to the field type for writing
105 virtual void GenerateColumnsImpl() = 0;
106 /// Creates the backing columns corresponsing to the field type for reading.
107 /// The method should to check, using the page source and fOnDiskId, if the column types match
108 /// and throw if they don't.
109 virtual void GenerateColumnsImpl(const RNTupleDescriptor &desc) = 0;
110
111 /// Called by Clone(), which additionally copies the on-disk ID
112 virtual std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const = 0;
113
114 /// Operations on values of complex types, e.g. ones that involve multiple columns or for which no direct
115 /// column type exists.
116 virtual std::size_t AppendImpl(const RFieldValue &value);
117 virtual void ReadGlobalImpl(NTupleSize_t globalIndex, RFieldValue *value);
118 virtual void ReadInClusterImpl(const RClusterIndex &clusterIndex, RFieldValue *value) {
120 }
121
122 /// Throws an exception if the column given by fOnDiskId and the columnIndex in the provided descriptor
123 /// is not of one of the requested types.
124 ROOT::Experimental::EColumnType EnsureColumnType(const std::vector<EColumnType> &requestedTypes,
125 unsigned int columnIndex, const RNTupleDescriptor &desc);
126
127public:
128 /// Iterates over the sub tree of fields in depth-first search order
130 private:
131 struct Position {
132 Position() : fFieldPtr(nullptr), fIdxInParent(-1) { }
133 Position(RFieldBase *fieldPtr, int idxInParent) : fFieldPtr(fieldPtr), fIdxInParent(idxInParent) { }
136 };
137 /// The stack of nodes visited when walking down the tree of fields
138 std::vector<Position> fStack;
139 public:
141 using iterator_category = std::forward_iterator_tag;
143 using difference_type = std::ptrdiff_t;
146
147 RSchemaIterator() { fStack.emplace_back(Position()); }
148 RSchemaIterator(pointer val, int idxInParent) { fStack.emplace_back(Position(val, idxInParent)); }
150 /// Given that the iterator points to a valid field which is not the end iterator, go to the next field
151 /// in depth-first search order
152 void Advance();
153
154 iterator operator++(int) /* postfix */ { auto r = *this; Advance(); return r; }
155 iterator& operator++() /* prefix */ { Advance(); return *this; }
156 reference operator* () const { return *fStack.back().fFieldPtr; }
157 pointer operator->() const { return fStack.back().fFieldPtr; }
158 bool operator==(const iterator& rh) const { return fStack.back().fFieldPtr == rh.fStack.back().fFieldPtr; }
159 bool operator!=(const iterator& rh) const { return fStack.back().fFieldPtr != rh.fStack.back().fFieldPtr; }
160 };
161
162 /// The constructor creates the underlying column objects and connects them to either a sink or a source.
164 std::size_t nRepetitions = 0);
165 RFieldBase(const RFieldBase&) = delete;
166 RFieldBase(RFieldBase&&) = default;
169 virtual ~RFieldBase();
170
171 /// Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns
172 std::unique_ptr<RFieldBase> Clone(std::string_view newName) const;
173
174 /// Factory method to resurrect a field from the stored on-disk type information
175 static RResult<std::unique_ptr<RFieldBase>> Create(const std::string &fieldName, const std::string &typeName);
176 /// Check whether a given string is a valid field name
178
179 /// Generates an object of the field type and allocates new initialized memory according to the type.
181 /// Generates a tree value in a given location of size at least GetValueSize(). Assumes that where has been
182 /// allocated by malloc().
183 virtual RFieldValue GenerateValue(void *where) = 0;
184 /// Releases the resources acquired during GenerateValue (memory and constructor)
185 /// This implementation works for simple types but needs to be overwritten for complex ones
186 virtual void DestroyValue(const RFieldValue &value, bool dtorOnly = false);
187 /// Creates a value from a memory location with an already constructed object
188 virtual RFieldValue CaptureValue(void *where) = 0;
189 /// Creates the list of direct child values given a value for this field. E.g. a single value for the
190 /// correct variant or all the elements of a collection. The default implementation assumes no sub values
191 /// and returns an empty vector.
192 virtual std::vector<RFieldValue> SplitValue(const RFieldValue &value) const;
193 /// The number of bytes taken by a value of the appropriate type
194 virtual size_t GetValueSize() const = 0;
195 /// For many types, the alignment requirement is equal to the size; otherwise override.
196 virtual size_t GetAlignment() const { return GetValueSize(); }
197
198 /// Write the given value into columns. The value object has to be of the same type as the field.
199 /// Returns the number of uncompressed bytes written.
200 std::size_t Append(const RFieldValue& value) {
201 if (!fIsSimple)
202 return AppendImpl(value);
203
204 fPrincipalColumn->Append(value.fMappedElement);
205 return value.fMappedElement.GetSize();
206 }
207
208 /// Populate a single value with data from the tree, which needs to be of the fitting type.
209 /// Reading copies data into the memory wrapped by the ntuple value.
210 void Read(NTupleSize_t globalIndex, RFieldValue *value) {
211 if (!fIsSimple) {
212 ReadGlobalImpl(globalIndex, value);
213 return;
214 }
215 fPrincipalColumn->Read(globalIndex, &value->fMappedElement);
216 }
217
218 void Read(const RClusterIndex &clusterIndex, RFieldValue *value) {
219 if (!fIsSimple) {
220 ReadInClusterImpl(clusterIndex, value);
221 return;
222 }
223 fPrincipalColumn->Read(clusterIndex, &value->fMappedElement);
224 }
225
226 /// Ensure that all received items are written from page buffers to the storage.
227 void Flush() const;
228 /// Perform housekeeping tasks for global to cluster-local index translation
229 virtual void CommitCluster() {}
230
231 /// Add a new subfield to the list of nested fields
232 void Attach(std::unique_ptr<Detail::RFieldBase> child);
233
234 std::string GetName() const { return fName; }
235 std::string GetType() const { return fType; }
237 std::size_t GetNRepetitions() const { return fNRepetitions; }
239 RFieldBase *GetParent() const { return fParent; }
240 std::vector<RFieldBase *> GetSubFields() const;
241 bool IsSimple() const { return fIsSimple; }
242 /// Get the field's description
243 std::string GetDescription() const { return fDescription; }
244 void SetDescription(std::string_view description) { fDescription = std::string(description); }
245
248
249 /// Fields and their columns live in the void until connected to a physical page storage. Only once connected, data
250 /// can be read or written. In order to find the field in the page storage, the field's on-disk ID has to be set.
251 void ConnectPageSink(RPageSink &pageSink);
252 void ConnectPageSource(RPageSource &pageSource);
253
254 /// Indicates an evolution of the mapping scheme from C++ type to columns
255 virtual std::uint32_t GetFieldVersion() const { return 0; }
256 /// Indicates an evolution of the C++ type itself
257 virtual std::uint32_t GetTypeVersion() const { return 0; }
258
259 RSchemaIterator begin();
260 RSchemaIterator end();
261
262 virtual void AcceptVisitor(RFieldVisitor &visitor) const;
263};
264
265} // namespace Detail
266
267
268
269/// The container field for an ntuple model, which itself has no physical representation
271protected:
272 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const;
273
274public:
275 RFieldZero() : Detail::RFieldBase("", "", ENTupleStructure::kRecord, false /* isSimple */) { }
276
277 void GenerateColumnsImpl() final {}
282 size_t GetValueSize() const final { return 0; }
283
284 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
285};
286
287/// The field for a class with dictionary
289private:
293 };
296 std::size_t fOffset;
297 };
298 /// Prefix used in the subfield names generated for base classes
299 static constexpr const char *kPrefixInherited{":"};
300
302 /// Additional information kept for each entry in `fSubFields`
303 std::vector<RSubFieldInfo> fSubFieldsInfo;
304 std::size_t fMaxAlignment = 1;
305
306private:
307 RClassField(std::string_view fieldName, std::string_view className, TClass *classp);
308 void Attach(std::unique_ptr<Detail::RFieldBase> child, RSubFieldInfo info);
309
310protected:
311 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final;
312 std::size_t AppendImpl(const Detail::RFieldValue& value) final;
313 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final;
314 void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final;
315
316public:
317 RClassField(std::string_view fieldName, std::string_view className);
318 RClassField(RClassField&& other) = default;
319 RClassField& operator =(RClassField&& other) = default;
320 ~RClassField() = default;
321
322 void GenerateColumnsImpl() final;
323 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
324 using Detail::RFieldBase::GenerateValue;
325 Detail::RFieldValue GenerateValue(void* where) override;
326 void DestroyValue(const Detail::RFieldValue& value, bool dtorOnly = false) final;
327 Detail::RFieldValue CaptureValue(void *where) final;
328 std::vector<Detail::RFieldValue> SplitValue(const Detail::RFieldValue &value) const final;
329 size_t GetValueSize() const override;
330 size_t GetAlignment() const final { return fMaxAlignment; }
331 void AcceptVisitor(Detail::RFieldVisitor &visitor) const override;
332};
333
334/// The field for an untyped record. The subfields are stored consequitively in a memory block, i.e.
335/// the memory layout is identical to one that a C++ struct would have
337protected:
338 std::size_t fMaxAlignment = 1;
339 std::size_t fSize = 0;
340 std::vector<std::size_t> fOffsets;
341
342 std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment) const;
343
344 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const override;
345 std::size_t AppendImpl(const Detail::RFieldValue& value) final;
346 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final;
347 void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final;
348
349 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields,
350 const std::vector<std::size_t> &offsets, std::string_view typeName = "");
351
352 template <std::size_t N>
353 RRecordField(std::string_view fieldName, std::array<std::unique_ptr<Detail::RFieldBase>, N> &&itemFields,
354 const std::array<std::size_t, N> &offsets, std::string_view typeName = "")
355 : ROOT::Experimental::Detail::RFieldBase(fieldName, typeName, ENTupleStructure::kRecord, false /* isSimple */)
356 {
357 for (unsigned i = 0; i < N; ++i) {
358 fOffsets.push_back(offsets[i]);
359 fMaxAlignment = std::max(fMaxAlignment, itemFields[i]->GetAlignment());
360 fSize += GetItemPadding(fSize, itemFields[i]->GetAlignment()) + itemFields[i]->GetValueSize();
361 Attach(std::move(itemFields[i]));
362 }
363 }
364public:
365 /// Construct a RRecordField based on a vector of child fields. The ownership of the child fields is transferred
366 /// to the RRecordField instance.
367 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields);
368 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
369 RRecordField(RRecordField&& other) = default;
371 ~RRecordField() = default;
372
373 void GenerateColumnsImpl() final {}
376 Detail::RFieldValue GenerateValue(void* where) override;
377 void DestroyValue(const Detail::RFieldValue& value, bool dtorOnly = false) override;
378 Detail::RFieldValue CaptureValue(void *where) final;
379 std::vector<Detail::RFieldValue> SplitValue(const Detail::RFieldValue &value) const final;
380 size_t GetValueSize() const final { return fSize; }
381 size_t GetAlignment() const final { return fMaxAlignment; }
382 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
383};
384
385/// The generic field for a (nested) std::vector<Type> except for std::vector<bool>
387private:
388 std::size_t fItemSize;
390
391protected:
392 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final;
393 std::size_t AppendImpl(const Detail::RFieldValue& value) final;
394 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final;
395
396public:
397 RVectorField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField);
398 RVectorField(RVectorField&& other) = default;
400 ~RVectorField() = default;
401
402 void GenerateColumnsImpl() final;
403 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
404 using Detail::RFieldBase::GenerateValue;
405 Detail::RFieldValue GenerateValue(void* where) override;
406 void DestroyValue(const Detail::RFieldValue& value, bool dtorOnly = false) final;
407 Detail::RFieldValue CaptureValue(void *where) override;
408 std::vector<Detail::RFieldValue> SplitValue(const Detail::RFieldValue &value) const final;
409 size_t GetValueSize() const override { return sizeof(std::vector<char>); }
410 size_t GetAlignment() const final { return std::alignment_of<std::vector<char>>(); }
411 void CommitCluster() final;
412 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
413 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const {
414 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart, size);
415 }
416 void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const {
417 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart, size);
418 }
419};
420
421/// The type-erased field for a RVec<Type>
423private:
424 /// Evaluate the constant returned by GetValueSize.
425 // (we separate evaluation from the getter to avoid repeating the computation).
426 std::size_t EvalValueSize() const;
427
428protected:
429 std::size_t fItemSize;
431 std::size_t fValueSize;
432
433 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const override;
434 std::size_t AppendImpl(const Detail::RFieldValue &value) override;
435 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) override;
436
437public:
438 RRVecField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField);
439 RRVecField(RRVecField &&) = default;
441 RRVecField(const RRVecField &) = delete;
443 ~RRVecField() = default;
444
445 void GenerateColumnsImpl() final;
446 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
447 using Detail::RFieldBase::GenerateValue;
448 Detail::RFieldValue GenerateValue(void *where) override;
449 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) override;
450 Detail::RFieldValue CaptureValue(void *where) override;
451 std::vector<Detail::RFieldValue> SplitValue(const Detail::RFieldValue &value) const final;
452 size_t GetValueSize() const override;
453 size_t GetAlignment() const override;
454 void CommitCluster() final;
455 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
456 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
457 {
458 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart, size);
459 }
460 void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
461 {
462 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart, size);
463 }
464};
465
466/// The generic field for fixed size arrays, which do not need an offset column
468private:
469 std::size_t fItemSize;
470 std::size_t fArrayLength;
471
472protected:
473 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final;
474 std::size_t AppendImpl(const Detail::RFieldValue& value) final;
475 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final;
476 void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final;
477
478public:
479 RArrayField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField, std::size_t arrayLength);
480 RArrayField(RArrayField &&other) = default;
481 RArrayField& operator =(RArrayField &&other) = default;
482 ~RArrayField() = default;
483
484 void GenerateColumnsImpl() final;
485 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
486 using Detail::RFieldBase::GenerateValue;
487 Detail::RFieldValue GenerateValue(void *where) override;
488 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) final;
489 Detail::RFieldValue CaptureValue(void *where) final;
490 std::vector<Detail::RFieldValue> SplitValue(const Detail::RFieldValue &value) const final;
491 size_t GetLength() const { return fArrayLength; }
492 size_t GetValueSize() const final { return fItemSize * fArrayLength; }
493 size_t GetAlignment() const final { return fSubFields[0]->GetAlignment(); }
494 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
495};
496
497/// The generic field for std::variant types
499private:
500 size_t fMaxItemSize = 0;
501 size_t fMaxAlignment = 1;
502 /// In the std::variant memory layout, at which byte number is the index stored
503 size_t fTagOffset = 0;
504 std::vector<ClusterSize_t::ValueType> fNWritten;
505
506 static std::string GetTypeList(const std::vector<Detail::RFieldBase *> &itemFields);
507 /// Extracts the index from an std::variant and transforms it into the 1-based index used for the switch column
508 std::uint32_t GetTag(void *variantPtr) const;
509 void SetTag(void *variantPtr, std::uint32_t tag) const;
510
511protected:
512 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final;
513 std::size_t AppendImpl(const Detail::RFieldValue& value) final;
514 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final;
515
516public:
517 // TODO(jblomer): use std::span in signature
518 RVariantField(std::string_view fieldName, const std::vector<Detail::RFieldBase *> &itemFields);
519 RVariantField(RVariantField &&other) = default;
521 ~RVariantField() = default;
522
523 void GenerateColumnsImpl() final;
524 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
525 using Detail::RFieldBase::GenerateValue;
526 Detail::RFieldValue GenerateValue(void *where) override;
527 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) final;
528 Detail::RFieldValue CaptureValue(void *where) final;
529 size_t GetValueSize() const final;
530 size_t GetAlignment() const final { return fMaxAlignment; }
531 void CommitCluster() final;
532};
533
534
535/// Classes with dictionaries that can be inspected by TClass
536template <typename T, typename=void>
537class RField : public RClassField {
538public:
539 static std::string TypeName() { return ROOT::Internal::GetDemangledTypeName(typeid(T)); }
541 static_assert(std::is_class<T>::value, "no I/O support for this basic C++ type");
542 }
543 RField(RField&& other) = default;
544 RField& operator =(RField&& other) = default;
545 ~RField() = default;
546
548 template <typename... ArgsT>
550 {
551 return Detail::RFieldValue(this, static_cast<T*>(where), std::forward<ArgsT>(args)...);
552 }
554};
555
556
557/// The collection field is only used for writing; when reading, untyped collections are projected to an std::vector
559private:
560 /// Save the link to the collection ntuple in order to reset the offset counter when committing the cluster
561 std::shared_ptr<RCollectionNTupleWriter> fCollectionNTuple;
562protected:
563 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final;
564public:
565 static std::string TypeName() { return ""; }
567 std::shared_ptr<RCollectionNTupleWriter> collectionNTuple,
568 std::unique_ptr<RNTupleModel> collectionModel);
571 ~RCollectionField() = default;
572
573 void GenerateColumnsImpl() final;
574 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
575
576 using Detail::RFieldBase::GenerateValue;
577 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final {
578 return Detail::RFieldValue(
580 this, static_cast<ClusterSize_t*>(where));
581 }
583 return Detail::RFieldValue(true /* captureFlag */,
584 Detail::RColumnElement<ClusterSize_t>(static_cast<ClusterSize_t*>(where)), this, where);
585 }
586 size_t GetValueSize() const final { return sizeof(ClusterSize_t); }
587 void CommitCluster() final;
588};
589
590/// The generic field for `std::pair<T1, T2>` types
591class RPairField : public RRecordField {
592private:
593 TClass *fClass = nullptr;
594 static std::string GetTypeList(const std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields);
595
596protected:
597 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const override;
598
599 RPairField(std::string_view fieldName, std::array<std::unique_ptr<Detail::RFieldBase>, 2> &&itemFields,
600 const std::array<std::size_t, 2> &offsets);
601
602public:
603 RPairField(std::string_view fieldName, std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields);
604 RPairField(RPairField &&other) = default;
605 RPairField &operator=(RPairField &&other) = default;
606 ~RPairField() = default;
607
609 Detail::RFieldValue GenerateValue(void *where) override;
610 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) override;
611};
612
613/// The generic field for `std::tuple<Ts...>` types
614class RTupleField : public RRecordField {
615private:
616 TClass *fClass = nullptr;
617 static std::string GetTypeList(const std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
618
619protected:
620 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const override;
621
622 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields,
623 const std::vector<std::size_t> &offsets);
624
625public:
626 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields);
627 RTupleField(RTupleField &&other) = default;
628 RTupleField &operator=(RTupleField &&other) = default;
629 ~RTupleField() = default;
630
632 Detail::RFieldValue GenerateValue(void *where) override;
633 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) override;
634};
635
636/// Template specializations for concrete C++ types
637
638
639template <>
641protected:
642 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
643 return std::make_unique<RField>(newName);
644 }
645
646public:
647 static std::string TypeName() { return "ROOT::Experimental::ClusterSize_t"; }
649 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
650 RField(RField&& other) = default;
651 RField& operator =(RField&& other) = default;
652 ~RField() = default;
653
655 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
656
658 return fPrincipalColumn->Map<ClusterSize_t>(globalIndex);
659 }
660 ClusterSize_t *Map(const RClusterIndex &clusterIndex) {
661 return fPrincipalColumn->Map<ClusterSize_t>(clusterIndex);
662 }
664 return fPrincipalColumn->MapV<ClusterSize_t>(globalIndex, nItems);
665 }
666 ClusterSize_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
667 return fPrincipalColumn->MapV<ClusterSize_t>(clusterIndex, nItems);
668 }
669
671 template <typename... ArgsT>
673 {
674 return Detail::RFieldValue(
676 this, static_cast<ClusterSize_t*>(where), std::forward<ArgsT>(args)...);
677 }
680 return Detail::RFieldValue(true /* captureFlag */,
681 Detail::RColumnElement<ClusterSize_t>(static_cast<ClusterSize_t*>(where)), this, where);
682 }
683 size_t GetValueSize() const final { return sizeof(ClusterSize_t); }
684
685 /// Special help for offset fields
686 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) {
687 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart, size);
688 }
689 void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) {
690 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart, size);
691 }
692 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
693};
694
695
696template <>
698protected:
699 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
700 return std::make_unique<RField>(newName);
701 }
702
703public:
704 static std::string TypeName() { return "bool"; }
706 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
707 RField(RField&& other) = default;
708 RField& operator =(RField&& other) = default;
709 ~RField() = default;
710
711 void GenerateColumnsImpl() final;
712 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
713
714 bool *Map(NTupleSize_t globalIndex) {
715 return fPrincipalColumn->Map<bool>(globalIndex);
716 }
717 bool *Map(const RClusterIndex &clusterIndex) {
718 return fPrincipalColumn->Map<bool>(clusterIndex);
719 }
720 bool *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
721 return fPrincipalColumn->MapV<bool>(globalIndex, nItems);
722 }
723 bool *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
724 return fPrincipalColumn->MapV<bool>(clusterIndex, nItems);
725 }
726
728 template <typename... ArgsT>
730 {
731 return Detail::RFieldValue(
732 Detail::RColumnElement<bool>(static_cast<bool*>(where)),
733 this, static_cast<bool*>(where), std::forward<ArgsT>(args)...);
734 }
735 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, false); }
737 return Detail::RFieldValue(true /* captureFlag */,
738 Detail::RColumnElement<bool>(static_cast<bool*>(where)), this, where);
739 }
740 size_t GetValueSize() const final { return sizeof(bool); }
741 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
742};
743
744template <>
745class RField<float> : public Detail::RFieldBase {
746protected:
747 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
748 return std::make_unique<RField>(newName);
749 }
750
751public:
752 static std::string TypeName() { return "float"; }
754 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
755 RField(RField&& other) = default;
756 RField& operator =(RField&& other) = default;
757 ~RField() = default;
758
759 void GenerateColumnsImpl() final;
760 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
761
762 float *Map(NTupleSize_t globalIndex) {
763 return fPrincipalColumn->Map<float>(globalIndex);
764 }
765 float *Map(const RClusterIndex &clusterIndex) {
766 return fPrincipalColumn->Map<float>(clusterIndex);
767 }
768 float *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
769 return fPrincipalColumn->MapV<float>(globalIndex, nItems);
770 }
771 float *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
772 return fPrincipalColumn->MapV<float>(clusterIndex, nItems);
773 }
774
776 template <typename... ArgsT>
778 {
779 return Detail::RFieldValue(
780 Detail::RColumnElement<float>(static_cast<float*>(where)),
781 this, static_cast<float*>(where), std::forward<ArgsT>(args)...);
782 }
783 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0.0); }
785 return Detail::RFieldValue(true /* captureFlag */,
786 Detail::RColumnElement<float>(static_cast<float*>(where)), this, where);
787 }
788 size_t GetValueSize() const final { return sizeof(float); }
789 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
790};
791
792
793template <>
795protected:
796 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
797 return std::make_unique<RField>(newName);
798 }
799
800public:
801 static std::string TypeName() { return "double"; }
803 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
804 RField(RField&& other) = default;
805 RField& operator =(RField&& other) = default;
806 ~RField() = default;
807
808 void GenerateColumnsImpl() final;
809 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
810
811 double *Map(NTupleSize_t globalIndex) {
812 return fPrincipalColumn->Map<double>(globalIndex);
813 }
814 double *Map(const RClusterIndex &clusterIndex) {
815 return fPrincipalColumn->Map<double>(clusterIndex);
816 }
817 double *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
818 return fPrincipalColumn->MapV<double>(globalIndex, nItems);
819 }
820 double *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
821 return fPrincipalColumn->MapV<double>(clusterIndex, nItems);
822 }
823
825 template <typename... ArgsT>
827 {
828 return Detail::RFieldValue(
829 Detail::RColumnElement<double>(static_cast<double*>(where)),
830 this, static_cast<double*>(where), std::forward<ArgsT>(args)...);
831 }
832 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0.0); }
834 return Detail::RFieldValue(true /* captureFlag */,
835 Detail::RColumnElement<double>(static_cast<double*>(where)), this, where);
836 }
837 size_t GetValueSize() const final { return sizeof(double); }
838 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
839};
840
841template <>
842class RField<char> : public Detail::RFieldBase {
843protected:
844 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
845 return std::make_unique<RField>(newName);
846 }
847
848public:
849 static std::string TypeName() { return "char"; }
851 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
852 RField(RField&& other) = default;
853 RField& operator =(RField&& other) = default;
854 ~RField() = default;
855
856 void GenerateColumnsImpl() final;
857 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
858
859 char *Map(NTupleSize_t globalIndex) {
860 return fPrincipalColumn->Map<char>(globalIndex);
861 }
862 char *Map(const RClusterIndex &clusterIndex) {
863 return fPrincipalColumn->Map<char>(clusterIndex);
864 }
865 char *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
866 return fPrincipalColumn->MapV<char>(globalIndex, nItems);
867 }
868 char *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
869 return fPrincipalColumn->MapV<char>(clusterIndex, nItems);
870 }
871
873 template <typename... ArgsT>
875 {
876 return Detail::RFieldValue(
877 Detail::RColumnElement<char>(static_cast<char*>(where)),
878 this, static_cast<char*>(where), std::forward<ArgsT>(args)...);
879 }
882 return Detail::RFieldValue(true /* captureFlag */,
883 Detail::RColumnElement<char>(static_cast<char*>(where)), this, where);
884 }
885 size_t GetValueSize() const final { return sizeof(char); }
886 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
887};
888
889template <>
890class RField<std::int8_t> : public Detail::RFieldBase {
891protected:
892 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
893 return std::make_unique<RField>(newName);
894 }
895
896public:
897 static std::string TypeName() { return "std::int8_t"; }
899 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
900 RField(RField&& other) = default;
901 RField& operator =(RField&& other) = default;
902 ~RField() = default;
903
904 void GenerateColumnsImpl() final;
905 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
906
907 std::int8_t *Map(NTupleSize_t globalIndex) {
908 return fPrincipalColumn->Map<std::int8_t>(globalIndex);
909 }
910 std::int8_t *Map(const RClusterIndex &clusterIndex) {
911 return fPrincipalColumn->Map<std::int8_t>(clusterIndex);
912 }
913 std::int8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
914 return fPrincipalColumn->MapV<std::int8_t>(globalIndex, nItems);
915 }
916 std::int8_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
917 return fPrincipalColumn->MapV<std::int8_t>(clusterIndex, nItems);
918 }
919
921 template <typename... ArgsT>
922 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT&&... args)
923 {
924 return Detail::RFieldValue(
925 Detail::RColumnElement<std::int8_t>(static_cast<std::int8_t*>(where)),
926 this, static_cast<std::int8_t*>(where), std::forward<ArgsT>(args)...);
927 }
928 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final { return GenerateValue(where, 0); }
929 Detail::RFieldValue CaptureValue(void *where) final {
930 return Detail::RFieldValue(true /* captureFlag */,
931 Detail::RColumnElement<std::int8_t>(static_cast<std::int8_t*>(where)), this, where);
932 }
933 size_t GetValueSize() const final { return sizeof(std::int8_t); }
934 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
935};
936
937template <>
938class RField<std::uint8_t> : public Detail::RFieldBase {
939protected:
940 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
941 return std::make_unique<RField>(newName);
942 }
943
944public:
945 static std::string TypeName() { return "std::uint8_t"; }
947 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
948 RField(RField&& other) = default;
949 RField& operator =(RField&& other) = default;
950 ~RField() = default;
951
952 void GenerateColumnsImpl() final;
953 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
954
955 std::uint8_t *Map(NTupleSize_t globalIndex) {
956 return fPrincipalColumn->Map<std::uint8_t>(globalIndex);
957 }
958 std::uint8_t *Map(const RClusterIndex &clusterIndex) {
959 return fPrincipalColumn->Map<std::uint8_t>(clusterIndex);
960 }
961 std::uint8_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
962 return fPrincipalColumn->MapV<std::uint8_t>(globalIndex, nItems);
963 }
964 std::uint8_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
965 return fPrincipalColumn->MapV<std::uint8_t>(clusterIndex, nItems);
966 }
967
969 template <typename... ArgsT>
970 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT&&... args)
971 {
972 return Detail::RFieldValue(
973 Detail::RColumnElement<std::uint8_t>(static_cast<std::uint8_t*>(where)),
974 this, static_cast<std::uint8_t*>(where), std::forward<ArgsT>(args)...);
975 }
976 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final { return GenerateValue(where, 0); }
977 Detail::RFieldValue CaptureValue(void *where) final {
978 return Detail::RFieldValue(true /* captureFlag */,
979 Detail::RColumnElement<std::uint8_t>(static_cast<std::uint8_t*>(where)), this, where);
980 }
981 size_t GetValueSize() const final { return sizeof(std::uint8_t); }
982 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
983};
984
985template <>
986class RField<std::int16_t> : public Detail::RFieldBase {
987protected:
988 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
989 return std::make_unique<RField>(newName);
990 }
991
992public:
993 static std::string TypeName() { return "std::int16_t"; }
995 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
996 RField(RField&& other) = default;
997 RField& operator =(RField&& other) = default;
998 ~RField() = default;
999
1000 void GenerateColumnsImpl() final;
1001 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1002
1003 std::int16_t *Map(NTupleSize_t globalIndex) {
1004 return fPrincipalColumn->Map<std::int16_t>(globalIndex);
1005 }
1006 std::int16_t *Map(const RClusterIndex &clusterIndex) {
1007 return fPrincipalColumn->Map<std::int16_t>(clusterIndex);
1008 }
1009 std::int16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1010 return fPrincipalColumn->MapV<std::int16_t>(globalIndex, nItems);
1011 }
1012 std::int16_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1013 return fPrincipalColumn->MapV<std::int16_t>(clusterIndex, nItems);
1014 }
1015
1017 template <typename... ArgsT>
1018 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1019 {
1020 return Detail::RFieldValue(
1021 Detail::RColumnElement<std::int16_t>(static_cast<std::int16_t*>(where)),
1022 this, static_cast<std::int16_t*>(where), std::forward<ArgsT>(args)...);
1023 }
1024 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0); }
1025 Detail::RFieldValue CaptureValue(void *where) final {
1026 return Detail::RFieldValue(true /* captureFlag */,
1027 Detail::RColumnElement<std::int16_t>(static_cast<std::int16_t*>(where)), this, where);
1028 }
1029 size_t GetValueSize() const final { return sizeof(std::int16_t); }
1030 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1031};
1032
1033template <>
1034class RField<std::uint16_t> : public Detail::RFieldBase {
1035protected:
1036 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1037 return std::make_unique<RField>(newName);
1038 }
1039
1040public:
1041 static std::string TypeName() { return "std::uint16_t"; }
1042 explicit RField(std::string_view name)
1043 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
1044 RField(RField&& other) = default;
1045 RField& operator =(RField&& other) = default;
1046 ~RField() = default;
1047
1048 void GenerateColumnsImpl() final;
1049 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1050
1051 std::uint16_t *Map(NTupleSize_t globalIndex) {
1052 return fPrincipalColumn->Map<std::uint16_t>(globalIndex);
1053 }
1054 std::uint16_t *Map(const RClusterIndex &clusterIndex) {
1055 return fPrincipalColumn->Map<std::uint16_t>(clusterIndex);
1056 }
1057 std::uint16_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1058 return fPrincipalColumn->MapV<std::uint16_t>(globalIndex, nItems);
1059 }
1060 std::uint16_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1061 return fPrincipalColumn->MapV<std::uint16_t>(clusterIndex, nItems);
1062 }
1063
1065 template <typename... ArgsT>
1066 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1067 {
1068 return Detail::RFieldValue(
1069 Detail::RColumnElement<std::uint16_t>(static_cast<std::uint16_t*>(where)),
1070 this, static_cast<std::uint16_t*>(where), std::forward<ArgsT>(args)...);
1071 }
1072 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0); }
1073 Detail::RFieldValue CaptureValue(void *where) final {
1074 return Detail::RFieldValue(true /* captureFlag */,
1075 Detail::RColumnElement<std::uint16_t>(static_cast<std::uint16_t*>(where)), this, where);
1076 }
1077 size_t GetValueSize() const final { return sizeof(std::uint16_t); }
1078 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1079};
1080
1081template <>
1082class RField<std::int32_t> : public Detail::RFieldBase {
1083protected:
1084 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1085 return std::make_unique<RField>(newName);
1086 }
1087
1088public:
1089 static std::string TypeName() { return "std::int32_t"; }
1090 explicit RField(std::string_view name)
1091 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
1092 RField(RField&& other) = default;
1093 RField& operator =(RField&& other) = default;
1094 ~RField() = default;
1095
1096 void GenerateColumnsImpl() final;
1097 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1098
1099 std::int32_t *Map(NTupleSize_t globalIndex) {
1100 return fPrincipalColumn->Map<std::int32_t>(globalIndex);
1101 }
1102 std::int32_t *Map(const RClusterIndex &clusterIndex) {
1103 return fPrincipalColumn->Map<std::int32_t>(clusterIndex);
1104 }
1105 std::int32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1106 return fPrincipalColumn->MapV<std::int32_t>(globalIndex, nItems);
1107 }
1108 std::int32_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1109 return fPrincipalColumn->MapV<std::int32_t>(clusterIndex, nItems);
1110 }
1111
1113 template <typename... ArgsT>
1114 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1115 {
1116 return Detail::RFieldValue(
1117 Detail::RColumnElement<std::int32_t>(static_cast<std::int32_t*>(where)),
1118 this, static_cast<std::int32_t*>(where), std::forward<ArgsT>(args)...);
1119 }
1120 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0); }
1121 Detail::RFieldValue CaptureValue(void *where) final {
1122 return Detail::RFieldValue(true /* captureFlag */,
1123 Detail::RColumnElement<std::int32_t>(static_cast<std::int32_t*>(where)), this, where);
1124 }
1125 size_t GetValueSize() const final { return sizeof(std::int32_t); }
1126 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1127};
1128
1129template <>
1130class RField<std::uint32_t> : public Detail::RFieldBase {
1131protected:
1132 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1133 return std::make_unique<RField>(newName);
1134 }
1135
1136public:
1137 static std::string TypeName() { return "std::uint32_t"; }
1138 explicit RField(std::string_view name)
1139 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
1140 RField(RField&& other) = default;
1141 RField& operator =(RField&& other) = default;
1142 ~RField() = default;
1143
1144 void GenerateColumnsImpl() final;
1145 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1146
1147 std::uint32_t *Map(NTupleSize_t globalIndex) {
1148 return fPrincipalColumn->Map<std::uint32_t>(globalIndex);
1149 }
1150 std::uint32_t *Map(const RClusterIndex clusterIndex) {
1151 return fPrincipalColumn->Map<std::uint32_t>(clusterIndex);
1152 }
1153 std::uint32_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1154 return fPrincipalColumn->MapV<std::uint32_t>(globalIndex, nItems);
1155 }
1156 std::uint32_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1157 return fPrincipalColumn->MapV<std::uint32_t>(clusterIndex, nItems);
1158 }
1159
1161 template <typename... ArgsT>
1162 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1163 {
1164 return Detail::RFieldValue(
1165 Detail::RColumnElement<std::uint32_t>(static_cast<std::uint32_t*>(where)),
1166 this, static_cast<std::uint32_t*>(where), std::forward<ArgsT>(args)...);
1167 }
1168 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0); }
1169 Detail::RFieldValue CaptureValue(void *where) final {
1170 return Detail::RFieldValue(true /* captureFlag */,
1171 Detail::RColumnElement<std::uint32_t>(static_cast<std::uint32_t*>(where)), this, where);
1172 }
1173 size_t GetValueSize() const final { return sizeof(std::uint32_t); }
1174 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1175};
1176
1177template <>
1178class RField<std::uint64_t> : public Detail::RFieldBase {
1179protected:
1180 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1181 return std::make_unique<RField>(newName);
1182 }
1183
1184public:
1185 static std::string TypeName() { return "std::uint64_t"; }
1186 explicit RField(std::string_view name)
1187 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
1188 RField(RField&& other) = default;
1189 RField& operator =(RField&& other) = default;
1190 ~RField() = default;
1191
1192 void GenerateColumnsImpl() final;
1193 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1194
1195 std::uint64_t *Map(NTupleSize_t globalIndex) {
1196 return fPrincipalColumn->Map<std::uint64_t>(globalIndex);
1197 }
1198 std::uint64_t *Map(const RClusterIndex &clusterIndex) {
1199 return fPrincipalColumn->Map<std::uint64_t>(clusterIndex);
1200 }
1201 std::uint64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1202 return fPrincipalColumn->MapV<std::uint64_t>(globalIndex, nItems);
1203 }
1204 std::uint64_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1205 return fPrincipalColumn->MapV<std::uint64_t>(clusterIndex, nItems);
1206 }
1207
1209 template <typename... ArgsT>
1210 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1211 {
1212 return Detail::RFieldValue(
1213 Detail::RColumnElement<std::uint64_t>(static_cast<std::uint64_t*>(where)),
1214 this, static_cast<std::uint64_t*>(where), std::forward<ArgsT>(args)...);
1215 }
1216 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0); }
1217 Detail::RFieldValue CaptureValue(void *where) final {
1218 return Detail::RFieldValue(true /* captureFlag */,
1219 Detail::RColumnElement<std::uint64_t>(static_cast<std::uint64_t*>(where)), this, where);
1220 }
1221 size_t GetValueSize() const final { return sizeof(std::uint64_t); }
1222 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1223};
1224
1225template <>
1226class RField<std::int64_t> : public Detail::RFieldBase {
1227protected:
1228 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1229 return std::make_unique<RField>(newName);
1230 }
1231
1232public:
1233 static std::string TypeName() { return "std::int64_t"; }
1234 explicit RField(std::string_view name)
1235 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, true /* isSimple */) {}
1236 RField(RField&& other) = default;
1237 RField& operator =(RField&& other) = default;
1238 ~RField() = default;
1239
1240 void GenerateColumnsImpl() final;
1241 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1242
1243 std::int64_t *Map(NTupleSize_t globalIndex) {
1244 return fPrincipalColumn->Map<std::int64_t>(globalIndex);
1245 }
1246 std::int64_t *Map(const RClusterIndex &clusterIndex) {
1247 return fPrincipalColumn->Map<std::int64_t>(clusterIndex);
1248 }
1249 std::int64_t *MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems) {
1250 return fPrincipalColumn->MapV<std::int64_t>(globalIndex, nItems);
1251 }
1252 std::int64_t *MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems) {
1253 return fPrincipalColumn->MapV<std::int64_t>(clusterIndex, nItems);
1254 }
1255
1257 template <typename... ArgsT>
1258 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1259 {
1260 return Detail::RFieldValue(
1261 Detail::RColumnElement<std::int64_t>(static_cast<std::int64_t*>(where)),
1262 this, static_cast<std::int64_t*>(where), std::forward<ArgsT>(args)...);
1263 }
1264 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, 0); }
1265 Detail::RFieldValue CaptureValue(void *where) final {
1266 return Detail::RFieldValue(true /* captureFlag */,
1267 Detail::RColumnElement<std::int64_t>(static_cast<std::int64_t*>(where)), this, where);
1268 }
1269 size_t GetValueSize() const final { return sizeof(std::int64_t); }
1270 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1271};
1272
1273template <>
1274class RField<std::string> : public Detail::RFieldBase {
1275private:
1276 ClusterSize_t fIndex;
1277 Detail::RColumnElement<ClusterSize_t, EColumnType::kIndex> fElemIndex;
1278
1279 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1280 return std::make_unique<RField>(newName);
1281 }
1285
1286public:
1287 static std::string TypeName() { return "std::string"; }
1288 explicit RField(std::string_view name)
1289 : Detail::RFieldBase(name, TypeName(), ENTupleStructure::kLeaf, false /* isSimple */)
1290 , fIndex(0), fElemIndex(&fIndex) {}
1291 RField(RField&& other) = default;
1292 RField& operator =(RField&& other) = default;
1293 ~RField() = default;
1294
1295 void GenerateColumnsImpl() final;
1296 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1297
1298 using Detail::RFieldBase::GenerateValue;
1299 template <typename... ArgsT>
1300 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1301 {
1302 return Detail::RFieldValue(this, static_cast<std::string*>(where), std::forward<ArgsT>(args)...);
1303 }
1304 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where) final { return GenerateValue(where, ""); }
1305 void DestroyValue(const Detail::RFieldValue& value, bool dtorOnly = false) {
1306 auto str = value.Get<std::string>();
1307 str->~basic_string(); // TODO(jblomer) C++17 std::destroy_at
1308 if (!dtorOnly)
1309 free(str);
1310 }
1311 Detail::RFieldValue CaptureValue(void *where) {
1312 return Detail::RFieldValue(true /* captureFlag */, this, where);
1313 }
1314 size_t GetValueSize() const final { return sizeof(std::string); }
1315 size_t GetAlignment() const final { return std::alignment_of<std::string>(); }
1316 void CommitCluster() final;
1317 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1318};
1319
1320
1321template <typename ItemT, std::size_t N>
1322class RField<std::array<ItemT, N>> : public RArrayField {
1323 using ContainerT = typename std::array<ItemT, N>;
1324public:
1325 static std::string TypeName() {
1326 return "std::array<" + RField<ItemT>::TypeName() + "," + std::to_string(N) + ">";
1327 }
1328 explicit RField(std::string_view name)
1329 : RArrayField(name, std::make_unique<RField<ItemT>>(RField<ItemT>::TypeName()), N)
1330 {}
1331 RField(RField&& other) = default;
1332 RField& operator =(RField&& other) = default;
1333 ~RField() = default;
1334
1336 template <typename... ArgsT>
1337 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT&&... args)
1338 {
1339 return Detail::RFieldValue(this, static_cast<ContainerT*>(where), std::forward<ArgsT>(args)...);
1340 }
1342 return GenerateValue(where, ContainerT());
1343 }
1344};
1345
1346
1347template <typename... ItemTs>
1348class RField<std::variant<ItemTs...>> : public RVariantField {
1349 using ContainerT = typename std::variant<ItemTs...>;
1350private:
1351 template <typename HeadT, typename... TailTs>
1352 static std::string BuildItemTypes()
1353 {
1354 std::string result = RField<HeadT>::TypeName();
1355 if constexpr(sizeof...(TailTs) > 0)
1356 result += "," + BuildItemTypes<TailTs...>();
1357 return result;
1358 }
1359
1360 template <typename HeadT, typename... TailTs>
1361 static std::vector<Detail::RFieldBase *> BuildItemFields(unsigned int index = 0)
1362 {
1363 std::vector<Detail::RFieldBase *> result;
1364 result.emplace_back(new RField<HeadT>("_" + std::to_string(index)));
1365 if constexpr(sizeof...(TailTs) > 0) {
1366 auto tailFields = BuildItemFields<TailTs...>(index + 1);
1367 result.insert(result.end(), tailFields.begin(), tailFields.end());
1368 }
1369 return result;
1370 }
1371
1372public:
1373 static std::string TypeName() { return "std::variant<" + BuildItemTypes<ItemTs...>() + ">"; }
1374 explicit RField(std::string_view name) : RVariantField(name, BuildItemFields<ItemTs...>()) {}
1375 RField(RField&& other) = default;
1376 RField& operator =(RField&& other) = default;
1377 ~RField() = default;
1378
1380 template <typename... ArgsT>
1381 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT&&... args)
1382 {
1383 return Detail::RFieldValue(this, static_cast<ContainerT*>(where), std::forward<ArgsT>(args)...);
1384 }
1386 return GenerateValue(where, ContainerT());
1387 }
1388};
1389
1390template <typename ItemT>
1391class RField<std::vector<ItemT>> : public RVectorField {
1392 using ContainerT = typename std::vector<ItemT>;
1393public:
1394 static std::string TypeName() { return "std::vector<" + RField<ItemT>::TypeName() + ">"; }
1395 explicit RField(std::string_view name)
1396 : RVectorField(name, std::make_unique<RField<ItemT>>("_0"))
1397 {}
1398 RField(RField&& other) = default;
1399 RField& operator =(RField&& other) = default;
1400 ~RField() = default;
1401
1403 template <typename... ArgsT>
1404 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1405 {
1406 return Detail::RFieldValue(this, static_cast<ContainerT*>(where), std::forward<ArgsT>(args)...);
1407 }
1409 return GenerateValue(where, ContainerT());
1410 }
1411 Detail::RFieldValue CaptureValue(void *where) final {
1412 return Detail::RFieldValue(true /* captureFlag */, this, where);
1413 }
1414 size_t GetValueSize() const final { return sizeof(ContainerT); }
1415};
1416
1417// std::vector<bool> is a template specialization and needs special treatment
1418template <>
1419class RField<std::vector<bool>> : public Detail::RFieldBase {
1420private:
1422
1423protected:
1424 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1425 return std::make_unique<RField>(newName);
1426 }
1427 std::size_t AppendImpl(const Detail::RFieldValue& value) final;
1428 void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final;
1429 void GenerateColumnsImpl() final;
1430 void GenerateColumnsImpl(const RNTupleDescriptor &desc) final;
1431
1432public:
1433 static std::string TypeName() { return "std::vector<bool>"; }
1434 explicit RField(std::string_view name);
1435 RField(RField&& other) = default;
1436 RField& operator =(RField&& other) = default;
1437 ~RField() = default;
1438
1440 template <typename... ArgsT>
1441 ROOT::Experimental::Detail::RFieldValue GenerateValue(void* where, ArgsT&&... args)
1442 {
1443 return Detail::RFieldValue(this, static_cast<std::vector<bool>*>(where), std::forward<ArgsT>(args)...);
1444 }
1446 return GenerateValue(where, std::vector<bool>());
1447 }
1448 Detail::RFieldValue CaptureValue(void *where) final {
1449 return Detail::RFieldValue(true /* captureFlag */, this, where);
1450 }
1451 std::vector<Detail::RFieldValue> SplitValue(const Detail::RFieldValue &value) const final;
1452 void DestroyValue(const Detail::RFieldValue& value, bool dtorOnly = false) final;
1453
1454 size_t GetValueSize() const final { return sizeof(std::vector<bool>); }
1455 size_t GetAlignment() const final { return std::alignment_of<std::vector<bool>>(); }
1456 void CommitCluster() final { fNWritten = 0; }
1457 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
1458 void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const {
1459 fPrincipalColumn->GetCollectionInfo(globalIndex, collectionStart, size);
1460 }
1461 void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
1462 {
1463 fPrincipalColumn->GetCollectionInfo(clusterIndex, collectionStart, size);
1464 }
1465};
1466
1467template <typename ItemT>
1468class RField<ROOT::VecOps::RVec<ItemT>> : public RRVecField {
1470protected:
1471 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final {
1472 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetName());
1473 return std::make_unique<RField<ROOT::VecOps::RVec<ItemT>>>(newName, std::move(newItemField));
1474 }
1475 std::size_t AppendImpl(const Detail::RFieldValue& value) final {
1476 auto typedValue = value.Get<ContainerT>();
1477 auto nbytes = 0;
1478 auto count = typedValue->size();
1479 for (unsigned i = 0; i < count; ++i) {
1480 auto itemValue = fSubFields[0]->CaptureValue(&typedValue->data()[i]);
1481 nbytes += fSubFields[0]->Append(itemValue);
1482 }
1484 this->fNWritten += count;
1485 fColumns[0]->Append(elemIndex);
1486 return nbytes + sizeof(elemIndex);
1487 }
1489 auto typedValue = value->Get<ContainerT>();
1490 ClusterSize_t nItems;
1491 RClusterIndex collectionStart;
1492 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1493 typedValue->resize(nItems);
1494 for (unsigned i = 0; i < nItems; ++i) {
1495 auto itemValue = fSubFields[0]->CaptureValue(&typedValue->data()[i]);
1496 fSubFields[0]->Read(collectionStart + i, &itemValue);
1497 }
1498 }
1499
1500public:
1501 RField(std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField)
1502 : RRVecField(fieldName, std::move(itemField))
1503 {
1504 }
1505
1507 : RField(name, std::make_unique<RField<ItemT>>("_0"))
1508 {
1509 }
1510 RField(RField&& other) = default;
1511 RField& operator =(RField&& other) = default;
1512 ~RField() = default;
1513
1514 void DestroyValue(const Detail::RFieldValue& value, bool dtorOnly = false) final {
1515 auto vec = reinterpret_cast<ContainerT*>(value.GetRawPtr());
1516 vec->~RVec();
1517 if (!dtorOnly)
1518 free(vec);
1519 }
1520
1521 static std::string TypeName() { return "ROOT::VecOps::RVec<" + RField<ItemT>::TypeName() + ">"; }
1522
1524 template <typename... ArgsT>
1526 {
1527 return Detail::RFieldValue(this, static_cast<ContainerT*>(where), std::forward<ArgsT>(args)...);
1528 }
1530 return GenerateValue(where, ContainerT());
1531 }
1533 return Detail::RFieldValue(true /* captureFlag */, this, static_cast<ContainerT*>(where));
1534 }
1535 size_t GetValueSize() const final { return sizeof(ContainerT); }
1536 size_t GetAlignment() const final { return std::alignment_of<ContainerT>(); }
1537};
1538
1539template <typename T1, typename T2>
1540class RField<std::pair<T1, T2>> : public RPairField {
1541 using ContainerT = typename std::pair<T1,T2>;
1542private:
1543 template <typename Ty1, typename Ty2>
1544 static std::array<std::unique_ptr<Detail::RFieldBase>, 2> BuildItemFields()
1545 {
1546 return {std::make_unique<RField<Ty1>>("_0"), std::make_unique<RField<Ty2>>("_1")};
1547 }
1548
1549protected:
1550 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final
1551 {
1552 std::array<std::unique_ptr<Detail::RFieldBase>, 2> items{fSubFields[0]->Clone(fSubFields[0]->GetName()),
1553 fSubFields[1]->Clone(fSubFields[1]->GetName())};
1554 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
1555 }
1556
1557public:
1558 static std::string TypeName() {
1559 return "std::pair<" + RField<T1>::TypeName() + "," + RField<T2>::TypeName() + ">";
1560 }
1561 explicit RField(std::string_view name, std::array<std::unique_ptr<Detail::RFieldBase>, 2> &&itemFields)
1562 : RPairField(name, std::move(itemFields), {offsetof(ContainerT, first), offsetof(ContainerT, second)})
1563 {
1564 fMaxAlignment = std::max(alignof(T1), alignof(T2));
1565 fSize = sizeof(ContainerT);
1566 }
1567 explicit RField(std::string_view name) : RField(name, BuildItemFields<T1, T2>()) {}
1568 RField(RField&& other) = default;
1569 RField& operator =(RField&& other) = default;
1570 ~RField() = default;
1571
1573 template <typename... ArgsT>
1574 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT&&... args)
1575 {
1576 return Detail::RFieldValue(this, static_cast<ContainerT*>(where), std::forward<ArgsT>(args)...);
1577 }
1579 return GenerateValue(where, ContainerT());
1580 }
1581 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) final
1582 {
1583 reinterpret_cast<ContainerT *>(value.GetRawPtr())->~pair();
1584 if (!dtorOnly)
1585 free(reinterpret_cast<ContainerT *>(value.GetRawPtr()));
1586 }
1587};
1588
1589template <typename... ItemTs>
1590class RField<std::tuple<ItemTs...>> : public RTupleField {
1591 using ContainerT = typename std::tuple<ItemTs...>;
1592private:
1593 template <typename HeadT, typename... TailTs>
1594 static std::string BuildItemTypes()
1595 {
1596 std::string result = RField<HeadT>::TypeName();
1597 if constexpr (sizeof...(TailTs) > 0)
1598 result += "," + BuildItemTypes<TailTs...>();
1599 return result;
1600 }
1601
1602 template <typename HeadT, typename... TailTs>
1603 static void _BuildItemFields(std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields, unsigned int index = 0)
1604 {
1605 itemFields.emplace_back(new RField<HeadT>("_" + std::to_string(index)));
1606 if constexpr (sizeof...(TailTs) > 0)
1607 _BuildItemFields<TailTs...>(itemFields, index + 1);
1608 }
1609 template <typename... Ts>
1610 static std::vector<std::unique_ptr<Detail::RFieldBase>> BuildItemFields()
1611 {
1612 std::vector<std::unique_ptr<Detail::RFieldBase>> result;
1613 _BuildItemFields<Ts...>(result);
1614 return result;
1615 }
1616
1617 template <unsigned Index, typename HeadT, typename... TailTs>
1618 static void _BuildItemOffsets(std::vector<std::size_t> &offsets, const ContainerT &tuple)
1619 {
1620 auto offset =
1621 reinterpret_cast<std::uintptr_t>(&std::get<Index>(tuple)) - reinterpret_cast<std::uintptr_t>(&tuple);
1622 offsets.emplace_back(offset);
1623 if constexpr (sizeof...(TailTs) > 0)
1624 _BuildItemOffsets<Index + 1, TailTs...>(offsets, tuple);
1625 }
1626 template <typename... Ts>
1627 static std::vector<std::size_t> BuildItemOffsets()
1628 {
1629 std::vector<std::size_t> result;
1630 _BuildItemOffsets<0, Ts...>(result, ContainerT());
1631 return result;
1632 }
1633
1634protected:
1635 std::unique_ptr<Detail::RFieldBase> CloneImpl(std::string_view newName) const final
1636 {
1637 std::vector<std::unique_ptr<Detail::RFieldBase>> items;
1638 for (auto &item : fSubFields)
1639 items.push_back(item->Clone(item->GetName()));
1640 return std::make_unique<RField<std::tuple<ItemTs...>>>(newName, std::move(items));
1641 }
1642
1643public:
1644 static std::string TypeName() { return "std::tuple<" + BuildItemTypes<ItemTs...>() + ">"; }
1645 explicit RField(std::string_view name, std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields)
1646 : RTupleField(name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
1647 {
1648 fMaxAlignment = std::max({alignof(ItemTs)...});
1649 fSize = sizeof(ContainerT);
1650 }
1651 explicit RField(std::string_view name) : RField(name, BuildItemFields<ItemTs...>()) {}
1652 RField(RField &&other) = default;
1653 RField &operator=(RField &&other) = default;
1654 ~RField() = default;
1655
1657 template <typename... ArgsT>
1658 ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&...args)
1659 {
1660 return Detail::RFieldValue(this, static_cast<ContainerT *>(where), std::forward<ArgsT>(args)...);
1661 }
1663 {
1664 return GenerateValue(where, ContainerT());
1665 }
1666 void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly = false) final
1667 {
1668 reinterpret_cast<ContainerT *>(value.GetRawPtr())->~tuple();
1669 if (!dtorOnly)
1670 free(reinterpret_cast<ContainerT *>(value.GetRawPtr()));
1671 }
1672};
1673
1674} // namespace Experimental
1675} // namespace ROOT
1676
1677#endif
size_t fSize
Cppyy::TCppType_t fClass
ROOT::Experimental::RField< T > RField
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define N
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
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 id
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 Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition: TGX11.cxx:110
#define free
Definition: civetweb.c:1539
Pairs of C++ type and column type, like float and EColumnType::kReal32.
void Append(const RColumnElementBase &element)
Definition: RColumn.hxx:116
CppT * MapV(const NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition: RColumn.hxx:225
CppT * Map(const NTupleSize_t globalIndex)
Definition: RColumn.hxx:213
void Read(const NTupleSize_t globalIndex, RColumnElementBase *element)
Definition: RColumn.hxx:157
NTupleSize_t GetGlobalIndex(const RClusterIndex &clusterIndex)
Definition: RColumn.hxx:248
NTupleSize_t GetNElements() const
Definition: RColumn.hxx:307
void GetCollectionInfo(const NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *collectionSize)
For offset columns only, look at the two adjacent values that define a collection's coordinates.
Definition: RColumn.hxx:264
Iterates over the sub tree of fields in depth-first search order.
Definition: RField.hxx:129
void Advance()
Given that the iterator points to a valid field which is not the end iterator, go to the next field i...
Definition: RField.cxx:419
std::vector< Position > fStack
The stack of nodes visited when walking down the tree of fields.
Definition: RField.hxx:138
virtual std::uint32_t GetFieldVersion() const
Indicates an evolution of the mapping scheme from C++ type to columns.
Definition: RField.hxx:255
RFieldBase * GetParent() const
Definition: RField.hxx:239
virtual RFieldValue CaptureValue(void *where)=0
Creates a value from a memory location with an already constructed object.
std::string GetDescription() const
Get the field's description.
Definition: RField.hxx:243
void SetOnDiskId(DescriptorId_t id)
Definition: RField.hxx:247
virtual void GenerateColumnsImpl(const RNTupleDescriptor &desc)=0
Creates the backing columns corresponsing to the field type for reading.
virtual void GenerateColumnsImpl()=0
Creates the backing columns corresponsing to the field type for writing.
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
Definition: RField.hxx:94
RFieldBase * fParent
Sub fields point to their mother field.
Definition: RField.hxx:96
RFieldBase(std::string_view name, std::string_view type, ENTupleStructure structure, bool isSimple, std::size_t nRepetitions=0)
The constructor creates the underlying column objects and connects them to either a sink or a source.
Definition: RField.cxx:156
std::size_t GetNRepetitions() const
Definition: RField.hxx:237
std::string fDescription
Free text set by the user.
Definition: RField.hxx:90
virtual std::uint32_t GetTypeVersion() const
Indicates an evolution of the C++ type itself.
Definition: RField.hxx:257
virtual void DestroyValue(const RFieldValue &value, bool dtorOnly=false)
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:301
DescriptorId_t GetOnDiskId() const
Definition: RField.hxx:246
void ConnectPageSink(RPageSink &pageSink)
Fields and their columns live in the void until connected to a physical page storage.
Definition: RField.cxx:372
ROOT::Experimental::EColumnType EnsureColumnType(const std::vector< EColumnType > &requestedTypes, unsigned int columnIndex, const RNTupleDescriptor &desc)
Throws an exception if the column given by fOnDiskId and the columnIndex in the provided descriptor i...
Definition: RField.cxx:339
void Flush() const
Ensure that all received items are written from page buffers to the storage.
Definition: RField.cxx:331
virtual void ReadInClusterImpl(const RClusterIndex &clusterIndex, RFieldValue *value)
Definition: RField.hxx:118
virtual void CommitCluster()
Perform housekeeping tasks for global to cluster-local index translation.
Definition: RField.hxx:229
virtual size_t GetAlignment() const
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:196
virtual std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const =0
Called by Clone(), which additionally copies the on-disk ID.
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
void SetDescription(std::string_view description)
Definition: RField.hxx:244
virtual std::vector< RFieldValue > SplitValue(const RFieldValue &value) const
Creates the list of direct child values given a value for this field.
Definition: RField.cxx:308
static RResult< void > EnsureValidFieldName(std::string_view fieldName)
Check whether a given string is a valid field name.
Definition: RField.cxx:262
bool fIsSimple
A field on a trivial type that maps as-is to a single column.
Definition: RField.hxx:84
std::string fType
The C++ type captured by this field.
Definition: RField.hxx:78
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName)
Factory method to resurrect a field from the stored on-disk type information.
Definition: RField.cxx:168
std::string fName
The field name relative to its parent field.
Definition: RField.hxx:76
NTupleSize_t GetNElements() const
Definition: RField.hxx:238
void ConnectPageSource(RPageSource &pageSource)
Definition: RField.cxx:383
std::size_t Append(const RFieldValue &value)
Write the given value into columns.
Definition: RField.hxx:200
virtual std::size_t AppendImpl(const RFieldValue &value)
Operations on values of complex types, e.g.
Definition: RField.cxx:281
std::unique_ptr< RFieldBase > Clone(std::string_view newName) const
Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns.
Definition: RField.cxx:273
std::size_t fNRepetitions
For fixed sized arrays, the array length.
Definition: RField.hxx:82
RFieldBase(const RFieldBase &)=delete
virtual void AcceptVisitor(RFieldVisitor &visitor) const
Definition: RField.cxx:397
DescriptorId_t fOnDiskId
When the columns are connected to a page source or page sink, the field represents a field id in the ...
Definition: RField.hxx:88
virtual void ReadGlobalImpl(NTupleSize_t globalIndex, RFieldValue *value)
Definition: RField.cxx:287
ENTupleStructure fStructure
The role of this field in the data model structure.
Definition: RField.hxx:80
void Read(const RClusterIndex &clusterIndex, RFieldValue *value)
Definition: RField.hxx:218
std::vector< std::unique_ptr< RColumn > > fColumns
The columns are connected either to a sink or to a source (not to both); they are owned by the field.
Definition: RField.hxx:102
void Attach(std::unique_ptr< Detail::RFieldBase > child)
Add a new subfield to the list of nested fields.
Definition: RField.cxx:313
std::vector< RFieldBase * > GetSubFields() const
Definition: RField.cxx:321
virtual RFieldValue GenerateValue(void *where)=0
Generates a tree value in a given location of size at least GetValueSize().
RFieldBase & operator=(const RFieldBase &)=delete
ENTupleStructure GetStructure() const
Definition: RField.hxx:236
void Read(NTupleSize_t globalIndex, RFieldValue *value)
Populate a single value with data from the tree, which needs to be of the fitting type.
Definition: RField.hxx:210
RFieldValue GenerateValue()
Generates an object of the field type and allocates new initialized memory according to the type.
Definition: RField.cxx:294
RColumn * fPrincipalColumn
Points into fColumns.
Definition: RField.hxx:100
Abstract base class for classes implementing the visitor design pattern.
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
The available trivial, native content types of a column.
The generic field for fixed size arrays, which do not need an offset column.
Definition: RField.hxx:467
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
Definition: RField.cxx:1557
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.cxx:1551
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:1513
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:1504
RArrayField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField, std::size_t arrayLength)
Definition: RField.cxx:1477
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition: RField.cxx:1568
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.cxx:1523
RArrayField & operator=(RArrayField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:492
RArrayField(RArrayField &&other)=default
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:1540
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:493
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
Definition: RField.cxx:1494
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:1488
The field for a class with dictionary.
Definition: RField.hxx:288
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.cxx:889
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
Definition: RField.hxx:299
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
Definition: RField.cxx:907
void Attach(std::unique_ptr< Detail::RFieldBase > child, RSubFieldInfo info)
Definition: RField.cxx:831
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
Definition: RField.cxx:896
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:839
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
Definition: RField.cxx:844
RClassField & operator=(RClassField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const override
Definition: RField.cxx:912
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:330
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:861
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.cxx:869
RClassField(std::string_view fieldName, std::string_view className, TClass *classp)
Definition: RField.cxx:797
std::vector< RSubFieldInfo > fSubFieldsInfo
Additional information kept for each entry in fSubFields
Definition: RField.hxx:303
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:853
RClassField(RClassField &&other)=default
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:882
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Definition: RNTupleUtil.hxx:87
The collection field is only used for writing; when reading, untyped collections are projected to an ...
Definition: RField.hxx:558
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:582
static std::string TypeName()
Definition: RField.hxx:565
std::shared_ptr< RCollectionNTupleWriter > fCollectionNTuple
Save the link to the collection ntuple in order to reset the offset counter when committing the clust...
Definition: RField.hxx:561
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:586
RCollectionField(RCollectionField &&other)=default
A field translates read and write calls from/to underlying columns to/from tree values.
Represents transient storage of simple or complex C++ values.
The container field for an ntuple model, which itself has no physical representation.
Definition: RField.hxx:270
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition: RField.cxx:455
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:446
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:282
Detail::RFieldValue GenerateValue(void *)
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:280
Detail::RFieldValue CaptureValue(void *) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:281
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.hxx:277
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
Definition: RField.hxx:278
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
Definition: RField.hxx:689
ClusterSize_t * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition: RField.hxx:663
ClusterSize_t * Map(const RClusterIndex &clusterIndex)
Definition: RField.hxx:660
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:679
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:683
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
ClusterSize_t * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
Definition: RField.hxx:666
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size)
Special help for offset fields.
Definition: RField.hxx:686
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:672
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:678
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.hxx:642
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:1532
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:1529
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Definition: RField.hxx:1488
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:1535
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
Definition: RField.hxx:1475
typename ROOT::VecOps::RVec< ItemT > ContainerT
Definition: RField.hxx:1469
RField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
Definition: RField.hxx:1501
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.hxx:1471
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:1536
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:1525
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.hxx:1514
bool * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition: RField.hxx:720
RField(std::string_view name)
Definition: RField.hxx:705
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:740
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.hxx:699
bool * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
Definition: RField.hxx:723
static std::string TypeName()
Definition: RField.hxx:704
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:729
RField(RField &&other)=default
bool * Map(const RClusterIndex &clusterIndex)
Definition: RField.hxx:717
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:736
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:735
char * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition: RField.hxx:865
RField(std::string_view name)
Definition: RField.hxx:850
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:885
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:880
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.hxx:844
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:874
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:881
RField(RField &&other)=default
char * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
Definition: RField.hxx:868
static std::string TypeName()
Definition: RField.hxx:849
char * Map(const RClusterIndex &clusterIndex)
Definition: RField.hxx:862
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:833
double * Map(const RClusterIndex &clusterIndex)
Definition: RField.hxx:814
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.hxx:796
double * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition: RField.hxx:817
double * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
Definition: RField.hxx:820
RField(std::string_view name)
Definition: RField.hxx:802
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:826
RField(RField &&other)=default
static std::string TypeName()
Definition: RField.hxx:801
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:837
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:832
static std::string TypeName()
Definition: RField.hxx:752
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:783
RField(RField &&other)=default
float * MapV(NTupleSize_t globalIndex, NTupleSize_t &nItems)
Definition: RField.hxx:768
float * MapV(const RClusterIndex &clusterIndex, NTupleSize_t &nItems)
Definition: RField.hxx:771
RField(std::string_view name)
Definition: RField.hxx:753
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:777
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:788
float * Map(const RClusterIndex &clusterIndex)
Definition: RField.hxx:765
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.hxx:784
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.hxx:747
Classes with dictionaries that can be inspected by TClass.
Definition: RField.hxx:537
RField(std::string_view name)
Definition: RField.hxx:540
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
Definition: RField.hxx:549
RField(RField &&other)=default
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
Definition: RField.hxx:553
static std::string TypeName()
Definition: RField.hxx:539
The on-storage meta-data of an ntuple.
The generic field for std::pair<T1, T2> types.
Definition: RField.hxx:591
static std::string GetTypeList(const std::array< std::unique_ptr< Detail::RFieldBase >, 2 > &itemFields)
RPairField(RPairField &&other)=default
RPairField & operator=(RPairField &&other)=default
The type-erased field for a RVec<Type>
Definition: RField.hxx:422
Detail::RFieldValue CaptureValue(void *where) override
Creates a value from a memory location with an already constructed object.
Definition: RField.cxx:1299
std::size_t EvalValueSize() const
Evaluate the constant returned by GetValueSize.
Definition: RField.cxx:1318
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) override
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:1272
RRVecField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
Definition: RField.cxx:1160
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
Definition: RField.cxx:1378
RRVecField(RRVecField &&)=default
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
Definition: RField.hxx:460
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) override
Definition: RField.cxx:1193
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition: RField.cxx:1383
size_t GetAlignment() const override
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.cxx:1371
RRVecField(const RRVecField &)=delete
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:1170
RRVecField & operator=(RRVecField &&)=default
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
Definition: RField.cxx:1366
std::size_t AppendImpl(const Detail::RFieldValue &value) override
Operations on values of complex types, e.g.
Definition: RField.cxx:1176
RRVecField & operator=(RRVecField &)=delete
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
Definition: RField.cxx:1305
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
Definition: RField.hxx:456
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.cxx:1248
The field for an untyped record.
Definition: RField.hxx:336
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:965
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:380
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:381
std::vector< std::size_t > fOffsets
Definition: RField.hxx:340
RRecordField(RRecordField &&other)=default
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
Definition: RField.cxx:973
RRecordField(std::string_view fieldName, std::array< std::unique_ptr< Detail::RFieldBase >, N > &&itemFields, const std::array< std::size_t, N > &offsets, std::string_view typeName="")
Definition: RField.hxx:353
void GenerateColumnsImpl(const RNTupleDescriptor &) final
Creates the backing columns corresponsing to the field type for reading.
Definition: RField.hxx:374
RRecordField(std::string_view fieldName, std::vector< std::unique_ptr< Detail::RFieldBase > > &&itemFields, const std::vector< std::size_t > &offsets, std::string_view typeName="")
Definition: RField.cxx:919
std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment) const
Definition: RField.cxx:954
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:982
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.cxx:1017
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
Definition: RField.cxx:1024
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) override
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:1006
RRecordField & operator=(RRecordField &&other)=default
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:990
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.hxx:373
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition: RField.cxx:1034
RResult<void> has no data member and no Inspect() method but instead a Success() factory method.
Definition: RError.hxx:257
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition: RError.hxx:195
The generic field for std::tuple<Ts...> types.
Definition: RField.hxx:614
static std::string GetTypeList(const std::vector< std::unique_ptr< Detail::RFieldBase > > &itemFields)
RTupleField & operator=(RTupleField &&other)=default
RTupleField(RTupleField &&other)=default
The generic field for std::variant types.
Definition: RField.hxx:498
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
Definition: RField.cxx:1626
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Definition: RField.cxx:1692
RVariantField & operator=(RVariantField &&other)=default
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:1675
std::vector< ClusterSize_t::ValueType > fNWritten
Definition: RField.hxx:504
size_t fTagOffset
In the std::variant memory layout, at which byte number is the index stored.
Definition: RField.hxx:503
void SetTag(void *variantPtr, std::uint32_t tag) const
Definition: RField.cxx:1620
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.cxx:1654
std::uint32_t GetTag(void *variantPtr) const
Extracts the index from an std::variant and transforms it into the 1-based index used for the switch ...
Definition: RField.cxx:1614
static std::string GetTypeList(const std::vector< Detail::RFieldBase * > &itemFields)
Definition: RField.cxx:1575
RVariantField(std::string_view fieldName, const std::vector< Detail::RFieldBase * > &itemFields)
Definition: RField.cxx:1586
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:1642
RVariantField(RVariantField &&other)=default
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:530
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Definition: RField.cxx:1687
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:1603
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
Definition: RField.cxx:1697
The generic field for a (nested) std::vector<Type> except for std::vector<bool>
Definition: RField.hxx:386
Detail::RFieldValue CaptureValue(void *where) override
Creates a value from a memory location with an already constructed object.
Definition: RField.cxx:1129
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
Definition: RField.cxx:1147
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Definition: RField.cxx:1052
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Definition: RField.cxx:1152
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
Definition: RField.hxx:409
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
Definition: RField.cxx:1135
void GetCollectionInfo(const RClusterIndex &clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
Definition: RField.hxx:416
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Definition: RField.cxx:1073
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
Definition: RField.hxx:413
RVectorField & operator=(RVectorField &&other)=default
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
Definition: RField.cxx:1097
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Definition: RField.hxx:410
RVectorField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
Definition: RField.cxx:1042
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Definition: RField.cxx:1115
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
Definition: RField.cxx:1058
RVectorField(RVectorField &&other)=default
A "std::vector"-like collection of values implementing handy operation to analyse them.
Definition: RVec.hxx:1456
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
RooCmdArg Index(RooCategory &icat)
auto Map(Args &&... args)
Create new collection applying a callable to the elements of the input collection.
Definition: RVec.hxx:2062
basic_string_view< char > string_view
#define T2
Definition: md5.inl:147
#define T1
Definition: md5.inl:146
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:47
RClusterSize ClusterSize_t
Definition: RNTupleUtil.hxx:62
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
Definition: RNTupleUtil.hxx:37
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
Definition: RNTupleUtil.hxx:83
constexpr DescriptorId_t kInvalidDescriptorId
Definition: RNTupleUtil.hxx:84
std::string GetDemangledTypeName(const std::type_info &t)
double T(double x)
Definition: ChebyshevPol.h:34
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
static constexpr double second
Definition: first.py:1
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...
Definition: RNTupleUtil.hxx:50
Definition: civetweb.c:1856