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

Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combined RNTuples.

Example usage (see ntpl012_processor_chain.C and ntpl015_processor_join.C for bigger examples):

std::vector<RNTupleOpenSpec> ntuples = {{"ntuple1", "ntuple1.root"}, {"ntuple2", "ntuple2.root"}};
auto pt = processor->RequestField<float>("pt");
for (const auto idx : *processor) {
std::cout << "event = " << idx << ", pt = " << *pt << std::endl;
}
Specification of the name and location of an RNTuple, used for creating a new RNTupleProcessor.
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
static std::unique_ptr< RNTupleProcessor > CreateChain(std::vector< RNTupleOpenSpec > ntuples, std::string_view processorName="")
Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.
TPaveText * pt

An RNTupleProcessor is created either:

  1. By providing one or more RNTupleOpenSpecs, each of which contains the name and storage location of a single RNTuple;
  2. By providing a previously created RNTupleProcessor.

The RNTupleProcessor provides an iterator which gives access to the index of the current global entry of the processor, i.e. taking into account previously processed RNTuples.

Because the schemas of each RNTuple that are part of an RNTupleProcessor may not necessarily be identical, or because it can occur that entries are only partially complete in a join-based processor, field values may be marked as "invalid", at which point their data should not be read. This is handled by the RNTupleProcessorOptionalPtr that is returned by RequestField().

Definition at line 245 of file RNTupleProcessor.hxx.

Classes

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.
 
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
 
void PrintStructure (std::ostream &output=std::cout)
 Print a graphical representation of the processor composition.
 
template<typename T >
RNTupleProcessorOptionalPtr< T > RequestField (std::string_view fieldName, void *valuePtr=nullptr)
 Request access to a field for reading during processing.
 

Static Public Member Functions

static std::unique_ptr< RNTupleProcessorCreate (RNTupleOpenSpec ntuple, std::string_view processorName="")
 Create an RNTupleProcessor for a single RNTuple.
 
static std::unique_ptr< RNTupleProcessorCreateChain (std::vector< RNTupleOpenSpec > ntuples, std::string_view processorName="")
 Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.
 
static std::unique_ptr< RNTupleProcessorCreateChain (std::vector< std::unique_ptr< RNTupleProcessor > > innerProcessors, std::string_view processorName="")
 Create an RNTupleProcessor for a chain (i.e., a vertical combination) of other RNTupleProcessors.
 
static std::unique_ptr< RNTupleProcessorCreateJoin (RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTuple, const std::vector< std::string > &joinFields, std::string_view processorName="")
 Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.
 
static std::unique_ptr< RNTupleProcessorCreateJoin (std::unique_ptr< RNTupleProcessor > primaryProcessor, std::unique_ptr< RNTupleProcessor > auxProcessor, const std::vector< std::string > &joinFields, std::string_view processorName="")
 Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.
 

Protected Member Functions

 RNTupleProcessor (std::string_view processorName)
 Create a new base RNTupleProcessor.
 
virtual void AddEntriesToJoinTable (Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0)=0
 Add the entry mappings for this processor to the provided join table.
 
virtual ROOT::RResult< Internal::RNTupleProcessorEntry::FieldIndex_tAddFieldToEntry (std::string_view fieldName, void *valuePtr, const Internal::RNTupleProcessorProvenance &provenance)=0
 Add a field to the entry.
 
virtual bool CanReadFieldFromDisk (std::string_view fieldName)=0
 Check if a field exists on-disk and can be read by the processor.
 
virtual void Connect (const std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > &fieldIdxs, const Internal::RNTupleProcessorProvenance &provenance, bool updateFields)=0
 Connect fields to the page source of the processor's underlying RNTuple(s).
 
virtual ROOT::NTupleSize_t GetNEntries ()=0
 Get the total number of entries in this processor.
 
const ROOT::RNTupleModelGetProtoModel () const
 Get the proto model used by the processor.
 
virtual void Initialize (std::shared_ptr< Internal::RNTupleProcessorEntry > entry)=0
 Initialize the processor, by setting fProtoModel and creating an (initially empty) fEntry, or setting an existing one.
 
bool IsInitialized () const
 Check if the processor already has been initialized.
 
virtual ROOT::NTupleSize_t LoadEntry (ROOT::NTupleSize_t entryNumber)=0
 Load the entry identified by the provided entry number.
 
virtual void PrintStructureImpl (std::ostream &output) const =0
 Processor-specific implementation for printing its structure, called by PrintStructure().
 

Protected Attributes

ROOT::NTupleSize_t fCurrentEntryNumber = 0
 
std::size_t fCurrentProcessorNumber = 0
 
std::shared_ptr< Internal::RNTupleProcessorEntryfEntry = nullptr
 
std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_tfFieldIdxs
 
ROOT::NTupleSize_t fNEntries = kInvalidNTupleIndex
 Total number of entries.
 
ROOT::NTupleSize_t fNEntriesProcessed = 0
 
std::string fProcessorName
 
std::unique_ptr< ROOT::RNTupleModelfProtoModel = nullptr
 

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)
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.

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

◆ AddEntriesToJoinTable()

virtual void ROOT::Experimental::RNTupleProcessor::AddEntriesToJoinTable ( Internal::RNTupleJoinTable & joinTable,
ROOT::NTupleSize_t entryOffset = 0 )
protectedpure virtual

Add the entry mappings for this processor to the provided join table.

Parameters
[in]joinTablethe join table to map the entries to.
[in]entryOffsetIn case the entry mapping is added from a chain, the offset of the entry indexes to use with respect to the processor's position in the chain.

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

◆ AddFieldToEntry()

virtual ROOT::RResult< Internal::RNTupleProcessorEntry::FieldIndex_t > ROOT::Experimental::RNTupleProcessor::AddFieldToEntry ( std::string_view fieldName,
void * valuePtr,
const Internal::RNTupleProcessorProvenance & provenance )
protectedpure virtual

Add a field to the entry.

Parameters
[in]fieldNameName of the field to add.
[in]valuePtrPointer to bind to the field's value in the entry. If this is a nullptr, a pointer will be created.
[in]provenanceProvenance of the processor.
Returns
The index of the newly added field in the entry.

In case the field was already present in the entry, the index of the existing field is returned.

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

◆ begin()

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

Definition at line 483 of file RNTupleProcessor.hxx.

◆ CanReadFieldFromDisk()

virtual bool ROOT::Experimental::RNTupleProcessor::CanReadFieldFromDisk ( std::string_view fieldName)
protectedpure virtual

Check if a field exists on-disk and can be read by the processor.

Parameters
[in]fieldNameName of the field to check.

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

◆ Connect()

virtual void ROOT::Experimental::RNTupleProcessor::Connect ( const std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > & fieldIdxs,
const Internal::RNTupleProcessorProvenance & provenance,
bool updateFields )
protectedpure virtual

Connect fields to the page source of the processor's underlying RNTuple(s).

Parameters
[in]fieldIdxsIndices of the fields to connect.
[in]provenanceProvenance of the processor.
[in]updateFieldsWhether the fields in the entry need to be updated, because the current underlying RNTuple source changed.

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

◆ Create()

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::Create ( RNTupleOpenSpec ntuple,
std::string_view processorName = "" )
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. If empty, the name of the input RNTuple is used.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 38 of file RNTupleProcessor.cxx.

◆ CreateChain() [1/2]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateChain ( std::vector< RNTupleOpenSpec > ntuples,
std::string_view processorName = "" )
static

Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.

Parameters
[in]ntuplesA list specifying the names and locations of the RNTuples to process.
[in]processorNameThe name to give to the processor. If empty, the name of the first RNTuple is used.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 44 of file RNTupleProcessor.cxx.

◆ CreateChain() [2/2]

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

Create an RNTupleProcessor for a chain (i.e., a vertical combination) of other RNTupleProcessors.

Parameters
[in]innerProcessorsA list with the processors to chain.
[in]processorNameThe name to give to the processor. If empty, the name of the first inner processor is used.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 60 of file RNTupleProcessor.cxx.

◆ CreateJoin() [1/2]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateJoin ( RNTupleOpenSpec primaryNTuple,
RNTupleOpenSpec auxNTuple,
const std::vector< std::string > & joinFields,
std::string_view processorName = "" )
static

Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.

Parameters
[in]primaryNTupleThe name and location of the primary RNTuple. Its entries are processed in sequential order.
[in]auxNTupleThe name and location of the RNTuple to join the primary RNTuple with. The order in which its entries are processed is determined by the primary RNTuple and doesn't necessarily have to be sequential.
[in]joinFieldsThe names of the fields on which to join, in case the specified RNTuples 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.
[in]processorNameThe name to give to the processor. If empty, the name of the primary RNTuple is used.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 70 of file RNTupleProcessor.cxx.

◆ CreateJoin() [2/2]

std::unique_ptr< ROOT::Experimental::RNTupleProcessor > ROOT::Experimental::RNTupleProcessor::CreateJoin ( std::unique_ptr< RNTupleProcessor > primaryProcessor,
std::unique_ptr< RNTupleProcessor > auxProcessor,
const std::vector< std::string > & joinFields,
std::string_view processorName = "" )
static

Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.

Parameters
[in]primaryProcessorThe primary processor. Its entries are processed in sequential order.
[in]auxProcessorThe processor to join the primary processor with. The order in which its entries are processed is determined by the primary processor and doesn't necessarily have to be sequential.
[in]joinFieldsThe names of the fields on which to join, in case the specified processors are unaligned. The join is made based on the combined join field values, and therefore each field has to be present in each specified processors. If an empty list is provided, it is assumed that the specified processors are fully aligned.
[in]processorNameThe name to give to the processor. If empty, the name of the primary processor is used.
Returns
A pointer to the newly created RNTupleProcessor.

Definition at line 90 of file RNTupleProcessor.cxx.

◆ end()

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

Definition at line 484 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 364 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 370 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 360 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 processor for RNTupleJoinProcessor.

Definition at line 378 of file RNTupleProcessor.hxx.

◆ GetProtoModel()

const ROOT::RNTupleModel & ROOT::Experimental::RNTupleProcessor::GetProtoModel ( ) const
inlineprotected

Get the proto model used by the processor.

A processor's proto model contains all fields that can be accessed and is inferred from the descriptors of the underlying RNTuples. It is used in RequestField() to check that the requested field is actually valid.

Definition at line 297 of file RNTupleProcessor.hxx.

◆ Initialize()

virtual void ROOT::Experimental::RNTupleProcessor::Initialize ( std::shared_ptr< Internal::RNTupleProcessorEntry > entry)
protectedpure virtual

Initialize the processor, by setting fProtoModel and creating an (initially empty) fEntry, or setting an existing one.

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

◆ IsInitialized()

bool ROOT::Experimental::RNTupleProcessor::IsInitialized ( ) const
inlineprotected

Check if the processor already has been initialized.

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

◆ PrintStructure()

void ROOT::Experimental::RNTupleProcessor::PrintStructure ( std::ostream & output = std::cout)
inline

Print a graphical representation of the processor composition.

Parameters
[in,out]outputStream to print to (default is stdout).

Example:

The structure of a processor representing a join between a single primary RNTuple and a chain of two auxiliary RNTuples will be printed as follows:

+-----------------------------+ +-----------------------------+
| ntuple.root | | ntuple_aux1.root |
+-----------------------------+ +-----------------------------+
+-----------------------------+
| ntuple_aux2.root |
+-----------------------------+

Definition at line 421 of file RNTupleProcessor.hxx.

◆ PrintStructureImpl()

virtual void ROOT::Experimental::RNTupleProcessor::PrintStructureImpl ( std::ostream & output) const
protectedpure virtual

Processor-specific implementation for printing its structure, called by PrintStructure().

Parameters
[in,out]outputOutput stream to print to.

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

◆ RequestField()

template<typename T >
RNTupleProcessorOptionalPtr< T > ROOT::Experimental::RNTupleProcessor::RequestField ( std::string_view fieldName,
void * valuePtr = nullptr )
inline

Request access to a field for reading during processing.

Template Parameters
TType of the requested field.
Parameters
[in]fieldNameName of the requested field.
Returns
An RNTupleProcessorOptionalPtr, which provides access to the field's value.
Warning
Provide a valuePtr with care! Values may not always be valid for every entry during processing, for example when a field is not present in one of the chained processors or when during a join operation, no matching entry in the auxiliary processor can be found. Reading valuePtr as-is therefore comes with the risk of reading invalid data. After passing a pointer to RequestField, we strongly recommend only accessing its data through the interface of the returned RNTupleProcessorOptionalPtr, to ensure that only valid data can be read.

Definition at line 395 of file RNTupleProcessor.hxx.

Friends And Related Symbol Documentation

◆ RNTupleChainProcessor

Definition at line 248 of file RNTupleProcessor.hxx.

◆ RNTupleJoinProcessor

friend class RNTupleJoinProcessor
friend

Definition at line 249 of file RNTupleProcessor.hxx.

◆ RNTupleSingleProcessor

Definition at line 247 of file RNTupleProcessor.hxx.

◆ ROOT::Experimental::Internal::RNTupleProcessorEntryLoader

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

Definition at line 246 of file RNTupleProcessor.hxx.

Member Data Documentation

◆ fCurrentEntryNumber

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

Definition at line 262 of file RNTupleProcessor.hxx.

◆ fCurrentProcessorNumber

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

Definition at line 263 of file RNTupleProcessor.hxx.

◆ fEntry

std::shared_ptr<Internal::RNTupleProcessorEntry> ROOT::Experimental::RNTupleProcessor::fEntry = nullptr
protected

Definition at line 254 of file RNTupleProcessor.hxx.

◆ fFieldIdxs

std::unordered_set<Internal::RNTupleProcessorEntry::FieldIndex_t> ROOT::Experimental::RNTupleProcessor::fFieldIdxs
protected

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

◆ fNEntriesProcessed

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

Definition at line 261 of file RNTupleProcessor.hxx.

◆ fProcessorName

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

Definition at line 252 of file RNTupleProcessor.hxx.

◆ fProtoModel

std::unique_ptr<ROOT::RNTupleModel> ROOT::Experimental::RNTupleProcessor::fProtoModel = nullptr
protected

Definition at line 253 of file RNTupleProcessor.hxx.

Libraries for ROOT::Experimental::RNTupleProcessor:

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