31 auto dir = std::get<TDirectory *>(
fStorage);
36std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
42std::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>();
128 fEntry = std::move(
entry);
130 fPageSource = fNTupleSpec.CreatePageSource();
131 fPageSource->Attach();
133 fNEntries = fPageSource->GetNEntries();
139 auto desc = fPageSource->GetSharedDescriptorGuard();
146std::unique_ptr<ROOT::RFieldBase>
148 const std::string &typeName)
156 auto descGuard = fPageSource->GetSharedDescriptorGuard();
167 std::unique_ptr<ROOT::RFieldBase>
field;
168 if (typeName.empty()) {
175 if (
posDot != std::string::npos)
184 return std::move(
fieldZero.ReleaseSubfields()[0]);
204 "\" because it is not present in the on-disk information of the RNTuple(s) this "
205 "processor is created from"));
223 fNEntriesProcessed++;
228 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
236 for (
const auto &
fieldIdx : fFieldIdxs) {
254 static constexpr int width = 32;
260 output <<
"+" << std::setfill(
'-') << std::setw(
width - 1) <<
"+\n";
263 if (
const std::string *
storage = std::get_if<std::string>(&fNTupleSpec.fStorage)) {
270 output <<
"| " << std::setw(
width - 2) <<
" |\n";
273 output <<
"+" << std::setfill(
'-') << std::setw(
width - 1) <<
"+\n";
291 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
297 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
299 fEntry = std::move(
entry);
301 fInnerProcessors[0]->Initialize(fEntry);
309 for (
unsigned i = 0; i < fInnerProcessors.size(); ++i) {
311 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
314 fNEntries += fInnerNEntries[i];
322 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
328 ConnectInnerProcessor(fCurrentProcessorNumber);
335 innerProc->Connect(fFieldIdxs, fProvenance,
true);
352 fCurrentProcessorNumber = 0;
353 ConnectInnerProcessor(fCurrentProcessorNumber);
360 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
383 fNEntriesProcessed++;
391 for (
unsigned i = 0; i < fInnerProcessors.size(); ++i) {
392 const auto &
innerProc = fInnerProcessors[i];
402 for (
const auto &
innerProc : fInnerProcessors) {
424 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
430 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
432 fEntry = std::move(
entry);
434 fPrimaryProcessor->Initialize(fEntry);
435 fAuxiliaryProcessor->Initialize(fEntry);
437 if (!fJoinFieldNames.empty()) {
438 for (
const auto &
joinField : fJoinFieldNames) {
439 if (!fPrimaryProcessor->CanReadFieldFromDisk(
joinField)) {
441 fPrimaryProcessor->fOptions.GetProcessorName() +
"\""));
443 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(
joinField)) {
445 fAuxiliaryProcessor->fOptions.GetProcessorName() +
"\""));
450 auto fieldIdx = AddFieldToEntry(fOptions.GetProcessorName() +
".R_rntproc_join_" +
joinField,
"std::uint64_t",
460 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
469 fAuxiliaryFieldIdxs.insert(
fieldIdx);
488 if (fPrimaryProcessor->CanReadFieldFromDisk(
fieldName)) {
490 "\" is present in the primary RNTupleProcessor \"" +
491 fPrimaryProcessor->fOptions.GetProcessorName() +
492 "\", but may also refer to a field in the auxiliary RNTupleProcessor named \"" +
493 fAuxiliaryProcessor->fOptions.GetProcessorName() +
494 "\". To avoid this ambiguity, rename the auxiliary RNTupleProcessor."));
499 fAuxiliaryFieldIdxs.insert(
fieldIdx);
511 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
512 fEntry->SetFieldValidity(
fieldIdx, isValid);
520 fEntry->SetFieldValidity(
fieldIdx,
false);
522 SetAuxiliaryFieldValidity(
false);
526 fNEntriesProcessed++;
534 if (!fJoinTableIsBuilt) {
535 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
536 fJoinTableIsBuilt =
true;
540 std::vector<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t> values;
541 values.reserve(fJoinFieldIdxs.size());
542 for (
const auto &
fieldIdx : fJoinFieldIdxs) {
544 values.push_back(val);
549 const auto entryIdx = fJoinTable->GetEntryIndex(values);
552 SetAuxiliaryFieldValidity(
false);
554 SetAuxiliaryFieldValidity(
true);
555 fAuxiliaryProcessor->LoadEntry(
entryIdx);
564 fNEntries = fPrimaryProcessor->GetNEntries();
586 for (
unsigned i = 0; i <
maxLength; i++) {
#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.
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.
std::uint64_t JoinValue_t
static constexpr PartitionKey_t kDefaultPartitionKey
std::uint64_t FieldIndex_t
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.
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.
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 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.
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...
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::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 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.
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
const std::string & GetProcessorName() const
void SetProcessorName(std::string_view name)
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
static std::unique_ptr< RNTupleProcessor > CreateChain(std::vector< RNTupleOpenSpec > ntuples, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.
RNTupleProcessorOptions fOptions
friend class RNTupleJoinProcessor
static std::unique_ptr< RNTupleProcessor > CreateJoin(RNTupleOpenSpec primaryNTuple, RNTupleOpenSpec auxNTuple, const std::vector< std::string > &joinFields, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a join (i.e., a horizontal combination) of RNTuples.
friend class RNTupleChainProcessor
friend class RNTupleSingleProcessor
static std::unique_ptr< RNTupleProcessor > Create(RNTupleOpenSpec ntuple, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
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.
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 creating an (initially empty) fEntry, or setting an existing one.
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...
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.
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.
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.
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName, const ROOT::RCreateFieldOptions &options, const ROOT::RNTupleDescriptor *desc, ROOT::DescriptorId_t fieldId)
Factory method to resurrect a field from the stored on-disk type information.
The container field for an ntuple model, which itself has no physical representation.
Representation of an RNTuple data set in a ROOT file.
const_iterator begin() const
const_iterator end() const
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
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