@@ -67,6 +67,50 @@ struct RNTupleClusterBoundaries {
67
67
std::vector<ROOT::Internal::RNTupleClusterBoundaries> GetClusterBoundaries (const RNTupleDescriptor &desc);
68
68
} // namespace Internal
69
69
70
+ namespace Experimental {
71
+
72
+ // clang-format off
73
+ /* *
74
+ \class ROOT::Experimental::RNTupleAttrSetDescriptor
75
+ \ingroup NTuple
76
+ \brief Metadata stored for every Attribute Set linked to an RNTuple.
77
+ */
78
+ // clang-format on
79
+ class RNTupleAttrSetDescriptor final {
80
+ friend class Experimental ::Internal::RNTupleAttrSetDescriptorBuilder;
81
+
82
+ std::uint16_t fSchemaVersionMajor = 0 ;
83
+ std::uint16_t fSchemaVersionMinor = 0 ;
84
+ std::uint32_t fAnchorLength = 0 ; // /< uncompressed size of the linked anchor
85
+ // The locator of the AttributeSet anchor.
86
+ // In case of kTypeFile, it points to the beginning of the Anchor's payload.
87
+ // NOTE: Only kTypeFile is supported at the moment.
88
+ RNTupleLocator fAnchorLocator ;
89
+ std::string fName ;
90
+
91
+ public:
92
+ RNTupleAttrSetDescriptor () = default ;
93
+ RNTupleAttrSetDescriptor (const RNTupleAttrSetDescriptor &other) = delete ;
94
+ RNTupleAttrSetDescriptor &operator =(const RNTupleAttrSetDescriptor &other) = delete ;
95
+ RNTupleAttrSetDescriptor (RNTupleAttrSetDescriptor &&other) = default ;
96
+ RNTupleAttrSetDescriptor &operator =(RNTupleAttrSetDescriptor &&other) = default ;
97
+
98
+ bool operator ==(const RNTupleAttrSetDescriptor &other) const ;
99
+ bool operator !=(const RNTupleAttrSetDescriptor &other) const { return !(*this == other); }
100
+
101
+ const std::string &GetName () const { return fName ; }
102
+ std::uint16_t GetSchemaVersionMajor () const { return fSchemaVersionMajor ; }
103
+ std::uint16_t GetSchemaVersionMinor () const { return fSchemaVersionMinor ; }
104
+ std::uint32_t GetAnchorLength () const { return fAnchorLength ; }
105
+ const RNTupleLocator &GetAnchorLocator () const { return fAnchorLocator ; }
106
+
107
+ RNTupleAttrSetDescriptor Clone () const ;
108
+ };
109
+
110
+ class RNTupleAttrSetDescriptorIterable ;
111
+
112
+ } // namespace Experimental
113
+
70
114
// clang-format off
71
115
/* *
72
116
\class ROOT::RFieldDescriptor
@@ -701,6 +745,8 @@ private:
701
745
std::vector<ROOT::DescriptorId_t> fSortedClusterGroupIds ;
702
746
// / Potentially a subset of all the available clusters
703
747
std::unordered_map<ROOT::DescriptorId_t, RClusterDescriptor> fClusterDescriptors ;
748
+ // / List of AttributeSets linked to this RNTuple
749
+ std::vector<Experimental::RNTupleAttrSetDescriptor> fAttributeSets ;
704
750
705
751
// We don't expose this publicly because when we add sharded clusters, this interface does not make sense anymore
706
752
ROOT::DescriptorId_t FindClusterId (ROOT::NTupleSize_t entryIdx) const ;
@@ -718,6 +764,7 @@ public:
718
764
class RClusterGroupDescriptorIterable ;
719
765
class RClusterDescriptorIterable ;
720
766
class RExtraTypeInfoDescriptorIterable ;
767
+ friend class Experimental ::RNTupleAttrSetDescriptorIterable;
721
768
722
769
// / Modifiers passed to CreateModel()
723
770
struct RCreateModelOptions {
@@ -806,6 +853,8 @@ public:
806
853
807
854
RExtraTypeInfoDescriptorIterable GetExtraTypeInfoIterable () const ;
808
855
856
+ ROOT::Experimental::RNTupleAttrSetDescriptorIterable GetAttrSetIterable () const ;
857
+
809
858
const std::string &GetName () const { return fName ; }
810
859
const std::string &GetDescription () const { return fDescription ; }
811
860
@@ -816,6 +865,7 @@ public:
816
865
std::size_t GetNClusters () const { return fNClusters ; }
817
866
std::size_t GetNActiveClusters () const { return fClusterDescriptors .size (); }
818
867
std::size_t GetNExtraTypeInfos () const { return fExtraTypeInfoDescriptors .size (); }
868
+ std::size_t GetNAttributeSets () const { return fAttributeSets .size (); }
819
869
820
870
// / We know the number of entries from adding the cluster summaries
821
871
ROOT::NTupleSize_t GetNEntries () const { return fNEntries ; }
@@ -1145,6 +1195,59 @@ public:
1145
1195
RIterator end () { return RIterator (fNTuple .fExtraTypeInfoDescriptors .cend ()); }
1146
1196
};
1147
1197
1198
+ namespace Experimental {
1199
+ // clang-format off
1200
+ /* *
1201
+ \class ROOT::Experimental::RNTupleAttrSetDescriptorIterable
1202
+ \ingroup NTuple
1203
+ \brief Used to loop over all the Attribute Sets linked to an RNTuple
1204
+ */
1205
+ // clang-format on
1206
+ // TODO: move this to RNTupleDescriptor::RNTupleAttrSetDescriptorIterable when it moves out of Experimental.
1207
+ class RNTupleAttrSetDescriptorIterable final {
1208
+ private:
1209
+ // / The associated RNTuple for this range.
1210
+ const RNTupleDescriptor &fNTuple ;
1211
+
1212
+ public:
1213
+ class RIterator final {
1214
+ private:
1215
+ using Iter_t = std::vector<RNTupleAttrSetDescriptor>::const_iterator;
1216
+ // / The wrapped vector iterator
1217
+ Iter_t fIter ;
1218
+
1219
+ public:
1220
+ using iterator_category = std::forward_iterator_tag;
1221
+ using iterator = RIterator;
1222
+ using value_type = RNTupleAttrSetDescriptor;
1223
+ using difference_type = std::ptrdiff_t ;
1224
+ using pointer = const value_type *;
1225
+ using reference = const value_type &;
1226
+
1227
+ RIterator (Iter_t iter) : fIter (iter) {}
1228
+ iterator &operator ++() /* prefix */
1229
+ {
1230
+ ++fIter ;
1231
+ return *this ;
1232
+ }
1233
+ iterator operator ++(int ) /* postfix */
1234
+ {
1235
+ auto old = *this ;
1236
+ operator ++();
1237
+ return old;
1238
+ }
1239
+ reference operator *() const { return *fIter ; }
1240
+ pointer operator ->() const { return &*fIter ; }
1241
+ bool operator !=(const iterator &rh) const { return fIter != rh.fIter ; }
1242
+ bool operator ==(const iterator &rh) const { return fIter == rh.fIter ; }
1243
+ };
1244
+
1245
+ RNTupleAttrSetDescriptorIterable (const RNTupleDescriptor &ntuple) : fNTuple (ntuple) {}
1246
+ RIterator begin () { return RIterator (fNTuple .fAttributeSets .cbegin ()); }
1247
+ RIterator end () { return RIterator (fNTuple .fAttributeSets .cend ()); }
1248
+ };
1249
+ } // namespace Experimental
1250
+
1148
1251
// clang-format off
1149
1252
/* *
1150
1253
\class ROOT::RNTupleDescriptor::RHeaderExtension
@@ -1218,6 +1321,39 @@ public:
1218
1321
}
1219
1322
};
1220
1323
1324
+ namespace Experimental ::Internal {
1325
+ class RNTupleAttrSetDescriptorBuilder final {
1326
+ ROOT::Experimental::RNTupleAttrSetDescriptor fDesc ;
1327
+
1328
+ public:
1329
+ RNTupleAttrSetDescriptorBuilder &Name (std::string_view name)
1330
+ {
1331
+ fDesc .fName = name;
1332
+ return *this ;
1333
+ }
1334
+ RNTupleAttrSetDescriptorBuilder &SchemaVersion (std::uint16_t major, std::uint16_t minor)
1335
+ {
1336
+ fDesc .fSchemaVersionMajor = major;
1337
+ fDesc .fSchemaVersionMinor = minor;
1338
+ return *this ;
1339
+ }
1340
+ RNTupleAttrSetDescriptorBuilder &AnchorLocator (const RNTupleLocator &loc)
1341
+ {
1342
+ fDesc .fAnchorLocator = loc;
1343
+ return *this ;
1344
+ }
1345
+ RNTupleAttrSetDescriptorBuilder &AnchorLength (std::uint32_t length)
1346
+ {
1347
+ fDesc .fAnchorLength = length;
1348
+ return *this ;
1349
+ }
1350
+
1351
+ // / Attempt to make an AttributeSet descriptor. This may fail if the builder
1352
+ // / was not given enough information to make a proper descriptor.
1353
+ RResult<ROOT::Experimental::RNTupleAttrSetDescriptor> MoveDescriptor ();
1354
+ };
1355
+ } // namespace Experimental::Internal
1356
+
1221
1357
namespace Internal {
1222
1358
1223
1359
// clang-format off
@@ -1601,6 +1737,8 @@ public:
1601
1737
RResult<void > AddExtraTypeInfo (RExtraTypeInfoDescriptor &&extraTypeInfoDesc);
1602
1738
void ReplaceExtraTypeInfo (RExtraTypeInfoDescriptor &&extraTypeInfoDesc);
1603
1739
1740
+ RResult<void > AddAttributeSet (Experimental::RNTupleAttrSetDescriptor &&attrSetDesc);
1741
+
1604
1742
// / Mark the beginning of the header extension; any fields and columns added after a call to this function are
1605
1743
// / annotated as begin part of the header extension.
1606
1744
void BeginHeaderExtension ();
@@ -1634,6 +1772,7 @@ inline RNTupleDescriptor CloneDescriptorSchema(const RNTupleDescriptor &desc)
1634
1772
}
1635
1773
1636
1774
} // namespace Internal
1775
+
1637
1776
} // namespace ROOT
1638
1777
1639
1778
#endif // ROOT_RNTupleDescriptor
0 commit comments