16#ifndef ROOT7_RField_ProxiedCollection
17#define ROOT7_RField_ProxiedCollection
20#error "Please include RField.hxx!"
34#include <unordered_map>
35#include <unordered_set>
39namespace Experimental {
75 auto fnNext_Contig = [&]() {
78 auto &iter =
reinterpret_cast<unsigned char *&
>(
fIterator),
p = iter;
115 std::size_t stride = 0U)
128 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
141 void operator()(
void *objPtr,
bool dtorOnly)
final;
145 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
160 std::unique_ptr<RFieldBase> itemField);
163 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
171 std::
size_t AppendImpl(const
void *from) override;
184 size_t GetAlignment()
const override {
return alignof(std::max_align_t); }
200template <
typename T,
typename =
void>
205 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
246template <
typename T,
typename =
void>
273 static_assert(std::is_class<T>::value,
"collection proxy unsupported for fundamental types");
290 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
292 std::size_t
AppendImpl(
const void *from)
final;
296 RMapField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
303 size_t GetAlignment()
const override {
return std::alignment_of<std::map<std::max_align_t, std::max_align_t>>(); }
306template <
typename KeyT,
typename ValueT>
307class RField<std::map<KeyT, ValueT>> final :
public RMapField {
308 using ContainerT =
typename std::map<KeyT, ValueT>;
311 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
312 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
321 : RMapField(
name,
TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
328 size_t GetValueSize() const final {
return sizeof(ContainerT); }
329 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
332template <
typename KeyT,
typename ValueT>
333class RField<std::unordered_map<KeyT, ValueT>> final :
public RMapField {
334 using ContainerT =
typename std::unordered_map<KeyT, ValueT>;
337 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
338 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
347 : RMapField(
name,
TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
354 size_t GetValueSize() const final {
return sizeof(ContainerT); }
355 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
358template <
typename KeyT,
typename ValueT>
359class RField<std::multimap<KeyT, ValueT>> final :
public RMapField {
360 using ContainerT =
typename std::multimap<KeyT, ValueT>;
363 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
364 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
373 : RMapField(
name,
TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
380 size_t GetValueSize() const final {
return sizeof(ContainerT); }
381 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
384template <
typename KeyT,
typename ValueT>
385class RField<std::unordered_multimap<KeyT, ValueT>> final :
public RMapField {
386 using ContainerT =
typename std::unordered_multimap<KeyT, ValueT>;
389 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
390 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
399 : RMapField(
name,
TypeName(), std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
406 size_t GetValueSize() const final {
return sizeof(ContainerT); }
407 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
417 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
420 RSetField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
425 size_t GetAlignment()
const override {
return std::alignment_of<std::set<std::max_align_t>>(); }
428template <
typename ItemT>
429class RField<std::set<ItemT>> :
public RSetField {
430 using ContainerT =
typename std::set<ItemT>;
433 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
434 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
444 size_t GetValueSize() const final {
return sizeof(ContainerT); }
445 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
448template <
typename ItemT>
449class RField<std::unordered_set<ItemT>> final :
public RSetField {
450 using ContainerT =
typename std::unordered_set<ItemT>;
453 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
454 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
464 size_t GetValueSize() const final {
return sizeof(ContainerT); }
465 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
468template <
typename ItemT>
469class RField<std::multiset<ItemT>> :
public RSetField {
470 using ContainerT =
typename std::multiset<ItemT>;
473 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
474 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
484 size_t GetValueSize() const final {
return sizeof(ContainerT); }
485 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
488template <
typename ItemT>
489class RField<std::unordered_multiset<ItemT>> :
public RSetField {
490 using ContainerT =
typename std::unordered_multiset<ItemT>;
493 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
494 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
504 size_t GetValueSize() const final {
return sizeof(ContainerT); }
505 size_t GetAlignment() const final {
return std::alignment_of<ContainerT>(); }
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
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
Abstract base class for classes implementing the visitor design pattern.
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.
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< RDeleter > GetDeleter() const final
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Some fields have multiple possible column representations, e.g.
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.
Internal::RColumn * fPrincipalColumn
All fields that have columns have a distinct main column.
Classes with dictionaries that can be inspected by TClass.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
RField & operator=(RField &&other)=default
static std::string TypeName()
~RField() override=default
Template specializations for C++ std::[unordered_][multi]map.
size_t GetAlignment() const override
As a rule of thumb, the alignment is equal to the size of the type.
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
RMapField(RMapField &&other)=default
~RMapField() override=default
RMapField & operator=(RMapField &&other)=default
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
The on-storage meta-data of an ntuple.
pointer operator*() const
bool operator==(const iterator &rh) const
RIterator(const RCollectionIterableOnce &owner)
bool operator!=(const iterator &rh) const
std::forward_iterator_tag iterator_category
const RCollectionIterableOnce & fOwner
RIterator(const RCollectionIterableOnce &owner, void *iter)
std::ptrdiff_t difference_type
Allows for iterating over the elements of a proxied collection.
unsigned char fEndSmallBuf[TVirtualCollectionProxy::fgIteratorArenaSize]
unsigned char fBeginSmallBuf[TVirtualCollectionProxy::fgIteratorArenaSize]
const RIteratorFuncs & fIFuncs
const std::size_t fStride
~RCollectionIterableOnce()
static RIteratorFuncs GetIteratorFuncs(TVirtualCollectionProxy *proxy, bool readFromDisk)
RCollectionIterableOnce(void *collection, const RIteratorFuncs &ifuncs, TVirtualCollectionProxy *proxy, std::size_t stride=0U)
Construct a RCollectionIterableOnce that iterates over collection.
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy, std::unique_ptr< RDeleter > itemDeleter, size_t itemSize)
void operator()(void *objPtr, bool dtorOnly) final
std::shared_ptr< TVirtualCollectionProxy > fProxy
std::unique_ptr< RDeleter > fItemDeleter
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy)
The field for a class representing a collection of elements via TVirtualCollectionProxy.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
void CommitClusterImpl() final
void GetCollectionInfo(RClusterIndex clusterIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
void ConstructValue(void *where) const override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::size_t AppendImpl(const void *from) override
Operations on values of complex types, e.g.
std::shared_ptr< TVirtualCollectionProxy > fProxy
The collection proxy is needed by the deleters and thus defined as a shared pointer.
RCollectionIterableOnce::RIteratorFuncs fIFuncsRead
Two sets of functions to operate on iterators, to be used depending on the access type.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const override
std::unique_ptr< RDeleter > GetDeleter() const override
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
RProxiedCollectionField(RProxiedCollectionField &&other)=default
void GetCollectionInfo(NTupleSize_t globalIndex, RClusterIndex *collectionStart, ClusterSize_t *size) const
~RProxiedCollectionField() override=default
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
std::vector< RValue > SplitValue(const RValue &value) const override
Creates the list of direct child values given a value for this field.
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
size_t GetAlignment() const override
As a rule of thumb, the alignment is equal to the size of the type.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) override
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
RProxiedCollectionField & operator=(RProxiedCollectionField &&other)=default
Template specializations for C++ std::[unordered_][multi]set.
RSetField(RSetField &&other)=default
RSetField & operator=(RSetField &&other)=default
size_t GetAlignment() const override
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
~RSetField() override=default
TClass instances represent classes, structs and namespaces in the ROOT type system.
Defines a common interface to inspect/change the contents of an object that represents a collection.
void(* CreateIterators_t)(void *collection, void **begin_arena, void **end_arena, TVirtualCollectionProxy *proxy)
*begin_arena and *end_arena should contain the location of a memory arena of size fgIteratorArenaSize...
void *(* Next_t)(void *iter, const void *end)
iter and end should be pointers to an iterator to be incremented and an iterator that points to the e...
void(* DeleteTwoIterators_t)(void *begin, void *end)
static const Int_t fgIteratorArenaSize
The size of a small buffer that can be allocated on the stack to store iterator-specific information.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::string GetDemangledTypeName(const std::type_info &t)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Template specializations for classes with collection proxies.
The point here is that we can only tell at run time if a class has an associated collection proxy.
Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t.
TVirtualCollectionProxy::Next_t fNext
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators
TVirtualCollectionProxy::CreateIterators_t fCreateIterators