Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RNTupleProcessor Class Referenceabstract

Interface for iterating over entries of RNTuples and vertically concatenated RNTuples (chains).

Example usage (see ntpl012_processor.C for a full example):

std::vector<RNTupleOpenSpec> ntuples = {{"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}};
auto processor = RNTupleProcessor::CreateChain(ntuples);
for (const auto &entry : processor) {
std::cout << "pt = " << *entry.GetPtr<float>("pt") << std::endl;
}
Interface for iterating over entries of RNTuples and vertically concatenated RNTuples (chains).
static std::unique_ptr< RNTupleProcessor > CreateChain(const std::vector< RNTupleOpenSpec > &ntuples, std::unique_ptr< RNTupleModel > model=nullptr)
Create a new RNTuple processor chain for vertical concatenation of RNTuples.
Used to specify the underlying RNTuples in RNTupleProcessor.

An RNTupleProcessor is created by providing one or more RNTupleOpenSpecs, each of which contains the name and storage location of a single RNTuple. The RNTuples are processed in the order in which they were provided.

The RNTupleProcessor constructor also (optionally) accepts an RNTupleModel, which determines which fields should be read. If no model is provided, a default model based on the descriptor of the first specified RNTuple will be used. If a field that was present in the first RNTuple is not found in a subsequent one, an error will be thrown.

The RNTupleProcessor provides an iterator which gives access to the REntry containing the field data for the current entry. Additional bookkeeping information can be obtained through the RNTupleProcessor itself.

Definition at line 67 of file RNTupleProcessor.hxx.

Classes

class  RFieldContext
 Manager for a field as part of the RNTupleProcessor. More...
 
class  RIterator
 Iterator over the entries of an RNTuple, or vertical concatenation thereof. More...
 

Public Member Functions

 RNTupleProcessor (const RNTupleProcessor &)=delete
 
 RNTupleProcessor (RNTupleProcessor &&)=delete
 
virtual ~RNTupleProcessor ()=default
 
RIterator begin ()
 
RIterator end ()
 
std::size_t GetCurrentNTupleNumber () const
 Get the index to the RNTuple currently being processed, according to the sources specified upon creation.
 
const REntryGetEntry () const
 Returns a reference to the entry used by the processor.
 
NTupleSize_t GetLocalEntryNumber () const
 Get the entry number local to the RNTuple that is currently being processed.
 
NTupleSize_t GetNEntriesProcessed () const
 Get the total number of entries processed so far.
 
RNTupleProcessoroperator= (const RNTupleProcessor &)=delete
 
RNTupleProcessoroperator= (RNTupleProcessor &&)=delete
 

Static Public Member Functions

static std::unique_ptr< RNTupleProcessorCreate (const RNTupleOpenSpec &ntuple)
 
static std::unique_ptr< RNTupleProcessorCreate (const RNTupleOpenSpec &ntuple, RNTupleModel &model)
 
static std::unique_ptr< RNTupleProcessorCreateChain (const std::vector< RNTupleOpenSpec > &ntuples, std::unique_ptr< RNTupleModel > model=nullptr)
 Create a new RNTuple processor chain for vertical concatenation of RNTuples.
 
static std::unique_ptr< RNTupleProcessorCreateJoin (const std::vector< RNTupleOpenSpec > &ntuples, const std::vector< std::string > &joinFields, std::vector< std::unique_ptr< RNTupleModel > > models={})
 Create a new RNTuple processor for horizontallly concatenated RNTuples.
 

Protected Member Functions

 RNTupleProcessor (const std::vector< RNTupleOpenSpec > &ntuples)
 
virtual NTupleSize_t Advance ()=0
 Advance the processor to the next available entry.
 
void ConnectField (RFieldContext &fieldContext, Internal::RPageSource &pageSource, REntry &entry)
 Creates and connects a concrete field to the current page source, based on its proto field.
 
virtual void LoadEntry ()=0
 Fill the entry with values belonging to the current entry number.
 
void SetLocalEntryNumber (NTupleSize_t entryNumber)
 Set the local (i.e.
 

Protected Attributes

std::size_t fCurrentNTupleNumber
 
std::unique_ptr< REntryfEntry
 
std::unordered_map< std::string, RFieldContextfFieldContexts
 
NTupleSize_t fLocalEntryNumber
 
NTupleSize_t fNEntriesProcessed
 
std::vector< RNTupleOpenSpecfNTuples
 
std::unique_ptr< Internal::RPageSourcefPageSource
 

#include <ROOT/RNTupleProcessor.hxx>

Inheritance diagram for ROOT::Experimental::RNTupleProcessor:
[legend]

Constructor & Destructor Documentation

◆ RNTupleProcessor() [1/3]

ROOT::Experimental::RNTupleProcessor::RNTupleProcessor ( const std::vector< RNTupleOpenSpec > &  ntuples)
inlineprotected

Definition at line 143 of file RNTupleProcessor.hxx.

◆ RNTupleProcessor() [2/3]

ROOT::Experimental::RNTupleProcessor::RNTupleProcessor ( const RNTupleProcessor )
delete

◆ RNTupleProcessor() [3/3]

ROOT::Experimental::RNTupleProcessor::RNTupleProcessor ( RNTupleProcessor &&  )
delete

◆ ~RNTupleProcessor()

virtual ROOT::Experimental::RNTupleProcessor::~RNTupleProcessor ( )
virtualdefault

Member Function Documentation

◆ Advance()

virtual NTupleSize_t ROOT::Experimental::RNTupleProcessor::Advance ( )
protectedpure virtual

Advance the processor to the next available entry.

Returns
The number of the entry loaded after advancing, or kInvalidNTupleIndex if there was no entry to advance to.

Checks if the end of the currently connected RNTuple is reached. If this is the case, either the next RNTuple is connected or the iterator has reached the end.

Implemented in ROOT::Experimental::RNTupleSingleProcessor, ROOT::Experimental::RNTupleChainProcessor, and ROOT::Experimental::RNTupleJoinProcessor.

◆ begin()

RIterator ROOT::Experimental::RNTupleProcessor::begin ( )
inline

Definition at line 239 of file RNTupleProcessor.hxx.

◆ ConnectField()

void ROOT::Experimental::RNTupleProcessor::ConnectField ( RFieldContext fieldContext,
Internal::RPageSource pageSource,
REntry entry 
)
protected

Creates and connects a concrete field to the current page source, based on its proto field.

Definition at line 100 of file RNTupleProcessor.cxx.

◆ Create() [1/2]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::Create ( const RNTupleOpenSpec ntuple)
static

Definition at line 35 of file RNTupleProcessor.cxx.

◆ Create() [2/2]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::Create ( const RNTupleOpenSpec ntuple,
RNTupleModel model 
)
static

Definition at line 44 of file RNTupleProcessor.cxx.

◆ CreateChain()

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateChain ( const std::vector< RNTupleOpenSpec > &  ntuples,
std::unique_ptr< RNTupleModel model = nullptr 
)
static

Create a new RNTuple processor chain for vertical concatenation of RNTuples.

Parameters
[in]ntuplesA list specifying the names and locations of the ntuples to process.
[in]modelAn RNTupleModel specifying which fields can be read by the processor. If no model is provided, one will be created based on the descriptor of the first ntuple specified.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 50 of file RNTupleProcessor.cxx.

◆ CreateJoin()

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateJoin ( const std::vector< RNTupleOpenSpec > &  ntuples,
const std::vector< std::string > &  joinFields,
std::vector< std::unique_ptr< RNTupleModel > >  models = {} 
)
static

Create a new RNTuple processor for horizontallly concatenated RNTuples.

Parameters
[in]ntuplesA list specifying the names and locations of the ntuples to process. The first ntuple in the list will be considered the primary ntuple and drives the processor iteration loop. Subsequent ntuples are considered auxiliary, whose entries to be read are determined by the primary ntuple (which does not necessarily have to be sequential).
[in]joinFieldsThe names of the fields on which to join, in case the specified ntuples are unaligned. The join is made based on the combined join field values, and therefore each field has to be present in each specified RNTuple. If an empty list is provided, it is assumed that the specified ntuple are fully aligned, and RNTupleIndex will not be used.
[in]modelsA list of models for the ntuples. This list must either contain a model for each ntuple in ntuples (following the specification order), or be empty. When the list is empty, the default model (i.e. containing all fields) will be used for each ntuple.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 57 of file RNTupleProcessor.cxx.

◆ end()

RIterator ROOT::Experimental::RNTupleProcessor::end ( )
inline

Definition at line 240 of file RNTupleProcessor.hxx.

◆ GetCurrentNTupleNumber()

std::size_t ROOT::Experimental::RNTupleProcessor::GetCurrentNTupleNumber ( ) const
inline

Get the index to the RNTuple currently being processed, according to the sources specified upon creation.

Definition at line 163 of file RNTupleProcessor.hxx.

◆ GetEntry()

const REntry & ROOT::Experimental::RNTupleProcessor::GetEntry ( ) const
inline

Returns a reference to the entry used by the processor.

Returns
A reference to the entry used by the processor.

Definition at line 176 of file RNTupleProcessor.hxx.

◆ GetLocalEntryNumber()

NTupleSize_t ROOT::Experimental::RNTupleProcessor::GetLocalEntryNumber ( ) const
inline

Get the entry number local to the RNTuple that is currently being processed.

When only one RNTuple is present in the processor chain, the return value is equal to GetGlobalEntryNumber.

Definition at line 169 of file RNTupleProcessor.hxx.

◆ GetNEntriesProcessed()

NTupleSize_t ROOT::Experimental::RNTupleProcessor::GetNEntriesProcessed ( ) const
inline

Get the total number of entries processed so far.

When only one RNTuple is present in the processor chain, the return value is equal to GetLocalEntryNumber.

Definition at line 159 of file RNTupleProcessor.hxx.

◆ LoadEntry()

virtual void ROOT::Experimental::RNTupleProcessor::LoadEntry ( )
protectedpure virtual

Fill the entry with values belonging to the current entry number.

Implemented in ROOT::Experimental::RNTupleSingleProcessor, ROOT::Experimental::RNTupleChainProcessor, and ROOT::Experimental::RNTupleJoinProcessor.

◆ operator=() [1/2]

RNTupleProcessor & ROOT::Experimental::RNTupleProcessor::operator= ( const RNTupleProcessor )
delete

◆ operator=() [2/2]

RNTupleProcessor & ROOT::Experimental::RNTupleProcessor::operator= ( RNTupleProcessor &&  )
delete

◆ SetLocalEntryNumber()

void ROOT::Experimental::RNTupleProcessor::SetLocalEntryNumber ( NTupleSize_t  entryNumber)
inlineprotected

Set the local (i.e.

relative to the page source currently openend) entry number. Used by RNTupleProcessor::RIterator.

Parameters
[in]entryNumber

Definition at line 141 of file RNTupleProcessor.hxx.

Member Data Documentation

◆ fCurrentNTupleNumber

std::size_t ROOT::Experimental::RNTupleProcessor::fCurrentNTupleNumber
protected

Definition at line 115 of file RNTupleProcessor.hxx.

◆ fEntry

std::unique_ptr<REntry> ROOT::Experimental::RNTupleProcessor::fEntry
protected

Definition at line 109 of file RNTupleProcessor.hxx.

◆ fFieldContexts

std::unordered_map<std::string, RFieldContext> ROOT::Experimental::RNTupleProcessor::fFieldContexts
protected

Definition at line 112 of file RNTupleProcessor.hxx.

◆ fLocalEntryNumber

NTupleSize_t ROOT::Experimental::RNTupleProcessor::fLocalEntryNumber
protected

Definition at line 116 of file RNTupleProcessor.hxx.

◆ fNEntriesProcessed

NTupleSize_t ROOT::Experimental::RNTupleProcessor::fNEntriesProcessed
protected

Definition at line 114 of file RNTupleProcessor.hxx.

◆ fNTuples

std::vector<RNTupleOpenSpec> ROOT::Experimental::RNTupleProcessor::fNTuples
protected

Definition at line 108 of file RNTupleProcessor.hxx.

◆ fPageSource

std::unique_ptr<Internal::RPageSource> ROOT::Experimental::RNTupleProcessor::fPageSource
protected

Definition at line 110 of file RNTupleProcessor.hxx.

Libraries for ROOT::Experimental::RNTupleProcessor:

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