13#ifndef ROOT_RField_ProxiedCollection
14#define ROOT_RField_ProxiedCollection
17#error "Please include RField.hxx!"
31#include <unordered_map>
32#include <unordered_set>
71 auto fnNext_Contig = [&]() {
74 auto &iter =
reinterpret_cast<unsigned char *&
>(
fIterator), p = iter;
111 std::size_t stride = 0U)
124 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
137 void operator()(
void *objPtr,
bool dtorOnly)
final;
141 std::shared_ptr<TVirtualCollectionProxy>
fProxy;
156 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
164 std::
size_t AppendImpl(const
void *from) final;
179 size_t GetAlignment() const final {
return alignof(std::max_align_t); }
187template <
typename T,
typename =
void>
192 T, typename std::enable_if<std::is_same<typename T::IsCollectionProxy, std::true_type>::value>
::type>
235template <
typename T,
typename =
void>
259 static_assert(std::is_class<T>::value,
"collection proxy unsupported for fundamental types");
284 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
288 RMapField(std::string_view fieldName,
EMapType mapType, std::unique_ptr<RFieldBase> itemField);
294template <
typename KeyT,
typename ValueT>
303 : RMapField(
name, EMapType::kMap, std::make_unique<
RField<std::
pair<KeyT, ValueT>>>(
"_0"))
311template <typename KeyT, typename ValueT>
312class
RField<std::unordered_map<KeyT, ValueT>> final : public RMapField {
328template <typename KeyT, typename ValueT>
329class
RField<std::multimap<KeyT, ValueT>> final : public RMapField {
337 : RMapField(
name, EMapType::
kMultiMap, std::make_unique<
RField<std::pair<KeyT, ValueT>>>(
"_0"))
345template <typename KeyT, typename ValueT>
346class
RField<std::unordered_multimap<KeyT, ValueT>> final : public RMapField {
380 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
384 RSetField(std::string_view fieldName,
ESetType setType, std::unique_ptr<RFieldBase> itemField);
390template <
typename ItemT>
395 explicit RField(std::string_view
name) : RSetField(
name, ESetType::kSet, std::make_unique<RField<ItemT>>(
"_0")) {}
396 RField(RField &&other) =
default;
397 RField &
operator=(RField &&other) =
default;
398 ~RField() final = default;
401template <typename ItemT>
402class RField<std::unordered_set<ItemT>> final : public RSetField {
404 static std::string TypeName() {
return "std::unordered_set<" + RField<ItemT>::TypeName() +
">"; }
406 explicit RField(std::string_view
name)
407 : RSetField(
name, ESetType::
kUnorderedSet, std::make_unique<RField<ItemT>>(
"_0"))
410 RField(RField &&other) =
default;
411 RField &
operator=(RField &&other) =
default;
412 ~RField() final = default;
415template <typename ItemT>
416class RField<std::multiset<ItemT>> final : public RSetField {
418 static std::string TypeName() {
return "std::multiset<" + RField<ItemT>::TypeName() +
">"; }
420 explicit RField(std::string_view
name) : RSetField(
name, ESetType::
kMultiSet, std::make_unique<RField<ItemT>>(
"_0"))
423 RField(RField &&other) =
default;
424 RField &
operator=(RField &&other) =
default;
425 ~RField() final = default;
428template <typename ItemT>
429class RField<std::unordered_multiset<ItemT>> final : public RSetField {
431 static std::string TypeName() {
return "std::unordered_multiset<" + RField<ItemT>::TypeName() +
">"; }
433 explicit RField(std::string_view
name)
437 RField(RField &&other) =
default;
438 RField &
operator=(RField &&other) =
default;
439 ~RField() final = default;
int Int_t
Signed integer 4 bytes (int).
Binding & operator=(OUT(*fun)(void))
Abstract base class for classes implementing the visitor design pattern.
The in-memory representation of a 32bit or 64bit on-disk index column.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
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.
RFieldBase(std::string_view name, std::string_view type, ROOT::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.
Classes with dictionaries that can be inspected by TClass.
RField & operator=(RField &&other)=default
static std::string TypeName()
RField(std::string_view name)
Template specializations for C++ std::[unordered_][multi]map.
RMapField(RMapField &&other)=default
RMapField(std::string_view fieldName, EMapType mapType, std::unique_ptr< RFieldBase > itemField)
~RMapField() override=default
RMapField & operator=(RMapField &&other)=default
The on-storage metadata of an RNTuple.
RIterator(const RCollectionIterableOnce &owner)
bool operator!=(const iterator &rh) const
RIterator(const RCollectionIterableOnce &owner, void *iter)
std::forward_iterator_tag iterator_category
const RCollectionIterableOnce & fOwner
std::ptrdiff_t difference_type
bool operator==(const iterator &rh) const
pointer operator*() const
~RCollectionIterableOnce()
unsigned char fEndSmallBuf[TVirtualCollectionProxy::fgIteratorArenaSize]
const std::size_t fStride
const RIteratorFuncs & fIFuncs
RCollectionIterableOnce(void *collection, const RIteratorFuncs &ifuncs, TVirtualCollectionProxy *proxy, std::size_t stride=0U)
Construct a RCollectionIterableOnce that iterates over collection.
static RIteratorFuncs GetIteratorFuncs(TVirtualCollectionProxy *proxy, bool readFromDisk)
unsigned char fBeginSmallBuf[TVirtualCollectionProxy::fgIteratorArenaSize]
std::shared_ptr< TVirtualCollectionProxy > fProxy
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy, std::unique_ptr< RDeleter > itemDeleter, size_t itemSize)
std::unique_ptr< RDeleter > fItemDeleter
RProxiedCollectionDeleter(std::shared_ptr< TVirtualCollectionProxy > proxy)
void operator()(void *objPtr, bool dtorOnly) final
The field for a class representing a collection of elements via TVirtualCollectionProxy.
RProxiedCollectionField & operator=(RProxiedCollectionField &&other)=default
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
~RProxiedCollectionField() override=default
void CommitClusterImpl() final
RProxiedCollectionField(RProxiedCollectionField &&other)=default
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
RProxiedCollectionField(std::string_view fieldName, TClass *classp)
Constructor used when the value type of the collection is not known in advance, i....
RCollectionIterableOnce::RIteratorFuncs fIFuncsWrite
ROOT::Internal::RColumnIndex fNWritten
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
RCollectionIterableOnce::RIteratorFuncs fIFuncsRead
Two sets of functions to operate on iterators, to be used depending on the access type.
std::shared_ptr< TVirtualCollectionProxy > fProxy
The collection proxy is needed by the deleters and thus defined as a shared pointer.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RDeleter > GetDeleter() const final
void ReconcileOnDiskField(const RNTupleDescriptor &desc) override
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
Template specializations for C++ std::[unordered_][multi]set.
RSetField & operator=(RSetField &&other)=default
~RSetField() override=default
RSetField(RSetField &&other)=default
RSetField(std::string_view fieldName, ESetType setType, std::unique_ptr< RFieldBase > itemField)
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.
Special implementation of ROOT::RRangeCast for TCollection, including a check that the cast target ty...
std::string GetDemangledTypeName(const std::type_info &)
Returns a string with the demangled and normalized name for the given type.
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Template specializations for classes with collection proxies.
Helper type trait for marking classes as a collection proxy.
TVirtualCollectionProxy::Next_t fNext
TVirtualCollectionProxy::CreateIterators_t fCreateIterators
TVirtualCollectionProxy::DeleteTwoIterators_t fDeleteTwoIterators