15#ifndef ROOT_RNTupleProcessor
16#define ROOT_RNTupleProcessor
33class RNTupleProcessor;
35class RNTupleProcessorValuePtr;
36namespace Experimental {
37class RNTupleJoinProcessor;
41class RNTupleProcessorColumnReader;
48struct RNTupleProcessorEntryLoader;
49const RNTupleProcessorEntry *
130 return value.template GetPtr<T>();
158 "\" because it has no value for the current entry"));
171 "\" because it has no value for the current entry"));
238 return value.template GetPtr<void>();
301 bool includeSubfields);
415 std::shared_ptr<ROOT::Internal::RNTupleProcessorEntry>
fEntry =
nullptr;
416 std::unordered_set<Internal::RNTupleProcessorEntry::FieldIndex_t>
fFieldIdxs;
426 virtual void Initialize(std::shared_ptr<ROOT::Internal::RNTupleProcessorEntry> entry) = 0;
439 virtual void Connect(
const std::unordered_set<Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
498 AddFieldToEntry(
const std::string &canonicalFieldName,
const std::string &typeName,
void *valuePtr,
517 AddFieldToEntry(std::unique_ptr<ROOT::RFieldBase> field,
const std::string &canonicalFieldName,
void *valuePtr,
581 template <
typename T>
585 std::string typeName{};
586 if constexpr (!std::is_void_v<T>) {
591 if (
auto fieldIdx =
fEntry->FindFieldIndex(fieldName, typeName)) {
595 if (valuePtr !=
nullptr && valuePtr !=
value.GetPtr<
void>().get()) {
596 throw RException(
R__FAIL(
"attempted to request a field with user-provided value pointer to field \"" +
598 "\", which already exists in the entry. To change the underlying value pointer, "
599 "use RNTupleProcessorValuePtr::Bind instead."));
624 RequestField(
const std::string &fieldName,
const std::string &typeName,
void *valuePtr =
nullptr)
722 static std::unique_ptr<RNTupleProcessor>
732 static std::unique_ptr<RNTupleProcessor>
742 static std::unique_ptr<RNTupleProcessor>
743 CreateChain(std::vector<std::unique_ptr<RNTupleProcessor>> innerProcessors,
769 std::unique_ptr<ROOT::RFieldBase>
780 std::unique_ptr<ROOT::RFieldBase>
ConnectField(std::unique_ptr<ROOT::RFieldBase> field);
786 void Initialize(std::shared_ptr<ROOT::Internal::RNTupleProcessorEntry> entry =
nullptr) final;
792 bool updateFields = false) final;
825 const std::
string &fieldName, const std::
string &typeName,
void *valuePtr =
nullptr,
896 void Initialize(std::shared_ptr<ROOT::Internal::RNTupleProcessorEntry> entry =
nullptr) final;
904 bool updateFields = false) final;
946 const std::string &fieldName,
const std::string &typeName,
void *valuePtr =
nullptr,
994namespace Experimental {
1009std::unique_ptr<RNTupleProcessor>
1011 const std::vector<std::string> &joinFields,
1028std::unique_ptr<RNTupleProcessor>
1029CreateRNTupleJoinProcessor(std::unique_ptr<RNTupleProcessor> primaryProcessor,
1030 std::unique_ptr<RNTupleProcessor> auxProcessor,
const std::vector<std::string> &joinFields,
1042 friend std::unique_ptr<RNTupleProcessor>
1044 std::unique_ptr<RNTupleProcessor> auxProcessor,
1055 bool fJoinTableIsBuilt =
false;
1060 void Initialize(std::shared_ptr<ROOT::Internal::RNTupleProcessorEntry> entry =
nullptr) final;
1069 bool updateFields = false) final;
1093 void SetAuxiliaryFieldValidity(
bool validity);
1101 if (!fPrimaryProcessor->CanReadFieldFromDisk(fieldName)) {
1102 if (fieldName.find(fAuxiliaryProcessor->fOptions.GetProcessorName()) == 0)
1103 fieldName = fieldName.substr(fAuxiliaryProcessor->fOptions.GetProcessorName().size() + 1);
1104 return fAuxiliaryProcessor->CanReadFieldFromDisk(fieldName);
1115 AddFieldToEntry(
const std::string &fieldName,
const std::string &typeName,
void *valuePtr =
nullptr,
1155 std::unique_ptr<
RNTupleProcessor> auxProcessor, const std::vector<std::
string> &joinFields,
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Builds a join table on one or several fields of an RNTuple so it can be joined onto other RNTuples.
The RDataSource implementation for the RNTupleProcessor.
Processor specialization for horizontally combined (joined) RNTupleProcessors.
std::unordered_set< ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t > fAuxiliaryFieldIdxs
std::set< ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t > fJoinFieldIdxs
std::vector< std::string > fJoinFieldNames
std::unique_ptr< RNTupleProcessor > fPrimaryProcessor
std::unique_ptr< Internal::RNTupleJoinTable > fJoinTable
friend std::unique_ptr< RNTupleProcessor > CreateRNTupleJoinProcessor(std::unique_ptr< RNTupleProcessor > primaryProcessor, std::unique_ptr< RNTupleProcessor > auxProcessor, const std::vector< std::string > &joinFields, const RNTupleProcessorOptions &opts)
Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.
std::unique_ptr< RNTupleProcessor > fAuxiliaryProcessor
Collection of values in an RNTupleProcessor, analogous to REntry, with checks and support for missing...
std::uint64_t FieldIndex_t
ROOT::RFieldBase::RValue CreateValue(FieldIndex_t fieldIdx)
Create an RValue connected to the field identified by fieldIdx.
const ROOT::RFieldBase::RValue & GetValue(FieldIndex_t fieldIdx) const
bool IsValidField(FieldIndex_t fieldIdx) const
Check whether a field is valid for reading.
const std::string & FindFieldName(FieldIndex_t fieldIdx) const
Find the name of a field from its field index.
void BindRawPtr(FieldIndex_t fieldIdx, void *valuePtr)
Bind a new value pointer to a field in the entry.
void Bind(FieldIndex_t fieldIdx, std::shared_ptr< void > valuePtr)
Bind a new value pointer to a field in the entry.
Base class for all ROOT issued exceptions.
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
A field translates read and write calls from/to underlying columns to/from tree values.
Processor specialization for vertically combined (chained) RNTupleProcessors.
std::vector< std::unique_ptr< RNTupleProcessor > > fInnerProcessors
void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final
Add all known fields (from on-disk information) to the entry.
void ConnectInnerProcessor(std::size_t processorNumber)
Update the entry to reflect any missing fields in the current inner processor.
bool CanReadFieldFromDisk(std::string_view fieldName) final
Check if a field exists on-disk and can be read by the processor.
void Initialize(std::shared_ptr< ROOT::Internal::RNTupleProcessorEntry > entry=nullptr) final
Initialize the processor by creating an (initially empty) fEntry, or setting an existing one.
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.
Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr=nullptr, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance()) final
Add a field to the entry.
void LoadEntryImpl(const REntryMapping &mapping) final
Load the entry identified by the entry mapping.
void SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) final
Set the local entry mapping (for nested processors), according to a global entry number.
void AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0) final
Add the entry mappings for this processor to the provided join table.
ROOT::NTupleSize_t fLastLoadedEntry
void PrintStructureImpl(std::ostream &output) const final
Processor-specific implementation for printing its structure, called by PrintStructure().
std::size_t fCurrentProcessorNumber
void Disconnect() final
Disconnect the processor from associated physical storage.
Internal::RNTupleProcessorProvenance fProvenance
ROOT::NTupleSize_t GetNEntries() final
Get the total number of entries in this processor.
std::string fProcessorName
By default, the processor name is the name of the underlying RNTuple for RNTupleSingleProcessor,...
const std::string & GetProcessorName() const
Get the processor's name.
void SetProcessorName(std::string_view name)
Set the processor's name.
std::shared_ptr< void > GetPtr() const
Get the pointer to the field value managed by the processor's entry.
void Bind(std::shared_ptr< void > valuePtr)
Bind the value to valuePtr.
ROOT::RFieldBase::RValue CreateValue()
Create an RValue connected to the field managed by the processor's entry.
ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex
bool HasValue() const
Check if the pointer currently holds a valid value.
void * GetRawPtr() const
Get a non-owning pointer to the field value managed by the processor's entry.
RNTupleProcessorValuePtr(ROOT::Internal::RNTupleProcessorEntry *processorEntry, ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx)
friend bool operator==(const RNTupleProcessorValuePtr< void > &lhs, const RNTupleProcessorValuePtr< void > &rhs)
void BindRawPtr(void *valuePtr)
Bind the value to valuePtr.
ROOT::Internal::RNTupleProcessorEntry * fProcessorEntry
void BindRawPtr(T *valuePtr)
Bind the value to valuePtr.
const T * operator->() const
Access the field value managed by the processor's entry.
RNTupleProcessorValuePtr(ROOT::Internal::RNTupleProcessorEntry *processorEntry, ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fieldIdx)
ROOT::Internal::RNTupleProcessorEntry::FieldIndex_t fFieldIndex
const T & operator*() const
Get a reference to the field value managed by the processor's entry.
ROOT::Internal::RNTupleProcessorEntry * fProcessorEntry
bool HasValue() const
Check if the pointer currently holds a valid value.
void Bind(std::shared_ptr< T > valuePtr)
Bind the value to valuePtr.
friend bool operator==(const RNTupleProcessorValuePtr< T > &lhs, const RNTupleProcessorValuePtr< T > &rhs)
T * GetRawPtr() const
Get a non-owning pointer to the field value managed by the processor's entry.
std::shared_ptr< T > GetPtr() const
Get a shared pointer to the field value managed by the processor's entry.
Maps a processor's global (outer) entry index to its inner ones.
REntryMapping & GetPrimaryProcessorMapping()
friend bool operator==(const REntryMapping &lhs, const REntryMapping &rhs)
REntryMapping & operator=(const REntryMapping &other)
REntryMapping & GetInnerProcessorMapping()
REntryMapping(REntryMapping &&other)=default
REntryMapping(const REntryMapping &other)
std::unique_ptr< REntryMapping > fPrimaryMapping
std::size_t GetInnerProcessorIdx() const
const REntryMapping & GetAuxiliaryProcessorMapping() const
void SetInnerProcessorIdx(std::size_t idx)
const REntryMapping & GetInnerProcessorMapping() const
void SetEntryNumber(ROOT::NTupleSize_t entryNumber)
ROOT::NTupleSize_t operator*() const
ROOT::NTupleSize_t fEntryNumber
ROOT::NTupleSize_t GetEntryNumber() const
REntryMapping & GetAuxiliaryProcessorMapping()
std::unique_ptr< REntryMapping > fAuxiliaryMapping
friend bool operator!=(const REntryMapping &lhs, const REntryMapping &rhs)
REntryMapping & operator=(REntryMapping &&other)=default
const REntryMapping & GetPrimaryProcessorMapping() const
std::size_t fInnerProcessorIdx
std::unique_ptr< REntryMapping > fInnerMapping
Iterator over the entries of an RNTuple, or vertical concatenation thereof.
RIterator(RNTupleProcessor &processor, ROOT::NTupleSize_t firstEntryIdx)
const value_type * operator->() const
RNTupleProcessor & fProcessor
friend bool operator==(const iterator &lh, const iterator &rh)
friend bool operator!=(const iterator &lh, const iterator &rh)
std::forward_iterator_tag iterator_category
RNTupleProcessor::REntryMapping fEntryMapping
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
friend struct ROOT::Internal::RNTupleProcessorEntryLoader
ROOT::NTupleSize_t fNEntries
Total number of entries.
virtual void Disconnect()=0
Disconnect the processor from associated physical storage.
virtual Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(const std::string &canonicalFieldName, const std::string &typeName, void *valuePtr, const Internal::RNTupleProcessorProvenance &provenance)=0
Add a field to the entry.
RNTupleProcessorValuePtr< void > RequestField(const std::string &fieldName, const std::string &typeName, void *valuePtr=nullptr)
Request access to a field for reading during processing.
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).
std::unordered_set< Internal::RNTupleProcessorEntry::FieldIndex_t > fFieldIdxs
virtual void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields)=0
Add all known fields (from on-disk information) to the entry.
static std::unique_ptr< RNTupleProcessor > CreateChain(std::vector< RNTupleInputSpec > ntuples, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.
virtual void PrintStructureImpl(std::ostream &output) const =0
Processor-specific implementation for printing its structure, called by PrintStructure().
virtual ROOT::NTupleSize_t GetNEntries()=0
Get the total number of entries in this processor.
virtual void Initialize(std::shared_ptr< ROOT::Internal::RNTupleProcessorEntry > entry)=0
Initialize the processor by creating an (initially empty) fEntry, or setting an existing one.
const ROOT::Internal::RNTupleProcessorEntry & GetEntry() const
Get a reference to the processor's internal entry.
RNTupleProcessor & operator=(RNTupleProcessor &&)=delete
RNTupleProcessor(const RNTupleProcessor &)=delete
RNTupleProcessor(RNTupleProcessor &&)=delete
void LoadEntry(const REntryMapping &mapping)
Load the entry identified by the entry mapping.
RNTupleProcessor(const RNTupleProcessorOptions &options)
Create a new base RNTupleProcessor.
ROOT::NTupleSize_t GetNEntriesProcessed() const
Get the total number of entries processed so far.
void PrintStructure(std::ostream &output=std::cout)
Print a graphical representation of the processor composition.
ROOT::Internal::RNTupleProcessorEntry & GetEntry()
Get a reference to the processor's internal entry.
ROOT::NTupleSize_t fNEntriesProcessed
virtual void SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping)=0
Set the local entry mapping (for nested processors), according to a global entry number.
RNTupleProcessorValuePtr< T > RequestField(const std::string &fieldName, void *valuePtr=nullptr)
Request access to a field for reading during processing.
static std::unique_ptr< RNTupleProcessor > Create(RNTupleInputSpec ntuple, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a single RNTuple.
virtual void LoadEntryImpl(const REntryMapping &mapping)=0
Load the entry identified by the entry mapping.
void IncrementEntryMapping(REntryMapping &mapping)
Increment the local entry mapping by one.
virtual ~RNTupleProcessor()=default
virtual Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(std::unique_ptr< ROOT::RFieldBase > field, const std::string &canonicalFieldName, void *valuePtr, const Internal::RNTupleProcessorProvenance &provenance)=0
Add a field to the entry.
const RNTupleProcessorOptions & GetOptions() const
Get the options used for this processor.
RNTupleProcessorOptions fOptions
virtual void AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0)=0
Add the entry mappings for this processor to the provided join table.
bool IsInitialized() const
Check if the processor already has been initialized.
std::shared_ptr< ROOT::Internal::RNTupleProcessorEntry > fEntry
virtual bool CanReadFieldFromDisk(std::string_view fieldName)=0
Check if a field exists on-disk and can be read by the processor.
RNTupleProcessor & operator=(const RNTupleProcessor &)=delete
Processor specialization for processing a single RNTuple.
void SetEntryMapping(ROOT::NTupleSize_t globalEntryNumber, REntryMapping &mapping) final
Set the local entry mapping (for nested processors), according to a global entry number.
void PrintStructureImpl(std::ostream &output) const final
Processor-specific implementation for printing its structure, called by PrintStructure().
std::unique_ptr< ROOT::Internal::RPageSource > fPageSource
void LoadEntryImpl(const REntryMapping &mapping) final
Load the entry identified by the entry mapping.
RNTupleInputSpec fNTupleSpec
std::unique_ptr< ROOT::RFieldBase > ConnectField(std::unique_ptr< ROOT::RFieldBase > field)
Connect an existing field to the processor's page source.
bool CanReadFieldFromDisk(std::string_view fieldName) final
Check if a field exists on-disk and can be read by the processor.
void Initialize(std::shared_ptr< ROOT::Internal::RNTupleProcessorEntry > entry=nullptr) final
Initialize the processor by creating an (initially empty) fEntry, or setting an existing one.
Internal::RNTupleProcessorEntry::FieldIndex_t AddFieldToEntry(const std::string &fieldName, const std::string &typeName, void *valuePtr=nullptr, const Internal::RNTupleProcessorProvenance &provenance=Internal::RNTupleProcessorProvenance()) final
Add a field to the entry.
void AddAllFieldsToEntry(const Internal::RNTupleProcessorProvenance &provenance, bool includeSubfields) final
Add all known fields (from on-disk information) to the entry.
void AddEntriesToJoinTable(Experimental::Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0) final
Add the entry mappings for this processor to the provided join table.
std::unique_ptr< ROOT::RFieldBase > CreateAndConnectField(const std::string &qualifiedFieldName, const std::string &typeName)
Create a new field and connect it to the processor's page source.
ROOT::NTupleSize_t GetNEntries() final
Get the total number of entries in this processor.
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 Disconnect() final
Disconnect the processor from associated physical storage.
ROOT::RFieldBase::RValue CreateRValueFromValuePtr(RNTupleProcessorValuePtr< void > &valuePtr)
const RNTupleProcessorEntry * LoadFullRNTupleProcessorEntry(ROOT::RNTupleProcessor &processor, bool includeSubfields)
std::string GetRenormalizedTypeName(const std::string &metaNormalizedName)
Given a type name normalized by ROOT meta, renormalize it for RNTuple. E.g., insert std::prefix.
constexpr NTupleSize_t kInvalidNTupleIndex
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.