Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RNTupleAttrSetWriter Class Referencefinal

Class used to write an RNTupleAttrSet in the context of an RNTupleWriter.

An Attribute Set is written as a separate RNTuple linked to the "main" RNTuple that created it. A RNTupleAttrSetWriter only lives as long as the RNTupleWriter that created it (or until CloseAttributeSet() is called). Users should not use this class directly but rather via RNTupleAttrSetWriterHandle, which is the type returned by RNTupleWriter::CreateAttributeSet().

// Writing attributes via RNTupleAttrSetWriter
// -------------------------------------------
// First define the schema of your Attribute Set:
auto pMyAttr = attrModel->MakeField<std::string>("myAttr");
// Then, assuming `writer` is an RNTupleWriter, create it:
auto attrSet = writer->CreateAttributeSet(std::move(attrModel), "MyAttrSet");
// Attributes are assigned to entry ranges. A range is started via BeginRange():
auto range = attrSet->BeginRange();
// To assign actual attributes, you use the same interface as the main RNTuple:
*pMyAttr = "This is my attribute for this range";
// ... here you can fill your main RNTuple with data ...
// Once you're done, close the range. This will commit the attribute data and bind it to all data written
// between BeginRange() and CommitRange().
attrSet->CommitRange(std::move(range));
// You don't need to explicitly close the AttributeSet, but if you want to do so, use:
// writer->CloseAttributeSet(std::move(attrSet));
static std::unique_ptr< RNTupleModel > Create()

Definition at line 154 of file RNTupleAttrWriting.hxx.

Public Member Functions

RNTupleAttrPendingRange BeginRange ()
 Begins an attribute range.
 
void CommitRange (RNTupleAttrPendingRange range)
 Ends an attribute range and associates the current values of the fields of the attribute model's default entry with all the main RNTuple entries filled since the BeginRange that created the given range.
 
void CommitRange (RNTupleAttrPendingRange range, REntry &entry)
 Like CommitRange(RNTupleAttrPendingRange range) but uses the given entry rather than the default entry.
 
std::unique_ptr< REntryCreateEntry ()
 Creates an REntry fit to pass to CommitRange(RNTupleAttrPendingRange range, REntry entry).
 
const ROOT::RNTupleDescriptorGetDescriptor () const
 Returns the descriptor of the underlying attribute RNTuple.
 
const ROOT::RNTupleModelGetModel () const
 Returns the user-defined model used to create this attribute set.
 

Private Member Functions

 RNTupleAttrSetWriter (const RNTupleFillContext &mainFillContext, std::unique_ptr< ROOT::Internal::RPageSink > sink, std::unique_ptr< RNTupleModel > metaModel, std::unique_ptr< RNTupleModel > userModel, std::shared_ptr< ROOT::NTupleSize_t > rangeStartPtr, std::shared_ptr< ROOT::NTupleSize_t > rangeLenPtr)
 
ROOT::Internal::RNTupleLink Commit ()
 Commits the attributes written so far to disk and disables writing any new ones.
 

Static Private Member Functions

static std::unique_ptr< RNTupleAttrSetWriterCreate (const RNTupleFillContext &mainFillContext, std::unique_ptr< ROOT::Internal::RPageSink > sink, std::unique_ptr< RNTupleModel > userModel)
 Creates an RNTupleAttrSetWriter associated to the RNTupleWriter owning mainFillContext and writing using sink.
 

Private Attributes

RNTupleFillContext fFillContext
 Our own fill context.
 
const RNTupleFillContextfMainFillContext = nullptr
 Fill context of the main RNTuple being written (i.e. the RNTuple whose attributes we are).
 
std::shared_ptr< ROOT::NTupleSize_tfRangeLenPtr
 
std::shared_ptr< ROOT::NTupleSize_tfRangeStartPtr
 
std::unique_ptr< RNTupleModelfUserModel
 The model that the user provided on creation. Used to create user-visible entries.
 

Friends

class ROOT::RNTupleWriter
 

#include <ROOT/RNTupleAttrWriting.hxx>

Constructor & Destructor Documentation

◆ RNTupleAttrSetWriter()

ROOT::Experimental::RNTupleAttrSetWriter::RNTupleAttrSetWriter ( const RNTupleFillContext & mainFillContext,
std::unique_ptr< ROOT::Internal::RPageSink > sink,
std::unique_ptr< RNTupleModel > metaModel,
std::unique_ptr< RNTupleModel > userModel,
std::shared_ptr< ROOT::NTupleSize_t > rangeStartPtr,
std::shared_ptr< ROOT::NTupleSize_t > rangeLenPtr )
private

Definition at line 92 of file RNTupleAttrWriting.cxx.

Member Function Documentation

◆ BeginRange()

ROOT::Experimental::RNTupleAttrPendingRange ROOT::Experimental::RNTupleAttrSetWriter::BeginRange ( )

Begins an attribute range.

All entries filled in the main RNTupleWriter between BeginRange and CommitRange will be associated with the set of values of the fields of this attribute set at the moment of CommitRange. Note that every attribute range must be explicitly committed for it to be stored on disk.

Returns
An object describing the pending range, which must be passed back to CommitRange to end the attribute range

Definition at line 106 of file RNTupleAttrWriting.cxx.

◆ Commit()

ROOT::Internal::RNTupleLink ROOT::Experimental::RNTupleAttrSetWriter::Commit ( )
private

Commits the attributes written so far to disk and disables writing any new ones.

Definition at line 141 of file RNTupleAttrWriting.cxx.

◆ CommitRange() [1/2]

void ROOT::Experimental::RNTupleAttrSetWriter::CommitRange ( RNTupleAttrPendingRange range)

Ends an attribute range and associates the current values of the fields of the attribute model's default entry with all the main RNTuple entries filled since the BeginRange that created the given range.

This is only valid if the model used to create this attribute set is not bare.

Definition at line 136 of file RNTupleAttrWriting.cxx.

◆ CommitRange() [2/2]

void ROOT::Experimental::RNTupleAttrSetWriter::CommitRange ( RNTupleAttrPendingRange range,
REntry & entry )

Like CommitRange(RNTupleAttrPendingRange range) but uses the given entry rather than the default entry.

The given entry must have been created by CreateEntry().

Definition at line 112 of file RNTupleAttrWriting.cxx.

◆ Create()

std::unique_ptr< ROOT::Experimental::RNTupleAttrSetWriter > ROOT::Experimental::RNTupleAttrSetWriter::Create ( const RNTupleFillContext & mainFillContext,
std::unique_ptr< ROOT::Internal::RPageSink > sink,
std::unique_ptr< RNTupleModel > userModel )
staticprivate

Creates an RNTupleAttrSetWriter associated to the RNTupleWriter owning mainFillContext and writing using sink.

userModel is the schema of the AttributeSet.

Definition at line 57 of file RNTupleAttrWriting.cxx.

◆ CreateEntry()

std::unique_ptr< REntry > ROOT::Experimental::RNTupleAttrSetWriter::CreateEntry ( )
inline

Creates an REntry fit to pass to CommitRange(RNTupleAttrPendingRange range, REntry entry).

Definition at line 204 of file RNTupleAttrWriting.hxx.

◆ GetDescriptor()

const ROOT::RNTupleDescriptor & ROOT::Experimental::RNTupleAttrSetWriter::GetDescriptor ( ) const
inline

Returns the descriptor of the underlying attribute RNTuple.

This is NOT the same descriptor as the main RNTuple being written!

Definition at line 185 of file RNTupleAttrWriting.hxx.

◆ GetModel()

const ROOT::RNTupleModel & ROOT::Experimental::RNTupleAttrSetWriter::GetModel ( ) const
inline

Returns the user-defined model used to create this attribute set.

Definition at line 187 of file RNTupleAttrWriting.hxx.

Friends And Related Symbol Documentation

◆ ROOT::RNTupleWriter

friend class ROOT::RNTupleWriter
friend

Definition at line 155 of file RNTupleAttrWriting.hxx.

Member Data Documentation

◆ fFillContext

RNTupleFillContext ROOT::Experimental::RNTupleAttrSetWriter::fFillContext
private

Our own fill context.

Definition at line 158 of file RNTupleAttrWriting.hxx.

◆ fMainFillContext

const RNTupleFillContext* ROOT::Experimental::RNTupleAttrSetWriter::fMainFillContext = nullptr
private

Fill context of the main RNTuple being written (i.e. the RNTuple whose attributes we are).

Definition at line 160 of file RNTupleAttrWriting.hxx.

◆ fRangeLenPtr

std::shared_ptr<ROOT::NTupleSize_t> ROOT::Experimental::RNTupleAttrSetWriter::fRangeLenPtr
private

Definition at line 166 of file RNTupleAttrWriting.hxx.

◆ fRangeStartPtr

std::shared_ptr<ROOT::NTupleSize_t> ROOT::Experimental::RNTupleAttrSetWriter::fRangeStartPtr
private

Definition at line 165 of file RNTupleAttrWriting.hxx.

◆ fUserModel

std::unique_ptr<RNTupleModel> ROOT::Experimental::RNTupleAttrSetWriter::fUserModel
private

The model that the user provided on creation. Used to create user-visible entries.

Definition at line 162 of file RNTupleAttrWriting.hxx.

Libraries for ROOT::Experimental::RNTupleAttrSetWriter:

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