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"));
424 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
430 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
434 fPrimaryProcessor->Initialize(fEntry);
435 fAuxiliaryProcessor->Initialize(fEntry);
440 if (
auto &
primaryModel = fPrimaryProcessor->GetProtoModel();
441 primaryModel.GetFieldNames().find(fAuxiliaryProcessor->GetProcessorName()) !=
444 fAuxiliaryProcessor->GetProcessorName() +
445 "\" is already present as a field in the primary processor; rename the auxiliary "
446 "processor to avoid conflicts"));
449 SetProtoModel(fPrimaryProcessor->GetProtoModel().Clone(), fAuxiliaryProcessor->GetProtoModel().Clone());
451 if (!fJoinFieldNames.empty()) {
452 for (
const auto &
joinField : fJoinFieldNames) {
453 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(
joinField)) {
455 fAuxiliaryProcessor->GetProcessorName() +
"\""));
463 fPrimaryProcessor->GetProcessorName() +
"\""));
464 fJoinFieldIdxs.insert(
fieldIdx.Unwrap());
472 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
481 fAuxiliaryFieldIdxs.insert(
fieldIdx);
491 std::unique_ptr<RNTupleModel>
auxModel)
494 fProtoModel->Unfreeze();
499 std::vector<std::unique_ptr<ROOT::RFieldBase>>
auxFields;
506 auto auxParentField = std::make_unique<Internal::RAuxiliaryProcessorField>(fAuxiliaryProcessor->GetProcessorName(),
512 fProtoModel->RegisterSubfield(
field->GetQualifiedFieldName());
514 if (
field->GetTypeName() ==
"RAuxiliaryProcessorField") {
516 fProtoModel->RegisterSubfield(
auxSubField->GetQualifiedFieldName());
530 fAuxiliaryFieldIdxs.insert(
fieldIdx.Unwrap());
535 fFieldIdxs.insert(
fieldIdx.Unwrap());
542 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
543 fEntry->SetFieldValidity(
fieldIdx, isValid);
551 fEntry->SetFieldValidity(
fieldIdx,
false);
553 SetAuxiliaryFieldValidity(
false);
558 fNEntriesProcessed++;
566 if (!fJoinTableIsBuilt) {
567 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
568 fJoinTableIsBuilt =
true;
573 valPtrs.reserve(fJoinFieldIdxs.size());
574 for (
const auto &
fieldIdx : fJoinFieldIdxs) {
575 auto ptr = fEntry->GetPtr<
void>(
fieldIdx);
584 SetAuxiliaryFieldValidity(
false);
586 SetAuxiliaryFieldValidity(
true);
587 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
598 fNEntries = fPrimaryProcessor->GetNEntries();
620 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(std::vector< std::unique_ptr< RFieldBase > > itemFields)
std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment) const
std::vector< std::size_t > fOffsets
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()