15#ifndef ROOT_RNTupleProcessor
16#define ROOT_RNTupleProcessor
36struct RNTupleProcessorEntryLoader;
58 std::variant<std::string, TDirectory *>
fStorage;
134 "\" because it has no value for the current entry"));
147 "\" because it has no value for the current entry"));
253 std::shared_ptr<Internal::RNTupleProcessorEntry>
fEntry =
nullptr;
254 std::unordered_set<Internal::RNTupleProcessorEntry::FieldIndex_t>
fFieldIdxs;
267 virtual void Initialize(std::shared_ptr<Internal::RNTupleProcessorEntry> entry) = 0;
280 virtual void Connect(
const std::unordered_set<Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
393 template <
typename T>
446 fCurrentEntryNumber = ROOT::kInvalidNTupleIndex;
492 static std::unique_ptr<RNTupleProcessor>
Create(
RNTupleOpenSpec ntuple, std::string_view processorName =
"");
501 static std::unique_ptr<RNTupleProcessor>
502 CreateChain(std::vector<RNTupleOpenSpec> ntuples, std::string_view processorName =
"");
512 static std::unique_ptr<RNTupleProcessor>
513 CreateChain(std::vector<std::unique_ptr<RNTupleProcessor>> innerProcessors, std::string_view processorName =
"");
529 const std::vector<std::string> &joinFields,
530 std::string_view processorName =
"");
545 static std::unique_ptr<RNTupleProcessor>
546 CreateJoin(std::unique_ptr<RNTupleProcessor> primaryProcessor, std::unique_ptr<RNTupleProcessor> auxProcessor,
547 const std::vector<std::string> &joinFields, std::string_view processorName =
"");
569 void Initialize(std::shared_ptr<Internal::RNTupleProcessorEntry> entry =
nullptr) final;
573 void Connect(const std::unordered_set<
Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
575 bool updateFields = false) final;
605 std::string_view fieldName,
void *valuePtr =
nullptr,
659 void Initialize(std::shared_ptr<Internal::RNTupleProcessorEntry> entry =
nullptr) final;
665 void Connect(const std::unordered_set<
Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
667 bool updateFields = false) final;
700 std::string_view fieldName,
void *valuePtr =
nullptr,
757 void Initialize(std::shared_ptr<Internal::RNTupleProcessorEntry> entry =
nullptr) final;
763 void Connect(const std::unordered_set<
Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
765 bool updateFields = false) final;
799 if (fieldName.find(fAuxiliaryProcessor->GetProcessorName()) == 0)
800 fieldName = fieldName.substr(fAuxiliaryProcessor->GetProcessorName().size() + 1);
801 return fAuxiliaryProcessor->CanReadFieldFromDisk(fieldName);
812 std::string_view fieldName,
void *valuePtr =
nullptr,
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Builds a join table on one or several fields of an RNTuple so it can be joined onto other RNTuples.
Collection of values in an RNTupleProcessor, analogous to REntry, with checks and support for missing...
std::uint64_t FieldIndex_t
Processor specialization for vertically combined (chained) RNTupleProcessors.
bool CanReadFieldFromDisk(std::string_view fieldName) final
Check if a field exists on-disk and can be read by the processor.
void PrintStructureImpl(std::ostream &output) const final
Processor-specific implementation for printing its structure, called by PrintStructure().
void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0) final
Add the entry mappings for this processor to the provided join table.
RNTupleChainProcessor(std::vector< std::unique_ptr< RNTupleProcessor > > processors, std::string_view processorName)
Construct a new RNTupleChainProcessor.
void ConnectInnerProcessor(std::size_t processorNumber)
Update the entry to reflect any missing fields in the current inner processor.
Internal::RNTupleProcessorProvenance fProvenance
ROOT::NTupleSize_t GetNEntries() final
Get the total number of entries in this processor.
void Initialize(std::shared_ptr< Internal::RNTupleProcessorEntry > entry=nullptr) final
Initialize the processor, by setting fProtoModel and creating an (initially empty) fEntry,...
friend class RNTupleProcessor
std::vector< ROOT::NTupleSize_t > fInnerNEntries
void Connect(const std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > &fieldIdxs, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance(), bool updateFields=false) final
Connect the provided fields indices in the entry to their on-disk fields.
ROOT::NTupleSize_t LoadEntry(ROOT::NTupleSize_t entryNumber) final
Load the entry identified by the provided (global) entry number (i.e., considering all RNTuples in th...
ROOT::RResult< Internal::RNTupleProcessorEntry::FieldIndex_t > AddFieldToEntry(std::string_view fieldName, void *valuePtr=nullptr, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance()) final
Add a field to the entry.
std::vector< std::unique_ptr< RNTupleProcessor > > fInnerProcessors
Processor specialization for horizontally combined (joined) RNTupleProcessors.
std::set< Internal::RNTupleProcessorEntry::FieldIndex_t > fJoinFieldIdxs
std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > fAuxiliaryFieldIdxs
RNTupleJoinProcessor(std::unique_ptr< RNTupleProcessor > primaryProcessor, std::unique_ptr< RNTupleProcessor > auxProcessor, const std::vector< std::string > &joinFields, std::string_view processorName)
Construct a new RNTupleJoinProcessor.
void SetProtoModel(std::unique_ptr< ROOT::RNTupleModel > primaryModel, std::unique_ptr< ROOT::RNTupleModel > auxModel)
Set the processor's proto model by combining the primary and auxiliary models.
ROOT::NTupleSize_t LoadEntry(ROOT::NTupleSize_t entryNumber) final
Load the entry identified by the provided entry number of the primary processor.
ROOT::NTupleSize_t GetNEntries() final
Get the total number of entries in this processor.
void SetAuxiliaryFieldValidity(bool validity)
Set the validity for all fields in the auxiliary processor at once.
void Connect(const std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > &fieldIdxs, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance(), bool updateFields=false) final
Connect the provided fields indices in the entry to their on-disk fields.
std::vector< std::string > fJoinFieldNames
friend class RNTupleProcessor
bool CanReadFieldFromDisk(std::string_view fieldName) final
Check if a field exists on-disk and can be read by the processor.
std::unique_ptr< RNTupleProcessor > fPrimaryProcessor
std::unique_ptr< Internal::RNTupleJoinTable > fJoinTable
std::unique_ptr< RNTupleProcessor > fAuxiliaryProcessor
Specification of the name and location of an RNTuple, used for creating a new RNTupleProcessor.
RNTupleOpenSpec(std::string_view n, const std::string &s)
std::variant< std::string, TDirectory * > fStorage
friend class RNTupleJoinProcessor
RNTupleOpenSpec(std::string_view n, TDirectory *s)
friend class RNTupleProcessor
std::unique_ptr< ROOT::Internal::RPageSource > CreatePageSource() const
friend class RNTupleSingleProcessor
RNTupleProcessorOptionalPtr(Internal::RNTupleProcessorEntry *processorEntry, Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx)
Internal::RNTupleProcessorEntry * fProcessorEntry
void BindRawPtr(void *valuePtr)
Bind the value to valuePtr.
void * GetRawPtr() const
Get a non-owning pointer to the field value managed by the processor's entry.
Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex
friend class RNTupleProcessor
std::shared_ptr< void > GetPtr() const
Get the pointer to the field value managed by the processor's entry.
bool HasValue() const
Check if the pointer currently holds a valid value.
std::shared_ptr< T > GetPtr() const
Get a shared pointer to the field value managed by the processor's entry.
const T & operator*() const
Get a reference to the field value managed by the processor's entry.
Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex
const T * operator->() const
Access the field value managed by the processor's entry.
void BindRawPtr(T *valuePtr)
Bind the value to valuePtr.
bool HasValue() const
Check if the pointer currently holds a valid value.
T * GetRawPtr() const
Get a non-owning pointer to the field value managed by the processor's entry.
Internal::RNTupleProcessorEntry * fProcessorEntry
RNTupleProcessorOptionalPtr(Internal::RNTupleProcessorEntry *processorEntry, Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx)
friend class RNTupleProcessor
Identifies how a processor is composed.
Iterator over the entries of an RNTuple, or vertical concatenation thereof.
std::input_iterator_tag iterator_category
RNTupleProcessor & fProcessor
ROOT::NTupleSize_t & reference
ROOT::NTupleSize_t value_type
std::ptrdiff_t difference_type
friend bool operator==(const iterator &lh, const iterator &rh)
friend bool operator!=(const iterator &lh, const iterator &rh)
ROOT::NTupleSize_t * pointer
ROOT::NTupleSize_t fCurrentEntryNumber
RIterator(RNTupleProcessor &processor, ROOT::NTupleSize_t entryNumber)
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
virtual bool CanReadFieldFromDisk(std::string_view fieldName)=0
Check if a field exists on-disk and can be read by the processor.
const std::string & GetProcessorName() const
Get the name of the processor.
virtual ROOT::NTupleSize_t GetNEntries()=0
Get the total number of entries in this processor.
static std::unique_ptr< RNTupleProcessor > CreateJoin(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.
std::size_t fCurrentProcessorNumber
ROOT::NTupleSize_t fNEntries
Total number of entries.
friend struct ROOT::Experimental::Internal::RNTupleProcessorEntryLoader
friend class RNTupleJoinProcessor
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.
virtual ~RNTupleProcessor()=default
RNTupleProcessor(RNTupleProcessor &&)=delete
std::shared_ptr< Internal::RNTupleProcessorEntry > fEntry
virtual void PrintStructureImpl(std::ostream &output) const =0
Processor-specific implementation for printing its structure, called by PrintStructure().
virtual ROOT::NTupleSize_t LoadEntry(ROOT::NTupleSize_t entryNumber)=0
Load the entry identified by the provided entry number.
ROOT::NTupleSize_t GetCurrentEntryNumber() const
Get the entry number that is currently being processed.
virtual ROOT::RResult< Internal::RNTupleProcessorEntry::FieldIndex_t > AddFieldToEntry(std::string_view fieldName, void *valuePtr, const Internal::RNTupleProcessorProvenance &provenance)=0
Add a field to the entry.
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).
ROOT::NTupleSize_t fNEntriesProcessed
const ROOT::RNTupleModel & GetProtoModel() const
Get the proto model used by the processor.
std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > fFieldIdxs
RNTupleProcessorOptionalPtr< T > RequestField(std::string_view fieldName, void *valuePtr=nullptr)
Request access to a field for reading during processing.
virtual void Initialize(std::shared_ptr< Internal::RNTupleProcessorEntry > entry)=0
Initialize the processor, by setting fProtoModel and creating an (initially empty) fEntry,...
std::string fProcessorName
bool IsInitialized() const
Check if the processor already has been initialized.
virtual void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0)=0
Add the entry mappings for this processor to the provided join table.
std::size_t GetCurrentProcessorNumber() const
Get the number of the inner processor currently being read.
ROOT::NTupleSize_t fCurrentEntryNumber
void PrintStructure(std::ostream &output=std::cout)
Print a graphical representation of the processor composition.
ROOT::NTupleSize_t GetNEntriesProcessed() const
Get the total number of entries processed so far.
friend class RNTupleChainProcessor
RNTupleProcessor(const RNTupleProcessor &)=delete
RNTupleProcessor & operator=(RNTupleProcessor &&)=delete
RNTupleProcessor(std::string_view processorName)
Create a new base RNTupleProcessor.
friend class RNTupleSingleProcessor
std::unique_ptr< ROOT::RNTupleModel > fProtoModel
static std::unique_ptr< RNTupleProcessor > Create(RNTupleOpenSpec ntuple, std::string_view processorName="")
Create an RNTupleProcessor for a single RNTuple.
RNTupleProcessor & operator=(const RNTupleProcessor &)=delete
Processor specialization for processing a single RNTuple.
void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0) final
Add the entry mappings for this processor to the provided join table.
ROOT::RResult< Internal::RNTupleProcessorEntry::FieldIndex_t > AddFieldToEntry(std::string_view fieldName, void *valuePtr=nullptr, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance()) final
Add a field to the entry.
void Connect(const std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > &fieldIdxs, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance(), bool updateFields=false) final
Connect the provided fields indices in the entry to their on-disk fields.
void Initialize(std::shared_ptr< Internal::RNTupleProcessorEntry > entry=nullptr) final
Initialize the processor, by setting fProtoModel and creating an (initially empty) fEntry,...
void PrintStructureImpl(std::ostream &output) const final
Processor-specific implementation for printing its structure, called by PrintStructure().
RNTupleSingleProcessor(RNTupleOpenSpec ntuple, std::string_view processorName)
Construct a new RNTupleProcessor for processing a single RNTuple.
RNTupleOpenSpec fNTupleSpec
std::unique_ptr< ROOT::Internal::RPageSource > fPageSource
friend class RNTupleProcessor
bool CanReadFieldFromDisk(std::string_view fieldName) final
Check if a field exists on-disk and can be read by the processor.
ROOT::NTupleSize_t LoadEntry(ROOT::NTupleSize_t entryNumber) final
Load the entry identified by the provided (global) entry number (i.e., considering all RNTuples in th...
ROOT::NTupleSize_t GetNEntries() final
Get the total number of entries in this processor.
Base class for all ROOT issued exceptions.
The RNTupleModel encapulates the schema of an RNTuple.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Describe directory structure in memory.
Namespace for ROOT features in testing.
if(pos!=-1) leafTypeName.Remove(pos)
constexpr NTupleSize_t kInvalidNTupleIndex
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.