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