Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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"}};
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 79 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 ()
 
ROOT::NTupleSize_t GetCurrentEntryNumber () const
 Get the entry number that is currently being processed.
 
std::size_t GetCurrentProcessorNumber () const
 Get the number of the inner processor currently being read.
 
const REntryGetEntry () const
 Returns a reference to the entry used by the processor.
 
const RNTupleModelGetModel () const
 
ROOT::NTupleSize_t GetNEntriesProcessed () const
 Get the total number of entries processed so far.
 
const std::string & GetProcessorName () const
 Get the name of the processor.
 
RNTupleProcessoroperator= (const RNTupleProcessor &)=delete
 
RNTupleProcessoroperator= (RNTupleProcessor &&)=delete
 

Static Public Member Functions

static std::unique_ptr< RNTupleProcessorCreate (const RNTupleOpenSpec &ntuple, std::string_view processorName, std::unique_ptr< RNTupleModel > model=nullptr)
 Create an RNTupleProcessor for a single RNTuple.
 
static std::unique_ptr< RNTupleProcessorCreate (const RNTupleOpenSpec &ntuple, std::unique_ptr< RNTupleModel > model=nullptr)
 Create an RNTupleProcessor for a single RNTuple.
 
static std::unique_ptr< RNTupleProcessorCreateChain (const std::vector< RNTupleOpenSpec > &ntuples, std::string_view processorName, std::unique_ptr< RNTupleModel > model=nullptr)
 Create a new RNTuple processor chain for vertical combinations of RNTuples.
 
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< RNTupleProcessorCreateChain (std::vector< std::unique_ptr< RNTupleProcessor > > innerProcessors, std::string_view processorName, std::unique_ptr< RNTupleModel > model=nullptr)
 Create a new RNTuple processor chain for vertically combining other RNTupleProcessors.
 
static std::unique_ptr< RNTupleProcessorCreateChain (std::vector< std::unique_ptr< RNTupleProcessor > > innerProcessors, std::unique_ptr< RNTupleModel > model=nullptr)
 Create a new RNTuple processor chain for vertical concatenation of previously created processors.
 
static std::unique_ptr< RNTupleProcessorCreateJoin (const std::vector< RNTupleOpenSpec > &ntuples, const std::vector< std::string > &joinFields, std::string_view processorName, std::vector< std::unique_ptr< RNTupleModel > > models={})
 Create a new RNTuple processor for horizontally combined 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 (std::string_view processorName, std::unique_ptr< RNTupleModel > model)
 Create a new base RNTupleProcessor.
 
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 ROOT::NTupleSize_t GetNEntries ()=0
 Get the total number of entries in this processor.
 
virtual ROOT::NTupleSize_t LoadEntry (ROOT::NTupleSize_t entryNumber)=0
 Load the entry identified by the provided entry number.
 
virtual void SetEntryPointers (const REntry &entry)=0
 Points processor entry's field values to those in the provided entry.
 

Protected Attributes

ROOT::NTupleSize_t fCurrentEntryNumber = 0
 
std::size_t fCurrentProcessorNumber = 0
 
std::unique_ptr< REntryfEntry
 
std::unordered_map< std::string, RFieldContextfFieldContexts
 
std::unique_ptr< RNTupleModelfModel
 
ROOT::NTupleSize_t fNEntries = kInvalidNTupleIndex
 Total number of entries.
 
ROOT::NTupleSize_t fNEntriesProcessed = 0
 
std::vector< RNTupleOpenSpecfNTuples
 
std::unique_ptr< Internal::RPageSourcefPageSource
 
std::string fProcessorName
 

Friends

class RNTupleChainProcessor
 
class RNTupleJoinProcessor
 
class RNTupleSingleProcessor
 
struct ROOT::Experimental::Internal::RNTupleProcessorEntryLoader
 

#include <ROOT/RNTupleProcessor.hxx>

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

Constructor & Destructor Documentation

◆ RNTupleProcessor() [1/3]

ROOT::Experimental::RNTupleProcessor::RNTupleProcessor ( std::string_view processorName,
std::unique_ptr< RNTupleModel > model )
inlineprotected

Create a new base RNTupleProcessor.

Parameters
[in]processorNameName of the processor. By default, this is the name of the underlying RNTuple for RNTupleSingleProcessor, the name of the first processor for RNTupleChainProcessor, or the name of the primary RNTuple for RNTupleJoinProcessor.
[in]modelThe RNTupleModel representing the entries returned by the processor.
Note
Before processing, a model must exist. However, this is handled downstream by the RNTupleProcessor's factory functions (CreateSingle, CreateChain and CreateJoin) and constructors.

Definition at line 174 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

◆ begin()

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

Definition at line 271 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 164 of file RNTupleProcessor.cxx.

◆ Create() [1/2]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::Create ( const RNTupleOpenSpec & ntuple,
std::string_view processorName,
std::unique_ptr< RNTupleModel > model = nullptr )
static

Create an RNTupleProcessor for a single RNTuple.

Parameters
[in]ntupleThe name and storage location of the RNTuple to process.
[in]processorNameThe name to give to the processor. Use Create(const RNTupleOpenSpec &, std::unique_ptr<RNTupleModel>) to automatically use the name of the input RNTuple instead.
[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 41 of file RNTupleProcessor.cxx.

◆ Create() [2/2]

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

Create an RNTupleProcessor for a single RNTuple.

Parameters
[in]ntupleThe name and storage location of the RNTuple 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 35 of file RNTupleProcessor.cxx.

◆ CreateChain() [1/4]

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

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

Parameters
[in]ntuplesA list specifying the names and locations of the ntuples to process.
[in]processorNameThe name to give to the processor. Use CreateChain(const RNTupleOpenSpec &, std::unique_ptr<RNTupleModel>) to automatically use the name of the first input RNTuple instead.
[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 58 of file RNTupleProcessor.cxx.

◆ CreateChain() [2/4]

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 48 of file RNTupleProcessor.cxx.

◆ CreateChain() [3/4]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateChain ( std::vector< std::unique_ptr< RNTupleProcessor > > innerProcessors,
std::string_view processorName,
std::unique_ptr< RNTupleModel > model = nullptr )
static

Create a new RNTuple processor chain for vertically combining other RNTupleProcessors.

Parameters
[in]innerProcessorsA list with the processors to chain.
[in]processorNameThe name to give to the processor. Use CreateChain(std::vector<std::unique_ptr<RNTupleProcessor>>, std::unique_ptr<RNTupleModel>) to automatically use the name of the first inner processor instead.
[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 93 of file RNTupleProcessor.cxx.

◆ CreateChain() [4/4]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateChain ( std::vector< std::unique_ptr< RNTupleProcessor > > innerProcessors,
std::unique_ptr< RNTupleModel > model = nullptr )
static

Create a new RNTuple processor chain for vertical concatenation of previously created processors.

Parameters
[in]innerProcessorsA list with the processors to chain.
[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 82 of file RNTupleProcessor.cxx.

◆ CreateJoin() [1/2]

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

Create a new RNTuple processor for horizontally combined 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]processorNameThe name to give to the processor. Use CreateJoin(const std::vector<RNTupleOpenSpec> &, const std::vector<std::string> &, std::unique_ptr<RNTupleModel>) to automatically use the name of the input RNTuple instead.
[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 119 of file RNTupleProcessor.cxx.

◆ CreateJoin() [2/2]

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 109 of file RNTupleProcessor.cxx.

◆ end()

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

Definition at line 272 of file RNTupleProcessor.hxx.

◆ GetCurrentEntryNumber()

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

Get the entry number that is currently being processed.

Definition at line 192 of file RNTupleProcessor.hxx.

◆ GetCurrentProcessorNumber()

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

Get the number of the inner processor currently being read.

This method is only relevant for the RNTupleChainProcessor. For the other processors, 0 is always returned.

Definition at line 198 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 214 of file RNTupleProcessor.hxx.

◆ GetModel()

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

Definition at line 208 of file RNTupleProcessor.hxx.

◆ GetNEntries()

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

◆ GetNEntriesProcessed()

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

Get the total number of entries processed so far.

Definition at line 188 of file RNTupleProcessor.hxx.

◆ GetProcessorName()

const std::string & ROOT::Experimental::RNTupleProcessor::GetProcessorName ( ) const
inline

Get the name of the processor.

Unless this name was explicitly specified during creation of the processor, this is the name of the underlying RNTuple for RNTupleSingleProcessor, the name of the first processor for RNTupleChainProcessor, or the name of the primary RNTuple for RNTupleJoinProcessor.

Definition at line 206 of file RNTupleProcessor.hxx.

◆ LoadEntry()

virtual ROOT::NTupleSize_t ROOT::Experimental::RNTupleProcessor::LoadEntry ( ROOT::NTupleSize_t entryNumber)
protectedpure virtual

Load the entry identified by the provided entry number.

Parameters
[in]entryNumberEntry number to load
Returns
entryNumber if the entry was successfully loaded, kInvalidNTupleIndex otherwise.

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

◆ SetEntryPointers()

virtual void ROOT::Experimental::RNTupleProcessor::SetEntryPointers ( const REntry & entry)
protectedpure virtual

Points processor entry's field values to those in the provided entry.

Parameters
[in]entryThe entry whose field values to use.

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

Friends And Related Symbol Documentation

◆ RNTupleChainProcessor

Definition at line 82 of file RNTupleProcessor.hxx.

◆ RNTupleJoinProcessor

friend class RNTupleJoinProcessor
friend

Definition at line 83 of file RNTupleProcessor.hxx.

◆ RNTupleSingleProcessor

Definition at line 81 of file RNTupleProcessor.hxx.

◆ ROOT::Experimental::Internal::RNTupleProcessorEntryLoader

friend struct ROOT::Experimental::Internal::RNTupleProcessorEntryLoader
friend

Definition at line 80 of file RNTupleProcessor.hxx.

Member Data Documentation

◆ fCurrentEntryNumber

ROOT::NTupleSize_t ROOT::Experimental::RNTupleProcessor::fCurrentEntryNumber = 0
protected

Definition at line 139 of file RNTupleProcessor.hxx.

◆ fCurrentProcessorNumber

std::size_t ROOT::Experimental::RNTupleProcessor::fCurrentProcessorNumber = 0
protected

Definition at line 140 of file RNTupleProcessor.hxx.

◆ fEntry

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

Definition at line 127 of file RNTupleProcessor.hxx.

◆ fFieldContexts

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

Definition at line 130 of file RNTupleProcessor.hxx.

◆ fModel

std::unique_ptr<RNTupleModel> ROOT::Experimental::RNTupleProcessor::fModel
protected

Definition at line 132 of file RNTupleProcessor.hxx.

◆ fNEntries

ROOT::NTupleSize_t ROOT::Experimental::RNTupleProcessor::fNEntries = kInvalidNTupleIndex
protected

Total number of entries.

Only to be used internally by the processor, not meant to be exposed in the public interface.

Definition at line 136 of file RNTupleProcessor.hxx.

◆ fNEntriesProcessed

ROOT::NTupleSize_t ROOT::Experimental::RNTupleProcessor::fNEntriesProcessed = 0
protected

Definition at line 138 of file RNTupleProcessor.hxx.

◆ fNTuples

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

Definition at line 126 of file RNTupleProcessor.hxx.

◆ fPageSource

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

Definition at line 128 of file RNTupleProcessor.hxx.

◆ fProcessorName

std::string ROOT::Experimental::RNTupleProcessor::fProcessorName
protected

Definition at line 125 of file RNTupleProcessor.hxx.

Libraries for ROOT::Experimental::RNTupleProcessor:

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