Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
ROOT::RFieldBase Class Referenceabstract

A field translates read and write calls from/to underlying columns to/from tree values.

A field is a serializable C++ type or a container for a collection of sub fields. The RFieldBase and its type-safe descendants provide the object to column mapper. They map C++ objects to primitive columns. The mapping is trivial for simple types such as 'double'. Complex types resolve to multiple primitive columns. The field knows based on its type and the field name the type(s) and name(s) of the columns.

Note: the class hierarchy starting at RFieldBase is not meant to be extended by user-provided child classes. This is and can only be partially enforced through C++.

Definition at line 83 of file RFieldBase.hxx.

Classes

class  RBulk
 Similar to RValue but manages an array of consecutive values. More...
 
struct  RBulkSpec
 
struct  RCheckResult
 Used in the return value of the Check() method. More...
 
class  RColumnRepresentations
 Some fields have multiple possible column representations, e.g. More...
 
struct  RCreateObjectDeleter
 
class  RDeleter
 A functor to release the memory acquired by CreateValue (memory and constructor). More...
 
class  RSchemaIteratorTemplate
 Iterates over the sub tree of fields in depth-first search order. More...
 
struct  RSharedPtrDeleter
 
class  RTypedDeleter
 A deleter for templated RFieldBase descendents where the value type is known. More...
 
class  RValue
 Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field. More...
 

Public Types

enum  {
  kTraitTriviallyConstructible = 0x01 , kTraitTriviallyDestructible = 0x02 , kTraitMappable = 0x04 , kTraitTypeChecksum = 0x08 ,
  kTraitInvalidField = 0x10 , kTraitEmulatedField = 0x20 , kTraitTrivialType = kTraitTriviallyConstructible | kTraitTriviallyDestructible
}
 
using ColumnRepresentation_t = std::vector<ROOT::ENTupleColumnType>
 
enum class  EState { kUnconnected , kConnectedToSink , kConnectedToSource }
 During its lifetime, a field undergoes the following possible state transitions: More...
 
using RConstSchemaIterator = RSchemaIteratorTemplate<true>
 
using RSchemaIterator = RSchemaIteratorTemplate<false>
 

Public Member Functions

 RFieldBase (const RFieldBase &)=delete
 
 RFieldBase (RFieldBase &&)=default
 
 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.
 
virtual ~RFieldBase ()=default
 
virtual void AcceptVisitor (ROOT::Detail::RFieldVisitor &visitor) const
 
RSchemaIterator begin ()
 
RConstSchemaIterator begin () const
 
RValue BindValue (std::shared_ptr< void > objPtr)
 Creates a value from a memory location with an already constructed object.
 
RConstSchemaIterator cbegin () const
 
RConstSchemaIterator cend () const
 
std::unique_ptr< RFieldBaseClone (std::string_view newName) const
 Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns.
 
RBulk CreateBulk ()
 The returned bulk is initially empty; RBulk::ReadBulk will construct the array of values.
 
template<>
std::unique_ptr< void, typename RFieldBase::RCreateObjectDeleter< void >::deleter > CreateObject () const
 
template<typename T >
std::unique_ptr< T, typename RCreateObjectDeleter< T >::deleter > CreateObject () const
 Generates an object of the field type and allocates new initialized memory according to the type.
 
template<>
std::unique_ptr< void, typename ROOT::RFieldBase::RCreateObjectDeleter< void >::deleter > CreateObject () const
 
RValue CreateValue ()
 Generates an object of the field type and wraps the created object in a shared pointer and returns it an RValue connected to the field.
 
RSchemaIterator end ()
 
RConstSchemaIterator end () const
 
virtual size_t GetAlignment () const =0
 As a rule of thumb, the alignment is equal to the size of the type.
 
RColumnRepresentations::Selection_t GetColumnRepresentatives () const
 Returns the fColumnRepresentative pointee or, if unset (always the case for artificial fields), the field's default representative.
 
std::vector< const RFieldBase * > GetConstSubfields () const
 
const std::string & GetDescription () const
 Get the field's description.
 
const std::string & GetFieldName () const
 
virtual std::uint32_t GetFieldVersion () const
 Indicates an evolution of the mapping scheme from C++ type to columns.
 
std::vector< RFieldBase * > GetMutableSubfields ()
 
std::size_t GetNRepetitions () const
 
ROOT::DescriptorId_t GetOnDiskId () const
 
std::uint32_t GetOnDiskTypeChecksum () const
 Return checksum stored in the field descriptor; only valid after a call to ConnectPageSource(), if the field stored a type checksum.
 
std::uint32_t GetOnDiskTypeVersion () const
 Return the C++ type version stored in the field descriptor; only valid after a call to ConnectPageSource()
 
const RFieldBaseGetParent () const
 
std::string GetQualifiedFieldName () const
 Returns the field name and parent field names separated by dots ("grandparent.parent.child")
 
EState GetState () const
 
ROOT::ENTupleStructure GetStructure () const
 
std::uint32_t GetTraits () const
 
const std::string & GetTypeAlias () const
 
virtual std::uint32_t GetTypeChecksum () const
 Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.
 
const std::string & GetTypeName () const
 
virtual std::uint32_t GetTypeVersion () const
 Indicates an evolution of the C++ type itself.
 
virtual size_t GetValueSize () const =0
 The number of bytes taken by a value of the appropriate type.
 
bool HasDefaultColumnRepresentative () const
 Whether or not an explicit column representative was set.
 
bool HasReadCallbacks () const
 
bool IsArtificial () const
 
bool IsSimple () const
 
RFieldBaseoperator= (const RFieldBase &)=delete
 
RFieldBaseoperator= (RFieldBase &&)=default
 
void SetColumnRepresentatives (const RColumnRepresentations::Selection_t &representatives)
 Fixes a column representative.
 
void SetDescription (std::string_view description)
 
void SetOnDiskId (ROOT::DescriptorId_t id)
 
virtual std::vector< RValueSplitValue (const RValue &value) const
 Creates the list of direct child values given a value for this field.
 

Static Public Member Functions

static std::vector< RCheckResultCheck (const std::string &fieldName, const std::string &typeName)
 Checks if the given type is supported by RNTuple.
 
static RResult< std::unique_ptr< RFieldBase > > Create (const std::string &fieldName, const std::string &typeName)
 Factory method to create a field from a certain type given as string.
 

Static Public Attributes

static constexpr std::uint32_t kInvalidTypeVersion = -1U
 

Protected Member Functions

size_t AddReadCallback (ReadCallback_t func)
 Set a user-defined function to be called after reading a value, giving a chance to inspect and/or modify the value object.
 
virtual void AfterConnectPageSource ()
 Called by ConnectPageSource() once connected; derived classes may override this as appropriate.
 
std::size_t Append (const void *from)
 Write the given value into columns.
 
virtual std::size_t AppendImpl (const void *from)
 Operations on values of complex types, e.g.
 
void Attach (std::unique_ptr< RFieldBase > child)
 Add a new subfield to the list of nested fields.
 
void AutoAdjustColumnTypes (const ROOT::RNTupleWriteOptions &options)
 When connecting a field to a page sink, the field's default column representation is subject to adjustment according to the write options.
 
virtual void BeforeConnectPageSource (ROOT::Experimental::Internal::RPageSource &)
 Called by ConnectPageSource() before connecting; derived classes may override this as appropriate.
 
virtual std::unique_ptr< RFieldBaseCloneImpl (std::string_view newName) const =0
 Called by Clone(), which additionally copies the on-disk ID.
 
virtual void CommitClusterImpl ()
 
virtual void ConstructValue (void *where) const =0
 Constructs value in a given location of size at least GetValueSize(). Called by the base class' CreateValue().
 
void * CreateObjectRawPtr () const
 Factory method for the field's type. The caller owns the returned pointer.
 
const ColumnRepresentation_tEnsureCompatibleColumnTypes (const ROOT::RNTupleDescriptor &desc, std::uint16_t representationIndex) const
 Returns the on-disk column types found in the provided descriptor for fOnDiskId and the given representation index.
 
virtual void GenerateColumns ()
 Implementations in derived classes should create the backing columns corresponsing to the field type for writing.
 
virtual void GenerateColumns (const ROOT::RNTupleDescriptor &)
 Implementations in derived classes should create the backing columns corresponsing to the field type for reading.
 
template<typename... ColumnCppTs>
void GenerateColumnsImpl ()
 For writing, use the currently set column representative.
 
template<std::uint32_t ColumnIndexT, typename HeadT , typename... TailTs>
void GenerateColumnsImpl (const ColumnRepresentation_t &representation, std::uint16_t representationIndex)
 Helpers for generating columns.
 
template<typename... ColumnCppTs>
void GenerateColumnsImpl (const ROOT::RNTupleDescriptor &desc)
 For reading, use the on-disk column list.
 
virtual const RColumnRepresentationsGetColumnRepresentations () const
 Implementations in derived classes should return a static RColumnRepresentations object.
 
virtual std::unique_ptr< RDeleterGetDeleter () const
 
virtual ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo () const
 
virtual bool HasExtraTypeInfo () const
 
void Read (RNTupleLocalIndex localIndex, void *to)
 Populate a single value with data from the field.
 
void Read (ROOT::NTupleSize_t globalIndex, void *to)
 Populate a single value with data from the field.
 
std::size_t ReadBulk (const RBulkSpec &bulkSpec)
 Returns the number of newly available values, that is the number of bools in bulkSpec.fMaskAvail that flipped from false to true.
 
virtual std::size_t ReadBulkImpl (const RBulkSpec &bulkSpec)
 General implementation of bulk read.
 
virtual void ReadGlobalImpl (ROOT::NTupleSize_t globalIndex, void *to)
 
virtual void ReadInClusterImpl (RNTupleLocalIndex localIndex, void *to)
 
void RemoveReadCallback (size_t idx)
 

Static Protected Member Functions

static std::size_t CallAppendOn (RFieldBase &other, const void *from)
 Allow derived classes to call Append and Read on other (sub) fields.
 
static void CallConstructValueOn (const RFieldBase &other, void *where)
 Allow derived classes to call ConstructValue(void *) and GetDeleter on other (sub) fields.
 
static void * CallCreateObjectRawPtrOn (RFieldBase &other)
 
static void CallReadOn (RFieldBase &other, RNTupleLocalIndex localIndex, void *to)
 
static void CallReadOn (RFieldBase &other, ROOT::NTupleSize_t globalIndex, void *to)
 
static RResult< std::unique_ptr< RFieldBase > > Create (const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
 Factory method to resurrect a field from the stored on-disk type information.
 
static std::unique_ptr< RDeleterGetDeleterOf (const RFieldBase &other)
 
static ROOT::Internal::RColumnGetPrincipalColumnOf (const RFieldBase &other)
 Fields may need direct access to the principal column of their sub fields, e.g. in RRVecField::ReadBulk.
 

Protected Attributes

ROOT::Internal::RColumnfAuxiliaryColumn = nullptr
 Some fields have a second column in its column representation.
 
std::vector< std::unique_ptr< ROOT::Internal::RColumn > > fAvailableColumns
 The columns are connected either to a sink or to a source (not to both); they are owned by the field.
 
std::vector< std::reference_wrapper< const ColumnRepresentation_t > > fColumnRepresentatives
 Pointers into the static vector GetColumnRepresentations().GetSerializationTypes() when SetColumnRepresentatives is called.
 
std::uint32_t fOnDiskTypeChecksum = 0
 TClass checksum cached from the descriptor after a call to ConnectPageSource().
 
std::uint32_t fOnDiskTypeVersion = kInvalidTypeVersion
 C++ type version cached from the descriptor after a call to ConnectPageSource()
 
RFieldBasefParent
 Sub fields point to their mother field.
 
ROOT::Internal::RColumnfPrincipalColumn = nullptr
 All fields that have columns have a distinct main column.
 
std::vector< ReadCallback_tfReadCallbacks
 List of functions to be called after reading a value.
 
std::vector< std::unique_ptr< RFieldBase > > fSubfields
 Collections and classes own sub fields.
 
std::uint32_t fTraits = 0
 Properties of the type that allow for optimizations of collections of that type.
 
std::string fTypeAlias
 A typedef or using name that was used when creating the field.
 

Private Types

using ReadCallback_t = std::function<void(void *)>
 

Private Member Functions

void CommitCluster ()
 Flushes data from active columns to disk and calls CommitClusterImpl.
 
void ConnectPageSink (ROOT::Experimental::Internal::RPageSink &pageSink, ROOT::NTupleSize_t firstEntry=0)
 Fields and their columns live in the void until connected to a physical page storage.
 
void ConnectPageSource (ROOT::Experimental::Internal::RPageSource &pageSource)
 Connects the field and its sub field tree to the given page source.
 
ROOT::NTupleSize_t EntryToColumnElementIndex (ROOT::NTupleSize_t globalIndex) const
 Translate an entry index to a column element index of the principal column and viceversa.
 
void FlushColumns ()
 Flushes data from active columns.
 
void InvokeReadCallbacks (void *target)
 
void SetArtificial ()
 

Private Attributes

std::string fDescription
 Free text set by the user.
 
bool fIsArtificial = false
 A field that is not backed on disk but computed, e.g.
 
bool fIsSimple
 A field qualifies as simple if it is mappable (which implies it has a single principal column), and it is not an artificial field and has no post-read callback.
 
std::string fName
 The field name relative to its parent field.
 
std::size_t fNRepetitions
 For fixed sized arrays, the array length.
 
ROOT::DescriptorId_t fOnDiskId = ROOT::kInvalidDescriptorId
 When the columns are connected to a page source or page sink, the field represents a field id in the corresponding RNTuple descriptor.
 
EState fState = EState::kUnconnected
 Changed by ConnectTo[Sink,Source], reset by Clone()
 
ROOT::ENTupleStructure fStructure
 The role of this field in the data model structure.
 
std::string fType
 The C++ type captured by this field.
 

Friends

void Internal::CallCommitClusterOnField (RFieldBase &)
 
void Internal::CallConnectPageSinkOnField (RFieldBase &, ROOT::Experimental::Internal::RPageSink &, ROOT::NTupleSize_t)
 
void Internal::CallConnectPageSourceOnField (RFieldBase &, ROOT::Experimental::Internal::RPageSource &)
 
ROOT::RResult< std::unique_ptr< ROOT::RFieldBase > > Internal::CallFieldBaseCreate (const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
 
void Internal::CallFlushColumnsOnField (RFieldBase &)
 
class ROOT::Experimental::RNTupleJoinProcessor
 
struct ROOT::Internal::RFieldCallbackInjector
 
struct ROOT::Internal::RFieldRepresentationModifier
 
class ROOT::RClassField
 

#include <ROOT/RFieldBase.hxx>

Inheritance diagram for ROOT::RFieldBase:
[legend]

Member Typedef Documentation

◆ ColumnRepresentation_t

◆ RConstSchemaIterator

◆ ReadCallback_t

using ROOT::RFieldBase::ReadCallback_t = std::function<void(void *)>
private

Definition at line 98 of file RFieldBase.hxx.

◆ RSchemaIterator

Member Enumeration Documentation

◆ anonymous enum

Enumerator
kTraitTriviallyConstructible 

No constructor needs to be called, i.e.

any bit pattern in the allocated memory represents a valid type A trivially constructible field has a no-op ConstructValue() implementation

kTraitTriviallyDestructible 

The type is cleaned up just by freeing its memory. I.e. the destructor performs a no-op.

kTraitMappable 

A field of a fundamental type that can be directly mapped via RField<T>::Map(), i.e.

maps as-is to a single column

kTraitTypeChecksum 

The TClass checksum is set and valid.

kTraitInvalidField 

This field is an instance of RInvalidField and can be safely static_cast to it.

kTraitEmulatedField 

This field is a user defined type that was missing dictionaries and was reconstructed from the on-disk information.

kTraitTrivialType 

Shorthand for types that are both trivially constructible and destructible.

Definition at line 136 of file RFieldBase.hxx.

◆ EState

During its lifetime, a field undergoes the following possible state transitions:

[*] --> Unconnected --> ConnectedToSink -— | | | | --> ConnectedToSource ---> [*]

| |

Enumerator
kUnconnected 
kConnectedToSink 
kConnectedToSource 

Definition at line 166 of file RFieldBase.hxx.

Constructor & Destructor Documentation

◆ RFieldBase() [1/3]

ROOT::RFieldBase::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.

If isSimple is true, the trait kTraitMappable is automatically set on construction. However, the field might be demoted to non-simple if a post-read callback is set.

Definition at line 238 of file RFieldBase.cxx.

◆ RFieldBase() [2/3]

ROOT::RFieldBase::RFieldBase ( const RFieldBase & )
delete

◆ RFieldBase() [3/3]

ROOT::RFieldBase::RFieldBase ( RFieldBase && )
default

◆ ~RFieldBase()

virtual ROOT::RFieldBase::~RFieldBase ( )
virtualdefault

Member Function Documentation

◆ AcceptVisitor()

◆ AddReadCallback()

size_t ROOT::RFieldBase::AddReadCallback ( ReadCallback_t func)
protected

Set a user-defined function to be called after reading a value, giving a chance to inspect and/or modify the value object.

Returns an index that can be used to remove the callback.

Definition at line 911 of file RFieldBase.cxx.

◆ AfterConnectPageSource()

virtual void ROOT::RFieldBase::AfterConnectPageSource ( )
inlineprotectedvirtual

Called by ConnectPageSource() once connected; derived classes may override this as appropriate.

Reimplemented in ROOT::RField< TObject >.

Definition at line 488 of file RFieldBase.hxx.

◆ Append()

std::size_t ROOT::RFieldBase::Append ( const void * from)
protected

Write the given value into columns.

The value object has to be of the same type as the field. Returns the number of uncompressed bytes written.

Definition at line 780 of file RFieldBase.cxx.

◆ AppendImpl()

std::size_t ROOT::RFieldBase::AppendImpl ( const void * from)
protectedvirtual

Operations on values of complex types, e.g.

ones that involve multiple columns or for which no direct column type exists.

Reimplemented in ROOT::RClassField, ROOT::RStreamerField, ROOT::REnumField, ROOT::RField< TObject >, ROOT::RProxiedCollectionField, ROOT::RRecordField, ROOT::RArrayField, ROOT::RRVecField, ROOT::RVectorField, ROOT::RAtomicField, ROOT::RBitsetField, ROOT::ROptionalField, ROOT::RUniquePtrField, and ROOT::RVariantField.

Definition at line 638 of file RFieldBase.cxx.

◆ Attach()

void ROOT::RFieldBase::Attach ( std::unique_ptr< RFieldBase > child)
protected

Add a new subfield to the list of nested fields.

Definition at line 693 of file RFieldBase.cxx.

◆ AutoAdjustColumnTypes()

void ROOT::RFieldBase::AutoAdjustColumnTypes ( const ROOT::RNTupleWriteOptions & options)
protected

When connecting a field to a page sink, the field's default column representation is subject to adjustment according to the write options.

E.g., if compression is turned off, encoded columns are changed to their unencoded counterparts.

Definition at line 924 of file RFieldBase.cxx.

◆ BeforeConnectPageSource()

virtual void ROOT::RFieldBase::BeforeConnectPageSource ( ROOT::Experimental::Internal::RPageSource & )
inlineprotectedvirtual

Called by ConnectPageSource() before connecting; derived classes may override this as appropriate.

Reimplemented in ROOT::RClassField.

Definition at line 485 of file RFieldBase.hxx.

◆ begin() [1/2]

ROOT::RFieldBase::RSchemaIterator ROOT::RFieldBase::begin ( )

Definition at line 811 of file RFieldBase.cxx.

◆ begin() [2/2]

ROOT::RFieldBase::RConstSchemaIterator ROOT::RFieldBase::begin ( ) const

Definition at line 821 of file RFieldBase.cxx.

◆ BindValue()

ROOT::RFieldBase::RValue ROOT::RFieldBase::BindValue ( std::shared_ptr< void > objPtr)

Creates a value from a memory location with an already constructed object.

Definition at line 794 of file RFieldBase.cxx.

◆ CallAppendOn()

static std::size_t ROOT::RFieldBase::CallAppendOn ( RFieldBase & other,
const void * from )
inlinestaticprotected

Allow derived classes to call Append and Read on other (sub) fields.

Definition at line 456 of file RFieldBase.hxx.

◆ CallConstructValueOn()

static void ROOT::RFieldBase::CallConstructValueOn ( const RFieldBase & other,
void * where )
inlinestaticprotected

Allow derived classes to call ConstructValue(void *) and GetDeleter on other (sub) fields.

Definition at line 396 of file RFieldBase.hxx.

◆ CallCreateObjectRawPtrOn()

static void * ROOT::RFieldBase::CallCreateObjectRawPtrOn ( RFieldBase & other)
inlinestaticprotected

Definition at line 459 of file RFieldBase.hxx.

◆ CallReadOn() [1/2]

static void ROOT::RFieldBase::CallReadOn ( RFieldBase & other,
RNTupleLocalIndex localIndex,
void * to )
inlinestaticprotected

Definition at line 457 of file RFieldBase.hxx.

◆ CallReadOn() [2/2]

static void ROOT::RFieldBase::CallReadOn ( RFieldBase & other,
ROOT::NTupleSize_t globalIndex,
void * to )
inlinestaticprotected

Definition at line 458 of file RFieldBase.hxx.

◆ cbegin()

ROOT::RFieldBase::RConstSchemaIterator ROOT::RFieldBase::cbegin ( ) const

Definition at line 831 of file RFieldBase.cxx.

◆ cend()

ROOT::RFieldBase::RConstSchemaIterator ROOT::RFieldBase::cend ( ) const

Definition at line 836 of file RFieldBase.cxx.

◆ Check()

std::vector< ROOT::RFieldBase::RCheckResult > ROOT::RFieldBase::Check ( const std::string & fieldName,
const std::string & typeName )
static

Checks if the given type is supported by RNTuple.

In case of success, the result vector is empty. Otherwise there is an error record for each failing sub field (sub type).

Definition at line 271 of file RFieldBase.cxx.

◆ Clone()

std::unique_ptr< ROOT::RFieldBase > ROOT::RFieldBase::Clone ( std::string_view newName) const

Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns.

Definition at line 627 of file RFieldBase.cxx.

◆ CloneImpl()

◆ CommitCluster()

void ROOT::RFieldBase::CommitCluster ( )
private

Flushes data from active columns to disk and calls CommitClusterImpl.

Definition at line 749 of file RFieldBase.cxx.

◆ CommitClusterImpl()

virtual void ROOT::RFieldBase::CommitClusterImpl ( )
inlineprotectedvirtual

◆ ConnectPageSink()

void ROOT::RFieldBase::ConnectPageSink ( ROOT::Experimental::Internal::RPageSink & pageSink,
ROOT::NTupleSize_t firstEntry = 0 )
private

Fields and their columns live in the void until connected to a physical page storage.

Only once connected, data can be read or written. In order to find the field in the page storage, the field's on-disk ID has to be set.

Parameters
firstEntryThe global index of the first entry with on-disk data for the connected field

Definition at line 950 of file RFieldBase.cxx.

◆ ConnectPageSource()

void ROOT::RFieldBase::ConnectPageSource ( ROOT::Experimental::Internal::RPageSource & pageSource)
private

Connects the field and its sub field tree to the given page source.

Once connected, data can be read. Only unconnected fields may be connected, i.e. the method is not idempotent. The field ID has to be set prior to calling this function. For sub fields, a field ID may or may not be set. If the field ID is unset, it will be determined using the page source descriptor, based on the parent field ID and the sub field name.

Definition at line 976 of file RFieldBase.cxx.

◆ ConstructValue()

◆ Create() [1/2]

ROOT::RResult< std::unique_ptr< ROOT::RFieldBase > > ROOT::RFieldBase::Create ( const std::string & fieldName,
const std::string & typeName )
static

Factory method to create a field from a certain type given as string.

Note that the provided type name must be a valid C++ type name. Template arguments of templated types must be type names or integers (e.g., no expressions).

Definition at line 264 of file RFieldBase.cxx.

◆ Create() [2/2]

ROOT::RResult< std::unique_ptr< ROOT::RFieldBase > > ROOT::RFieldBase::Create ( const std::string & fieldName,
const std::string & typeName,
const ROOT::RCreateFieldOptions & options,
const ROOT::RNTupleDescriptor * desc,
ROOT::DescriptorId_t fieldId )
staticprotected

Factory method to resurrect a field from the stored on-disk type information.

This overload takes an already normalized type name and type alias. desc and fieldId must be passed if options.fEmulateUnknownTypes is true, otherwise they can be left blank.

Definition at line 293 of file RFieldBase.cxx.

◆ CreateBulk()

ROOT::RFieldBase::RBulk ROOT::RFieldBase::CreateBulk ( )

The returned bulk is initially empty; RBulk::ReadBulk will construct the array of values.

Definition at line 789 of file RFieldBase.cxx.

◆ CreateObject() [1/3]

template<>
std::unique_ptr< void, typename RFieldBase::RCreateObjectDeleter< void >::deleter > ROOT::RFieldBase::CreateObject ( ) const

◆ CreateObject() [2/3]

template<typename T >
std::unique_ptr< T, typename RFieldBase::RCreateObjectDeleter< T >::deleter > ROOT::RFieldBase::CreateObject ( ) const

Generates an object of the field type and allocates new initialized memory according to the type.

Implemented at the end of this header because the implementation is using RField<T>::TypeName() The returned object can be released with delete, i.e. it is valid to call auto ptr = field->CreateObject(); delete ptr.release();

Note that CreateObject<void> is supported. The returned unique_ptr has a custom deleter that reports an error if it is called. The intended use of the returned unique_ptr<void> is to call release(). In this way, the transfer of pointer ownership is explicit.

Definition at line 506 of file RField.hxx.

◆ CreateObject() [3/3]

template<>
std::unique_ptr< void, typename ROOT::RFieldBase::RCreateObjectDeleter< void >::deleter > ROOT::RFieldBase::CreateObject ( ) const

Definition at line 223 of file RFieldBase.cxx.

◆ CreateObjectRawPtr()

void * ROOT::RFieldBase::CreateObjectRawPtr ( ) const
protected

Factory method for the field's type. The caller owns the returned pointer.

Definition at line 674 of file RFieldBase.cxx.

◆ CreateValue()

ROOT::RFieldBase::RValue ROOT::RFieldBase::CreateValue ( )

Generates an object of the field type and wraps the created object in a shared pointer and returns it an RValue connected to the field.

Definition at line 682 of file RFieldBase.cxx.

◆ end() [1/2]

ROOT::RFieldBase::RSchemaIterator ROOT::RFieldBase::end ( )

Definition at line 816 of file RFieldBase.cxx.

◆ end() [2/2]

ROOT::RFieldBase::RConstSchemaIterator ROOT::RFieldBase::end ( ) const

Definition at line 826 of file RFieldBase.cxx.

◆ EnsureCompatibleColumnTypes()

const ROOT::RFieldBase::ColumnRepresentation_t & ROOT::RFieldBase::EnsureCompatibleColumnTypes ( const ROOT::RNTupleDescriptor & desc,
std::uint16_t representationIndex ) const
protected

Returns the on-disk column types found in the provided descriptor for fOnDiskId and the given representation index.

If there are no columns for the given representation index, return an empty ColumnRepresentation_t list. Otherwise, the returned reference points into the static array returned by GetColumnRepresentations(). Throws an exception if the types on disk don't match any of the deserialization types from GetColumnRepresentations().

Definition at line 875 of file RFieldBase.cxx.

◆ EntryToColumnElementIndex()

ROOT::NTupleSize_t ROOT::RFieldBase::EntryToColumnElementIndex ( ROOT::NTupleSize_t globalIndex) const
private

Translate an entry index to a column element index of the principal column and viceversa.

These functions take into account the role and number of repetitions on each level of the field hierarchy as follows:

  • Top level fields: element index == entry index
  • Record fields propagate their principal column index to the principal columns of direct descendant fields
  • Collection and variant fields set the principal column index of their childs to 0

The column element index also depends on the number of repetitions of each field in the hierarchy, e.g., given a field with type std::array<std::array<float, 4>, 2>, this function returns 8 for the inner-most field.

Definition at line 703 of file RFieldBase.cxx.

◆ FlushColumns()

void ROOT::RFieldBase::FlushColumns ( )
private

Flushes data from active columns.

Definition at line 737 of file RFieldBase.cxx.

◆ GenerateColumns() [1/2]

◆ GenerateColumns() [2/2]

virtual void ROOT::RFieldBase::GenerateColumns ( const ROOT::RNTupleDescriptor & )
inlineprotectedvirtual

Implementations in derived classes should create the backing columns corresponsing to the field type for reading.

The default implementation does not attach any columns to the field. The method should check, using the page source and fOnDiskId, if the column types match and throw if they don't.

Reimplemented in ROOT::RArrayAsRVecField, ROOT::Experimental::Internal::RArraySizeField, ROOT::RStreamerField, ROOT::RCardinalityField, ROOT::RNullableField, ROOT::Experimental::Internal::RRDFCardinalityField, ROOT::RRealField< T >, ROOT::RRealField< double >, ROOT::RRealField< float >, ROOT::RProxiedCollectionField, ROOT::RRVecField, ROOT::RVectorField, ROOT::RBitsetField, ROOT::RVariantField, ROOT::RSimpleField< T >, ROOT::RSimpleField< bool >, ROOT::RSimpleField< char >, ROOT::RSimpleField< double >, and ROOT::RSimpleField< float >.

Definition at line 375 of file RFieldBase.hxx.

◆ GenerateColumnsImpl() [1/3]

template<typename... ColumnCppTs>
void ROOT::RFieldBase::GenerateColumnsImpl ( )
inlineprotected

For writing, use the currently set column representative.

Definition at line 331 of file RFieldBase.hxx.

◆ GenerateColumnsImpl() [2/3]

template<std::uint32_t ColumnIndexT, typename HeadT , typename... TailTs>
void ROOT::RFieldBase::GenerateColumnsImpl ( const ColumnRepresentation_t & representation,
std::uint16_t representationIndex )
inlineprotected

Helpers for generating columns.

We use the fact that most fields have the same C++/memory types for all their column representations. Where possible, we call the helpers not from the header to reduce compilation time.

Definition at line 309 of file RFieldBase.hxx.

◆ GenerateColumnsImpl() [3/3]

template<typename... ColumnCppTs>
void ROOT::RFieldBase::GenerateColumnsImpl ( const ROOT::RNTupleDescriptor & desc)
inlineprotected

For reading, use the on-disk column list.

Definition at line 347 of file RFieldBase.hxx.

◆ GetAlignment()

◆ GetColumnRepresentations()

const ROOT::RFieldBase::RColumnRepresentations & ROOT::RFieldBase::GetColumnRepresentations ( ) const
protectedvirtual

◆ GetColumnRepresentatives()

ROOT::RFieldBase::RColumnRepresentations::Selection_t ROOT::RFieldBase::GetColumnRepresentatives ( ) const

Returns the fColumnRepresentative pointee or, if unset (always the case for artificial fields), the field's default representative.

Definition at line 841 of file RFieldBase.cxx.

◆ GetConstSubfields()

std::vector< const ROOT::RFieldBase * > ROOT::RFieldBase::GetConstSubfields ( ) const

Definition at line 727 of file RFieldBase.cxx.

◆ GetDeleter()

◆ GetDeleterOf()

static std::unique_ptr< RDeleter > ROOT::RFieldBase::GetDeleterOf ( const RFieldBase & other)
inlinestaticprotected

Definition at line 397 of file RFieldBase.hxx.

◆ GetDescription()

const std::string & ROOT::RFieldBase::GetDescription ( ) const
inline

Get the field's description.

Definition at line 583 of file RFieldBase.hxx.

◆ GetExtraTypeInfo()

virtual ROOT::RExtraTypeInfoDescriptor ROOT::RFieldBase::GetExtraTypeInfo ( ) const
inlineprotectedvirtual

Reimplemented in ROOT::RStreamerField.

Definition at line 479 of file RFieldBase.hxx.

◆ GetFieldName()

const std::string & ROOT::RFieldBase::GetFieldName ( ) const
inline

Definition at line 570 of file RFieldBase.hxx.

◆ GetFieldVersion()

virtual std::uint32_t ROOT::RFieldBase::GetFieldVersion ( ) const
inlinevirtual

Indicates an evolution of the mapping scheme from C++ type to columns.

Definition at line 601 of file RFieldBase.hxx.

◆ GetMutableSubfields()

std::vector< ROOT::RFieldBase * > ROOT::RFieldBase::GetMutableSubfields ( )

Definition at line 717 of file RFieldBase.cxx.

◆ GetNRepetitions()

std::size_t ROOT::RFieldBase::GetNRepetitions ( ) const
inline

Definition at line 576 of file RFieldBase.hxx.

◆ GetOnDiskId()

ROOT::DescriptorId_t ROOT::RFieldBase::GetOnDiskId ( ) const
inline

Definition at line 587 of file RFieldBase.hxx.

◆ GetOnDiskTypeChecksum()

std::uint32_t ROOT::RFieldBase::GetOnDiskTypeChecksum ( ) const
inline

Return checksum stored in the field descriptor; only valid after a call to ConnectPageSource(), if the field stored a type checksum.

Definition at line 610 of file RFieldBase.hxx.

◆ GetOnDiskTypeVersion()

std::uint32_t ROOT::RFieldBase::GetOnDiskTypeVersion ( ) const
inline

Return the C++ type version stored in the field descriptor; only valid after a call to ConnectPageSource()

Definition at line 607 of file RFieldBase.hxx.

◆ GetParent()

const RFieldBase * ROOT::RFieldBase::GetParent ( ) const
inline

Definition at line 577 of file RFieldBase.hxx.

◆ GetPrincipalColumnOf()

static ROOT::Internal::RColumn * ROOT::RFieldBase::GetPrincipalColumnOf ( const RFieldBase & other)
inlinestaticprotected

Fields may need direct access to the principal column of their sub fields, e.g. in RRVecField::ReadBulk.

Definition at line 462 of file RFieldBase.hxx.

◆ GetQualifiedFieldName()

std::string ROOT::RFieldBase::GetQualifiedFieldName ( ) const

Returns the field name and parent field names separated by dots ("grandparent.parent.child")

Definition at line 252 of file RFieldBase.cxx.

◆ GetState()

EState ROOT::RFieldBase::GetState ( ) const
inline

Definition at line 585 of file RFieldBase.hxx.

◆ GetStructure()

ROOT::ENTupleStructure ROOT::RFieldBase::GetStructure ( ) const
inline

Definition at line 575 of file RFieldBase.hxx.

◆ GetTraits()

std::uint32_t ROOT::RFieldBase::GetTraits ( ) const
inline

Definition at line 567 of file RFieldBase.hxx.

◆ GetTypeAlias()

const std::string & ROOT::RFieldBase::GetTypeAlias ( ) const
inline

Definition at line 574 of file RFieldBase.hxx.

◆ GetTypeChecksum()

virtual std::uint32_t ROOT::RFieldBase::GetTypeChecksum ( ) const
inlinevirtual

Return the current TClass reported checksum of this class. Only valid if kTraitTypeChecksum is set.

Reimplemented in ROOT::RClassField, ROOT::RStreamerField, and ROOT::RField< TObject >.

Definition at line 605 of file RFieldBase.hxx.

◆ GetTypeName()

const std::string & ROOT::RFieldBase::GetTypeName ( ) const
inline

Definition at line 573 of file RFieldBase.hxx.

◆ GetTypeVersion()

virtual std::uint32_t ROOT::RFieldBase::GetTypeVersion ( ) const
inlinevirtual

Indicates an evolution of the C++ type itself.

Reimplemented in ROOT::RClassField, ROOT::RStreamerField, and ROOT::RField< TObject >.

Definition at line 603 of file RFieldBase.hxx.

◆ GetValueSize()

◆ HasDefaultColumnRepresentative()

bool ROOT::RFieldBase::HasDefaultColumnRepresentative ( ) const
inline

Whether or not an explicit column representative was set.

Definition at line 598 of file RFieldBase.hxx.

◆ HasExtraTypeInfo()

virtual bool ROOT::RFieldBase::HasExtraTypeInfo ( ) const
inlineprotectedvirtual

Reimplemented in ROOT::RStreamerField.

Definition at line 475 of file RFieldBase.hxx.

◆ HasReadCallbacks()

bool ROOT::RFieldBase::HasReadCallbacks ( ) const
inline

Definition at line 568 of file RFieldBase.hxx.

◆ InvokeReadCallbacks()

void ROOT::RFieldBase::InvokeReadCallbacks ( void * target)
inlineprivate

Definition at line 226 of file RFieldBase.hxx.

◆ IsArtificial()

bool ROOT::RFieldBase::IsArtificial ( ) const
inline

Definition at line 581 of file RFieldBase.hxx.

◆ IsSimple()

bool ROOT::RFieldBase::IsSimple ( ) const
inline

Definition at line 580 of file RFieldBase.hxx.

◆ operator=() [1/2]

RFieldBase & ROOT::RFieldBase::operator= ( const RFieldBase & )
delete

◆ operator=() [2/2]

RFieldBase & ROOT::RFieldBase::operator= ( RFieldBase && )
default

◆ Read() [1/2]

void ROOT::RFieldBase::Read ( RNTupleLocalIndex localIndex,
void * to )
inlineprotected

Populate a single value with data from the field.

The memory location pointed to by to needs to be of the fitting type. The fast path is conditioned by the field qualifying as simple, i.e. maps as-is to a single column and has no read callback.

Definition at line 430 of file RFieldBase.hxx.

◆ Read() [2/2]

void ROOT::RFieldBase::Read ( ROOT::NTupleSize_t globalIndex,
void * to )
inlineprotected

Populate a single value with data from the field.

The memory location pointed to by to needs to be of the fitting type. The fast path is conditioned by the field qualifying as simple, i.e. maps as-is to a single column and has no read callback.

Definition at line 412 of file RFieldBase.hxx.

◆ ReadBulk()

std::size_t ROOT::RFieldBase::ReadBulk ( const RBulkSpec & bulkSpec)
protected

Returns the number of newly available values, that is the number of bools in bulkSpec.fMaskAvail that flipped from false to true.

As a special return value, kAllSet can be used if all values are read independent from the masks.

Definition at line 799 of file RFieldBase.cxx.

◆ ReadBulkImpl()

std::size_t ROOT::RFieldBase::ReadBulkImpl ( const RBulkSpec & bulkSpec)
protectedvirtual

General implementation of bulk read.

Loop over the required range and read values that are required and not already present. Derived classes may implement more optimized versions of this method. See ReadBulk() for the return value.

Reimplemented in ROOT::RField< RNTupleCardinality< SizeT > >, and ROOT::RRVecField.

Definition at line 654 of file RFieldBase.cxx.

◆ ReadGlobalImpl()

◆ ReadInClusterImpl()

◆ RemoveReadCallback()

void ROOT::RFieldBase::RemoveReadCallback ( size_t idx)
protected

Definition at line 918 of file RFieldBase.cxx.

◆ SetArtificial()

void ROOT::RFieldBase::SetArtificial ( )
inlineprivate

Definition at line 256 of file RFieldBase.hxx.

◆ SetColumnRepresentatives()

void ROOT::RFieldBase::SetColumnRepresentatives ( const RColumnRepresentations::Selection_t & representatives)

Fixes a column representative.

This can only be done before connecting the field to a page sink. Otherwise, or if the provided representation is not in the list of GetColumnRepresentations, an exception is thrown

Definition at line 855 of file RFieldBase.cxx.

◆ SetDescription()

void ROOT::RFieldBase::SetDescription ( std::string_view description)

Definition at line 764 of file RFieldBase.cxx.

◆ SetOnDiskId()

void ROOT::RFieldBase::SetOnDiskId ( ROOT::DescriptorId_t id)

Definition at line 771 of file RFieldBase.cxx.

◆ SplitValue()

std::vector< ROOT::RFieldBase::RValue > ROOT::RFieldBase::SplitValue ( const RValue & value) const
virtual

Creates the list of direct child values given a value for this field.

E.g. a single value for the correct variant or all the elements of a collection. The default implementation assumes no sub values and returns an empty vector.

Reimplemented in ROOT::RArrayAsRVecField, ROOT::RClassField, ROOT::REnumField, ROOT::RField< TObject >, ROOT::RProxiedCollectionField, ROOT::RRecordField, ROOT::RArrayField, ROOT::RRVecField, ROOT::RVectorField, ROOT::RAtomicField, ROOT::ROptionalField, and ROOT::RUniquePtrField.

Definition at line 688 of file RFieldBase.cxx.

Friends And Related Symbol Documentation

◆ Internal::CallCommitClusterOnField

◆ Internal::CallConnectPageSinkOnField

◆ Internal::CallConnectPageSourceOnField

◆ Internal::CallFieldBaseCreate

ROOT::RResult< std::unique_ptr< ROOT::RFieldBase > > Internal::CallFieldBaseCreate ( const std::string & fieldName,
const std::string & typeName,
const ROOT::RCreateFieldOptions & options,
const ROOT::RNTupleDescriptor * desc,
ROOT::DescriptorId_t fieldId )
friend

◆ Internal::CallFlushColumnsOnField

◆ ROOT::Experimental::RNTupleJoinProcessor

Definition at line 85 of file RFieldBase.hxx.

◆ ROOT::Internal::RFieldCallbackInjector

friend struct ROOT::Internal::RFieldCallbackInjector
friend

Definition at line 86 of file RFieldBase.hxx.

◆ ROOT::Internal::RFieldRepresentationModifier

Definition at line 87 of file RFieldBase.hxx.

◆ ROOT::RClassField

friend class ROOT::RClassField
friend

Definition at line 84 of file RFieldBase.hxx.

Member Data Documentation

◆ fAuxiliaryColumn

ROOT::Internal::RColumn* ROOT::RFieldBase::fAuxiliaryColumn = nullptr
protected

Some fields have a second column in its column representation.

In this case, fAuxiliaryColumn points into fAvailableColumns to the column that immediately follows the column fPrincipalColumn points to.

Definition at line 282 of file RFieldBase.hxx.

◆ fAvailableColumns

std::vector<std::unique_ptr<ROOT::Internal::RColumn> > ROOT::RFieldBase::fAvailableColumns
protected

The columns are connected either to a sink or to a source (not to both); they are owned by the field.

Contains all columns of all representations in order of representation and column index.

Definition at line 285 of file RFieldBase.hxx.

◆ fColumnRepresentatives

std::vector<std::reference_wrapper<const ColumnRepresentation_t> > ROOT::RFieldBase::fColumnRepresentatives
protected

Pointers into the static vector GetColumnRepresentations().GetSerializationTypes() when SetColumnRepresentatives is called.

Otherwise (if empty) GetColumnRepresentatives() returns a vector with a single element, the default representation. Always empty for artificial fields.

Definition at line 300 of file RFieldBase.hxx.

◆ fDescription

std::string ROOT::RFieldBase::fDescription
private

Free text set by the user.

Definition at line 222 of file RFieldBase.hxx.

◆ fIsArtificial

bool ROOT::RFieldBase::fIsArtificial = false
private

A field that is not backed on disk but computed, e.g.

a default-constructed missing field or a field whose data is created by I/O customization rules. Subfields of artificial fields are artificial, too.

Definition at line 216 of file RFieldBase.hxx.

◆ fIsSimple

bool ROOT::RFieldBase::fIsSimple
private

A field qualifies as simple if it is mappable (which implies it has a single principal column), and it is not an artificial field and has no post-read callback.

Definition at line 212 of file RFieldBase.hxx.

◆ fName

std::string ROOT::RFieldBase::fName
private

The field name relative to its parent field.

Definition at line 203 of file RFieldBase.hxx.

◆ fNRepetitions

std::size_t ROOT::RFieldBase::fNRepetitions
private

For fixed sized arrays, the array length.

Definition at line 209 of file RFieldBase.hxx.

◆ fOnDiskId

ROOT::DescriptorId_t ROOT::RFieldBase::fOnDiskId = ROOT::kInvalidDescriptorId
private

When the columns are connected to a page source or page sink, the field represents a field id in the corresponding RNTuple descriptor.

This on-disk ID is set in RPageSink::Create() for writing and by RFieldDescriptor::CreateField() when recreating a field / model from the stored descriptor.

Definition at line 220 of file RFieldBase.hxx.

◆ fOnDiskTypeChecksum

std::uint32_t ROOT::RFieldBase::fOnDiskTypeChecksum = 0
protected

TClass checksum cached from the descriptor after a call to ConnectPageSource().

Only set for classes with dictionaries.

Definition at line 296 of file RFieldBase.hxx.

◆ fOnDiskTypeVersion

std::uint32_t ROOT::RFieldBase::fOnDiskTypeVersion = kInvalidTypeVersion
protected

C++ type version cached from the descriptor after a call to ConnectPageSource()

Definition at line 293 of file RFieldBase.hxx.

◆ fParent

RFieldBase* ROOT::RFieldBase::fParent
protected

Sub fields point to their mother field.

Definition at line 272 of file RFieldBase.hxx.

◆ fPrincipalColumn

ROOT::Internal::RColumn* ROOT::RFieldBase::fPrincipalColumn = nullptr
protected

All fields that have columns have a distinct main column.

E.g., for simple fields (float, int, ...), the principal column corresponds to the field type. For collection fields except fixed-sized arrays, the main column is the offset field. Class fields have no column of their own. When reading, points to any column of the column team of the active representation. Usually, this is just the first column. When writing, points to the first column index of the currently active (not suppressed) column representation.

Definition at line 279 of file RFieldBase.hxx.

◆ fReadCallbacks

std::vector<ReadCallback_t> ROOT::RFieldBase::fReadCallbacks
protected

List of functions to be called after reading a value.

Definition at line 291 of file RFieldBase.hxx.

◆ fState

EState ROOT::RFieldBase::fState = EState::kUnconnected
private

Changed by ConnectTo[Sink,Source], reset by Clone()

Definition at line 224 of file RFieldBase.hxx.

◆ fStructure

ROOT::ENTupleStructure ROOT::RFieldBase::fStructure
private

The role of this field in the data model structure.

Definition at line 207 of file RFieldBase.hxx.

◆ fSubfields

std::vector<std::unique_ptr<RFieldBase> > ROOT::RFieldBase::fSubfields
protected

Collections and classes own sub fields.

Definition at line 270 of file RFieldBase.hxx.

◆ fTraits

std::uint32_t ROOT::RFieldBase::fTraits = 0
protected

Properties of the type that allow for optimizations of collections of that type.

Definition at line 287 of file RFieldBase.hxx.

◆ fType

std::string ROOT::RFieldBase::fType
private

The C++ type captured by this field.

Definition at line 205 of file RFieldBase.hxx.

◆ fTypeAlias

std::string ROOT::RFieldBase::fTypeAlias
protected

A typedef or using name that was used when creating the field.

Definition at line 289 of file RFieldBase.hxx.

◆ kInvalidTypeVersion

constexpr std::uint32_t ROOT::RFieldBase::kInvalidTypeVersion = -1U
staticconstexpr

Definition at line 135 of file RFieldBase.hxx.

Libraries for ROOT::RFieldBase:

The documentation for this class was generated from the following files: