32 auto dir = std::get<TDirectory *>(
fStorage);
37std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
43std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
59std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
69std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
89std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
103 return std::unique_ptr<RNTupleJoinProcessor>(
119 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
126 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
130 fPageSource = fNTupleSpec.CreatePageSource();
131 fPageSource->Attach();
133 opts.SetCreateBare(
true);
134 fProtoModel = fPageSource->GetSharedDescriptorGuard()->CreateModel(
opts);
135 fProtoModel->Unfreeze();
141 auto desc = fPageSource->GetSharedDescriptorGuard();
163 return R__FAIL(
"cannot register field with name \"" + std::string(
fieldName) +
164 "\" because it is not present in the on-disk information of the RNTuple(s) this "
165 "processor is created from");
181 fNEntriesProcessed++;
187 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
197 fNEntries = fPageSource->GetNEntries();
199 auto desc = fPageSource->GetSharedDescriptorGuard();
212 fEntry->SetFieldValidity(
fieldIdx,
false);
227 fEntry->SetFieldValidity(
fieldIdx,
true);
241 static constexpr int width = 32;
247 output <<
"+" << std::setfill(
'-') << std::setw(
width - 1) <<
"+\n";
250 if (
const std::string *
storage = std::get_if<std::string>(&fNTupleSpec.fStorage)) {
260 output <<
"+" << std::setfill(
'-') << std::setw(
width - 1) <<
"+\n";
278 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
284 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
288 fInnerProcessors[0]->Initialize(fEntry);
289 fProtoModel = fInnerProcessors[0]->GetProtoModel().Clone();
297 for (
unsigned i = 0; i < fInnerProcessors.size(); ++i) {
299 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
302 fNEntries += fInnerNEntries[i];
310 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
316 ConnectInnerProcessor(fCurrentProcessorNumber);
323 innerProc->Connect(fFieldIdxs, fProvenance,
true);
339 fCurrentProcessorNumber = 0;
340 ConnectInnerProcessor(fCurrentProcessorNumber);
360 fNEntriesProcessed++;
368 for (
unsigned i = 0; i < fInnerProcessors.size(); ++i) {
369 const auto &
innerProc = fInnerProcessors[i];
380 for (
const auto &
innerProc : fInnerProcessors) {
393 throw RException(
R__FAIL(
"RAuxiliaryProcessorField fields must only be used for reading"));
420 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
426 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
430 fPrimaryProcessor->Initialize(fEntry);
431 fAuxiliaryProcessor->Initialize(fEntry);
436 if (
auto &
primaryModel = fPrimaryProcessor->GetProtoModel();
437 primaryModel.GetFieldNames().find(fAuxiliaryProcessor->GetProcessorName()) !=
440 fAuxiliaryProcessor->GetProcessorName() +
441 "\" is already present as a field in the primary processor; rename the auxiliary "
442 "processor to avoid conflicts"));
445 SetProtoModel(fPrimaryProcessor->GetProtoModel().Clone(), fAuxiliaryProcessor->GetProtoModel().Clone());
447 if (!fJoinFieldNames.empty()) {
448 for (
const auto &
joinField : fJoinFieldNames) {
449 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(
joinField)) {
451 fAuxiliaryProcessor->GetProcessorName() +
"\""));
459 fPrimaryProcessor->GetProcessorName() +
"\""));
460 fJoinFieldIdxs.insert(
fieldIdx.Unwrap());
468 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
477 fAuxiliaryFieldIdxs.insert(
fieldIdx);
487 std::unique_ptr<RNTupleModel>
auxModel)
490 fProtoModel->Unfreeze();
495 std::vector<std::unique_ptr<ROOT::RFieldBase>>
auxFields;
502 auto auxParentField = std::make_unique<Internal::RAuxiliaryProcessorField>(fAuxiliaryProcessor->GetProcessorName(),
508 fProtoModel->RegisterSubfield(
field->GetQualifiedFieldName());
510 if (
field->GetTypeName() ==
"RAuxiliaryProcessorField") {
512 fProtoModel->RegisterSubfield(
auxSubField->GetQualifiedFieldName());
526 fAuxiliaryFieldIdxs.insert(
fieldIdx.Unwrap());
531 fFieldIdxs.insert(
fieldIdx.Unwrap());
538 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
539 fEntry->SetFieldValidity(
fieldIdx, isValid);
547 fEntry->SetFieldValidity(
fieldIdx,
false);
549 SetAuxiliaryFieldValidity(
false);
554 fNEntriesProcessed++;
562 if (!fJoinTableIsBuilt) {
563 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
564 fJoinTableIsBuilt =
true;
569 valPtrs.reserve(fJoinFieldIdxs.size());
570 for (
const auto &
fieldIdx : fJoinFieldIdxs) {
571 auto ptr = fEntry->GetPtr<
void>(
fieldIdx);
580 SetAuxiliaryFieldValidity(
false);
582 SetAuxiliaryFieldValidity(
true);
583 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
594 fNEntries = fPrimaryProcessor->GetNEntries();
616 for (
unsigned i = 0; i <
maxLength; i++) {
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
RAuxiliaryProcessorField(std::string_view fieldName, std::vector< std::unique_ptr< RFieldBase > > itemFields)
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponding to the field type ...
Builds a join table on one or several fields of an RNTuple so it can be joined onto other RNTuples.
static std::unique_ptr< RNTupleJoinTable > Create(const std::vector< std::string > &joinFieldNames)
Create an RNTupleJoinTable from an existing RNTuple.
static constexpr PartitionKey_t kDefaultPartitionKey
Processor specialization for vertically combined (chained) RNTupleProcessors.
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.
void ConnectInnerProcessor(std::size_t processorNumber)
Update the entry to reflect any missing fields in the current inner processor.
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,...
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.
void PrintStructureImpl(std::ostream &output) const final
Processor-specific implementation for printing its structure, called by PrintStructure().
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 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.
void AddEntriesToJoinTable(Internal::RNTupleJoinTable &joinTable, ROOT::NTupleSize_t entryOffset=0) final
Add the entry mappings for this processor to the provided join table.
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::unique_ptr< RNTupleProcessor > fPrimaryProcessor
void Initialize(std::shared_ptr< Internal::RNTupleProcessorEntry > entry=nullptr) final
Initialize the processor, by setting fProtoModel and creating an (initially empty) fEntry,...
Specification of the name and location of an RNTuple, used for creating a new RNTupleProcessor.
std::variant< std::string, TDirectory * > fStorage
std::unique_ptr< ROOT::Internal::RPageSource > CreatePageSource() const
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
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.
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.
std::string fProcessorName
friend class RNTupleChainProcessor
friend class RNTupleSingleProcessor
static std::unique_ptr< RNTupleProcessor > Create(RNTupleOpenSpec ntuple, std::string_view processorName="")
Create an RNTupleProcessor for a single RNTuple.
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().
RNTupleOpenSpec fNTupleSpec
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...
static std::unique_ptr< RPageSourceFile > CreateFromAnchor(const RNTuple &anchor, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Used from the RNTuple class to build a datasource if the anchor is already available.
static std::unique_ptr< RPageSource > Create(std::string_view ntupleName, std::string_view location, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Guess the concrete derived page source from the file name (location)
Base class for all ROOT issued exceptions.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponding to the field type ...
Representation of an RNTuple data set in a ROOT file.
const_iterator begin() const
const_iterator end() const
The field for an untyped record.
void AttachItemFields(ContainerT &&itemFields)
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
ROOT::RFieldZero & GetFieldZeroOfModel(RNTupleModel &model)
void CallConnectPageSourceOnField(RFieldBase &, ROOT::Internal::RPageSource &)
constexpr NTupleSize_t kInvalidNTupleIndex
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
Modifiers passed to CreateModel()