31 auto dir = std::get<TDirectory *>(
fStorage);
36std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
42std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
58std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
68std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
88std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
102 return std::unique_ptr<RNTupleJoinProcessor>(
118 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
125 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
129 fPageSource = fNTupleSpec.CreatePageSource();
130 fPageSource->Attach();
132 fNEntries = fPageSource->GetNEntries();
138 auto desc = fPageSource->GetSharedDescriptorGuard();
145std::unique_ptr<ROOT::RFieldBase>
147 const std::string &typeName)
158 const auto &desc = fPageSource->GetSharedDescriptorGuard().GetRef();
168 std::unique_ptr<ROOT::RFieldBase>
field;
169 if (typeName.empty()) {
176 if (
posDot != std::string::npos)
185 return std::move(
fieldZero.ReleaseSubfields()[0]);
205 "\" because it is not present in the on-disk information of the RNTuple(s) this "
206 "processor is created from"));
224 fNEntriesProcessed++;
230 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
238 for (
const auto &
fieldIdx : fFieldIdxs) {
256 static constexpr int width = 32;
262 output <<
"+" << std::setfill(
'-') << std::setw(
width - 1) <<
"+\n";
265 if (
const std::string *
storage = std::get_if<std::string>(&fNTupleSpec.fStorage)) {
272 output <<
"| " << std::setw(
width - 2) <<
" |\n";
275 output <<
"+" << std::setfill(
'-') << std::setw(
width - 1) <<
"+\n";
293 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
299 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
303 fInnerProcessors[0]->Initialize(fEntry);
311 for (
unsigned i = 0; i < fInnerProcessors.size(); ++i) {
313 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
316 fNEntries += fInnerNEntries[i];
324 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
330 ConnectInnerProcessor(fCurrentProcessorNumber);
337 innerProc->Connect(fFieldIdxs, fProvenance,
true);
353 fCurrentProcessorNumber = 0;
354 ConnectInnerProcessor(fCurrentProcessorNumber);
374 fNEntriesProcessed++;
382 for (
unsigned i = 0; i < fInnerProcessors.size(); ++i) {
383 const auto &
innerProc = fInnerProcessors[i];
394 for (
const auto &
innerProc : fInnerProcessors) {
407 throw RException(
R__FAIL(
"RAuxiliaryProcessorField fields must only be used for reading"));
434 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry>
entry)
440 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
444 fPrimaryProcessor->Initialize(fEntry);
445 fAuxiliaryProcessor->Initialize(fEntry);
447 if (!fJoinFieldNames.empty()) {
448 for (
const auto &
joinField : fJoinFieldNames) {
449 if (!fPrimaryProcessor->CanReadFieldFromDisk(
joinField)) {
451 fPrimaryProcessor->GetProcessorName() +
"\""));
453 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(
joinField)) {
455 fAuxiliaryProcessor->GetProcessorName() +
"\""));
460 auto fieldIdx = AddFieldToEntry(fProcessorName +
"._join." +
joinField,
"std::uint64_t",
nullptr,
470 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &
fieldIdxs,
479 fAuxiliaryFieldIdxs.insert(
fieldIdx);
498 if (fPrimaryProcessor->CanReadFieldFromDisk(
fieldName)) {
500 "\" is present in the primary RNTupleProcessor \"" +
501 fPrimaryProcessor->GetProcessorName() +
502 "\", but may also refer to a field in the auxiliary RNTupleProcessor named \"" +
503 fAuxiliaryProcessor->GetProcessorName() +
504 "\". To avoid this ambiguity, rename the auxiliary RNTupleProcessor."));
509 fAuxiliaryFieldIdxs.insert(
fieldIdx);
521 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
522 fEntry->SetFieldValidity(
fieldIdx, isValid);
530 fEntry->SetFieldValidity(
fieldIdx,
false);
532 SetAuxiliaryFieldValidity(
false);
537 fNEntriesProcessed++;
545 if (!fJoinTableIsBuilt) {
546 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
547 fJoinTableIsBuilt =
true;
551 std::vector<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t> values;
552 values.reserve(fJoinFieldIdxs.size());
553 for (
const auto &
fieldIdx : fJoinFieldIdxs) {
555 values.push_back(val);
560 const auto entryIdx = fJoinTable->GetEntryIndex(values);
563 SetAuxiliaryFieldValidity(
false);
565 SetAuxiliaryFieldValidity(
true);
566 for (
const auto &
fieldIdx : fAuxiliaryFieldIdxs) {
577 fNEntries = fPrimaryProcessor->GetNEntries();
599 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.
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.
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
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.
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.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponding to the field type ...
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
The field for an untyped record.
void AttachItemFields(ContainerT &&itemFields)
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