44namespace Experimental {
46class RCollectionNTuple;
49class RFieldCollection;
87 std::vector<std::unique_ptr<RColumn>>
fColumns;
103 class RIterator :
public std::iterator<std::forward_iterator_tag, Detail::RFieldBase> {
142 static RFieldBase *
Create(
const std::string &fieldName,
const std::string &typeName);
144 static std::string
GetLeafName(
const std::string &fullName);
205 void Attach(std::unique_ptr<Detail::RFieldBase> child);
293template <typename
T, typename=
void>
298 static_assert(std::is_class<T>::value,
"no I/O support for this basic C++ type");
305 template <
typename... ArgsT>
319 static std::string
MyTypeName() {
return ":RFieldCollection:"; }
321 std::shared_ptr<RCollectionNTuple> collectionNTuple,
322 std::unique_ptr<RNTupleModel> collectionModel);
352 static std::string
MyTypeName() {
return "ROOT::Experimental::ClusterSize_t"; }
365 "(ClusterSize_t, EColumnType::kIndex) is not identical on this platform");
370 template <
typename... ArgsT>
375 this,
static_cast<ClusterSize_t*
>(where), std::forward<ArgsT>(args)...);
407 "(float, EColumnType::kReal32) is not identical on this platform");
412 template <
typename... ArgsT>
417 this,
static_cast<float*
>(where), std::forward<ArgsT>(args)...);
444 "(double, EColumnType::kReal64) is not identical on this platform");
449 template <
typename... ArgsT>
454 this,
static_cast<double*
>(where), std::forward<ArgsT>(args)...);
465class RField<std::int32_t> :
public Detail::RFieldBase {
467 static std::string MyTypeName() {
return "std::int32_t"; }
470 RField(RField&& other) =
default;
476 unsigned int GetNColumns() const final {
return 1; }
479 static_assert(Detail::RColumnElement<std::int32_t, EColumnType::kInt32>::kIsMappable,
480 "(std::int32_t, EColumnType::kInt32) is not identical on this platform");
485 template <
typename... ArgsT>
488 return Detail::RFieldValue(
489 Detail::RColumnElement<std::int32_t, EColumnType::kInt32>(
static_cast<std::int32_t*
>(where)),
490 this,
static_cast<std::int32_t*
>(where), std::forward<ArgsT>(args)...);
494 return Detail::RFieldValue(
true ,
495 Detail::RColumnElement<std::int32_t, EColumnType::kInt32>(
static_cast<std::int32_t*
>(where)),
this, where);
497 size_t GetValueSize() const final {
return sizeof(std::int32_t); }
501class RField<std::uint32_t> :
public Detail::RFieldBase {
503 static std::string MyTypeName() {
return "std::uint32_t"; }
506 RField(RField&& other) =
default;
512 unsigned int GetNColumns() const final {
return 1; }
515 static_assert(Detail::RColumnElement<std::uint32_t, EColumnType::kInt32>::kIsMappable,
516 "(std::uint32_t, EColumnType::kInt32) is not identical on this platform");
521 template <
typename... ArgsT>
524 return Detail::RFieldValue(
525 Detail::RColumnElement<std::uint32_t, EColumnType::kInt32>(
static_cast<std::uint32_t*
>(where)),
526 this,
static_cast<std::uint32_t*
>(where), std::forward<ArgsT>(args)...);
530 return Detail::RFieldValue(
true ,
531 Detail::RColumnElement<std::uint32_t, EColumnType::kInt32>(
static_cast<std::uint32_t*
>(where)),
this, where);
533 size_t GetValueSize() const final {
return sizeof(std::uint32_t); }
537class RField<std::uint64_t> :
public Detail::RFieldBase {
539 static std::string MyTypeName() {
return "std::uint64_t"; }
542 RField(RField&& other) =
default;
548 unsigned int GetNColumns() const final {
return 1; }
551 static_assert(Detail::RColumnElement<std::uint64_t, EColumnType::kInt64>::kIsMappable,
552 "(std::uint64_t, EColumnType::kInt64) is not identical on this platform");
557 template <
typename... ArgsT>
560 return Detail::RFieldValue(
561 Detail::RColumnElement<std::uint64_t, EColumnType::kInt64>(
static_cast<std::uint64_t*
>(where)),
562 this,
static_cast<std::uint64_t*
>(where), std::forward<ArgsT>(args)...);
566 return Detail::RFieldValue(
true ,
567 Detail::RColumnElement<std::uint64_t, EColumnType::kInt64>(
static_cast<std::uint64_t*
>(where)),
this, where);
569 size_t GetValueSize() const final {
return sizeof(std::uint64_t); }
574class RField<std::string> :
public Detail::RFieldBase {
577 Detail::RColumnElement<ClusterSize_t, EColumnType::kIndex> fElemIndex;
583 static std::string MyTypeName() {
return "std::string"; }
586 , fIndex(0), fElemIndex(&fIndex) {}
587 RField(RField&& other) =
default;
593 unsigned int GetNColumns() const final {
return 2; }
596 template <
typename... ArgsT>
599 return Detail::RFieldValue(
this,
static_cast<std::string*
>(where), std::forward<ArgsT>(args)...);
602 void DestroyValue(
const Detail::RFieldValue& value,
bool dtorOnly =
false) {
603 auto str = value.Get<std::string>();
604 str->~basic_string();
609 return Detail::RFieldValue(
true ,
this, where);
611 size_t GetValueSize() const final {
return sizeof(std::string); }
616template <typename ItemT>
617class RField<std::vector<ItemT>> : public RFieldVector {
618 using ContainerT =
typename std::vector<ItemT>;
624 RField(RField&& other) =
default;
629 template <
typename... ArgsT>
632 return Detail::RFieldValue(
this,
static_cast<ContainerT*
>(where), std::forward<ArgsT>(args)...);
638 return Detail::RFieldValue(
true ,
this, where);
640 size_t GetValueSize() const final {
return sizeof(ContainerT); }
648template <
typename ItemT>
658 auto count = typedValue->size();
659 for (
unsigned i = 0; i < count; ++i) {
660 auto itemValue =
fSubFields[0]->CaptureValue(&typedValue->data()[i]);
672 typedValue->resize(nItems);
673 for (
unsigned i = 0; i < nItems; ++i) {
674 auto itemValue =
fSubFields[0]->GenerateValue(&typedValue->data()[i]);
675 fSubFields[0]->Read(idxStart + i, &itemValue);
685 Attach(std::move(itemField));
701 fColumns.emplace_back(std::make_unique<Detail::RColumn>(modelIndex));
707 auto nItems = vec->size();
708 for (
unsigned i = 0; i < nItems; ++i) {
709 auto itemValue =
fSubFields[0]->CaptureValue(vec->data() + (i * fItemSize));
710 fSubFields[0]->DestroyValue(itemValue,
true );
721 template <
typename... ArgsT>
Pairs of C++ type and column type, like float and EColumnType::kReal32.
void Append(const RColumnElementBase &element)
CppT * Map(const NTupleSize_t index, RColumnElementBase *element)
Map may fall back to Read() and therefore requires a valid element.
void GetCollectionInfo(const NTupleSize_t index, NTupleSize_t *collectionStart, ClusterSize_t *collectionSize)
For offset columns only, do index arithmetic from cluster-local to global indizes.
void Read(const NTupleSize_t index, RColumnElementBase *element)
Iterates over the sub fields in depth-first search order.
void Advance()
Given that the iterator points to a valid field which is not the end iterator, go to the next field i...
pointer operator->() const
bool operator==(const iterator &rh) const
std::vector< Position > fStack
The stack of nodes visited when walking down the tree of fields.
bool operator!=(const iterator &rh) const
RIterator(pointer val, int idxInParent)
reference operator*() const
static std::string GetCollectionName(const std::string &parentName)
Get the name for an item sub field that is part of a collection, e.g. the float field of std::vector<...
void ReadV(NTupleSize_t index, NTupleSize_t count, void *dst)
Type unsafe bulk read interface; dst must point to a vector of objects of the field type.
void Append(const RFieldValue &value)
Write the given value into columns. The value object has to be of the same type as the field.
virtual RFieldValue CaptureValue(void *where)=0
Creates a value from a memory location with an already constructed object.
virtual void DoReadV(NTupleSize_t index, NTupleSize_t count, void *dst)
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
RFieldBase * fParent
Sub fields point to their mother field.
RFieldBase(std::string_view name, std::string_view type, ENTupleStructure structure, bool isSimple)
The constructor creates the underlying column objects and connects them to either a sink or a source.
std::string GetName() const
virtual void DoAppend(const RFieldValue &value)
Operations on values of complex types, e.g.
virtual void DoGenerateColumns()=0
Creates the backing columns corresponsing to the field type and name.
static constexpr char kCollectionSeparator
Field names convey the level of subfields; sub fields (nested collections) are separated by a dot.
virtual void DestroyValue(const RFieldValue &value, bool dtorOnly=false)
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
virtual RNTupleVersion GetTypeVersion() const
Indicates an evolution of the C++ type itself.
static std::string GetLeafName(const std::string &fullName)
Get the tail of the field name up to the last dot.
void Flush() const
Ensure that all received items are written from page buffers to the storage.
virtual void CommitCluster()
Perform housekeeping tasks for global to cluster-local index translation.
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
std::string GetType() const
RFieldBase(RFieldBase &&)=default
bool fIsSimple
A field on a trivial type that maps as-is to a single column.
std::string fType
The C++ type captured by this field.
void ConnectColumns(Detail::RPageStorage *pageStorage)
Registeres (or re-registers) the backing columns with the physical storage.
std::string fName
The field name is a unique within a tree and also the basis for the column name(s)
virtual RNTupleVersion GetFieldVersion() const
Indicates an evolution of the mapping scheme from C++ type to columns.
virtual void DoRead(NTupleSize_t index, RFieldValue *value)
static RFieldBase * Create(const std::string &fieldName, const std::string &typeName)
Factory method to resurrect a field from the stored on-disk type information.
void Read(NTupleSize_t index, RFieldValue *value)
Populate a single value with data from the tree, which needs to be of the fitting type.
virtual unsigned int GetNColumns() const =0
Returns the number of columns generated to store data for the field; defaults to 1.
RFieldBase(const RFieldBase &)=delete
ENTupleStructure fStructure
The role of this field in the data model structure.
std::vector< std::unique_ptr< RColumn > > fColumns
The columns are connected either to a sink or to a source (not to both); they are owned by the field.
void Attach(std::unique_ptr< Detail::RFieldBase > child)
virtual RFieldValue GenerateValue(void *where)=0
Generates a tree value in a given location of size at least GetValueSize().
NTupleSize_t GetNItems()
The number of elements in the principal column. For top level fields, the number of entries.
RFieldBase & operator=(const RFieldBase &)=delete
ENTupleStructure GetStructure() const
const RFieldBase * GetParent() const
virtual RFieldBase * Clone(std::string_view newName)=0
RFieldValue GenerateValue()
Generates a tree value of the field type and allocates new initialized memory according to the type.
RColumn * fPrincipalColumn
All fields have a main column. For collection fields, the main column is the index field....
RColumnElementBase fMappedElement
For simple types, the mapped element drills through the layers from the C++ data representation to th...
Manages tree meta-data, which is common for sinks and sources.
Holds the static meta-data of a column in a tree.
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
A field translates read and write calls from/to underlying columns to/from tree values.
The field for a class with dictionary.
RFieldClass & operator=(RFieldClass &&other)=default
void DoGenerateColumns() final
Creates the backing columns corresponsing to the field type and name.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
void DoRead(NTupleSize_t index, Detail::RFieldValue *value) final
void DoAppend(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
RFieldClass(std::string_view fieldName, std::string_view className)
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
RFieldBase * Clone(std::string_view newName) final
RFieldClass(RFieldClass &&other)=default
unsigned int GetNColumns() const final
Returns the number of columns generated to store data for the field; defaults to 1.
~RFieldCollection()=default
RFieldCollection(RFieldCollection &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
std::shared_ptr< RCollectionNTuple > fCollectionNTuple
Save the link to the collection ntuple in order to reset the offset counter when committing the clust...
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
static std::string MyTypeName()
The container field for a tree model, which itself has no physical representation.
RFieldBase * Clone(std::string_view newName)
unsigned int GetNColumns() const final
Returns the number of columns generated to store data for the field; defaults to 1.
void DoGenerateColumns() final
Creates the backing columns corresponsing to the field type and name.
REntry * GenerateEntry()
Generates managed values for the top-level sub fields.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
Detail::RFieldValue CaptureValue(void *) final
Creates a value from a memory location with an already constructed object.
Detail::RFieldValue GenerateValue(void *)
Generates a tree value in a given location of size at least GetValueSize().
Represents transient storage of simple or complex C++ values.
The generic field for a (nested) std::vector<Type>
RFieldVector(RFieldVector &&other)=default
RFieldBase * Clone(std::string_view newName) final
static std::string MyTypeName()
RField(std::string_view name)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RField(RField &&other)=default
void DoGenerateColumns() final
Creates the backing columns corresponsing to the field type and name.
void GetCollectionInfo(NTupleSize_t index, NTupleSize_t *idxStart, ClusterSize_t *size)
Special help for offset fields.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
ClusterSize_t * Map(NTupleSize_t index)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
RField(std::string_view name)
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
void DoRead(NTupleSize_t index, Detail::RFieldValue *value) final
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
static std::string MyTypeName()
typename ROOT::VecOps::RVec< ItemT > ContainerT
RField(RField &&other)=default
RField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
void DoAppend(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
void DoGenerateColumns() final
Creates the backing columns corresponsing to the field type and name.
unsigned int GetNColumns() const final
Returns the number of columns generated to store data for the field; defaults to 1.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
RFieldBase * Clone(std::string_view newName) final
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
static std::string MyTypeName()
RField(std::string_view name)
RFieldBase * Clone(std::string_view newName) final
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
double * Map(NTupleSize_t index)
RField(RField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
RField(RField &&other)=default
RField(std::string_view name)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
static std::string MyTypeName()
float * Map(NTupleSize_t index)
RFieldBase * Clone(std::string_view newName) final
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
Classes with dictionaries that can be inspected by TClass.
RField(std::string_view name)
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where, ArgsT &&... args)
RField(RField &&other)=default
ROOT::Experimental::Detail::RFieldValue GenerateValue(void *where) final
Generates a tree value in a given location of size at least GetValueSize().
static std::string MyTypeName()
For forward and backward compatibility, attach version information to the consitituents of the file f...
A "std::vector"-like collection of values implementing handy operation to analyse them.
TClass instances represent classes, structs and namespaces in the ROOT type system.
basic_string_view< char > string_view
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
std::string GetDemangledTypeName(const std::type_info &)
Returns a string with the demangled and normalized name for the given type.
auto Map(Args &&... args) -> decltype(ROOT::Detail::VecOps::MapFromTuple(std::forward_as_tuple(args...), std::make_index_sequence< sizeof...(args) - 1 >()))
Create new collection applying a callable to the elements of the input collection.
Namespace for new ROOT classes and functions.
Position(pointer fieldPtr, int idxInParent)
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...