Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RFieldSoA.hxx
Go to the documentation of this file.
1/// \file ROOT/RField/RFieldSoA.hxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2026-03-03
5
6/*************************************************************************
7 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#ifndef ROOT_RField_SoA
15#define ROOT_RField_SoA
16
17#ifndef ROOT_RField
18#error "Please include RField.hxx!"
19#endif
20
21#include <ROOT/RFieldBase.hxx>
22#include <ROOT/RNTupleTypes.hxx>
23
24#include <cstddef>
25#include <memory>
26#include <string_view>
27#include <typeinfo>
28#include <vector>
29
30class TClass;
31
32namespace ROOT {
33
34namespace Experimental {
35
36/// The SoA field provides I/O for an in-memory SoA layout linked to an on-disk collection of the underlying record.
37/// As a concrete example, for an underlying record type
38/// \code{.cpp}
39/// struct PointRecord {
40/// float px, py;
41/// };
42/// \endcode
43/// a corresponding SoA layout will look like
44/// \code{.cpp}
45/// struct PointSoA {
46/// ROOT::RVec<float> px;
47/// ROOT::RVec<float> py;
48/// };
49/// \endcode
50///
51/// The SoA type has to be marked in the dictionary with the rntupleSoARecord attribute.
52///
53/// Since the on-disk representation is a collection of record type, the class version and checksum of the SoA type
54/// itself is ignored.
55class RSoAField : public RFieldBase {
56 class RSoADeleter : public RDeleter {
57 private:
59
60 public:
61 explicit RSoADeleter(TClass *cl) : fSoAClass(cl) {}
62 void operator()(void *objPtr, bool dtorOnly) final;
63 };
64
65 TClass *fSoAClass = nullptr;
66 std::vector<std::size_t> fSoAMemberOffsets; ///< The offset of the RVec members in the SoA type
67 std::vector<std::size_t> fRecordMemberIndexes; ///< Maps the SoA members to the members of the underlying record
68 std::vector<RFieldBase *> fRecordMemberFields; ///< Direct access to the member fields of the underlying record
69 std::size_t fMaxAlignment = 1;
71
72 RSoAField(std::string_view fieldName, const RSoAField &source); ///< Used by CloneImpl
73 RSoAField(std::string_view fieldName, TClass *clSoA);
74
75protected:
76 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName) const final;
77
81
82 void ConstructValue(void *where) const final;
83 std::unique_ptr<RDeleter> GetDeleter() const final { return std::make_unique<RSoADeleter>(fSoAClass); }
84
85 std::size_t AppendImpl(const void *from) final;
86 void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
87
89
91
92public:
93 RSoAField(std::string_view fieldName, std::string_view className);
96 ~RSoAField() override = default;
97
98 std::vector<RValue> SplitValue(const RValue &value) const final;
99 size_t GetValueSize() const final;
101 /// For polymorphic classes (that declare or inherit at least one virtual method), return the expected dynamic type
102 /// of any user object. If the class is not polymorphic, return nullptr.
103 /// TODO(jblomer): use information in unique pointer field
104 const std::type_info *GetPolymorphicTypeInfo() const;
105 // TODO(jblomer)
106 // void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final;
107};
108
109} // namespace Experimental
110} // namespace ROOT
111
112#endif // ROOT_RField_SoA
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
void operator()(void *objPtr, bool dtorOnly) final
The SoA field provides I/O for an in-memory SoA layout linked to an on-disk collection of the underly...
Definition RFieldSoA.hxx:55
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
~RSoAField() override=default
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
std::vector< std::size_t > fSoAMemberOffsets
The offset of the RVec members in the SoA type.
Definition RFieldSoA.hxx:66
const std::type_info * GetPolymorphicTypeInfo() const
For polymorphic classes (that declare or inherit at least one virtual method), return the expected dy...
RSoAField & operator=(RSoAField &&other)=default
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
std::vector< RFieldBase * > fRecordMemberFields
Direct access to the member fields of the underlying record.
Definition RFieldSoA.hxx:68
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
RSoAField(std::string_view fieldName, const RSoAField &source)
Used by CloneImpl.
std::unique_ptr< RDeleter > GetDeleter() const final
Definition RFieldSoA.hxx:83
RSoAField(RSoAField &&other)=default
std::vector< std::size_t > fRecordMemberIndexes
Maps the SoA members to the members of the underlying record.
Definition RFieldSoA.hxx:67
void ReconcileOnDiskField(const RNTupleDescriptor &) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
Definition RFieldSoA.hxx:88
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
ROOT::Internal::RColumnIndex fNWritten
Definition RFieldSoA.hxx:70
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
The in-memory representation of a 32bit or 64bit on-disk index column.
The list of column representations a field can have.
A functor to release the memory acquired by CreateValue() (memory and constructor).
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
A field translates read and write calls from/to underlying columns to/from tree values.
The on-storage metadata of an RNTuple.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.