Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleProcessor.cxx
Go to the documentation of this file.
1/// \file RNTupleProcessor.cxx
2/// \author Florine de Geus <florine.de.geus@cern.ch>
3/// \date 2024-03-26
4/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
5/// is welcome!
6
7/*************************************************************************
8 * Copyright (C) 1995-2024, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
16
17#include <ROOT/RFieldBase.hxx>
18#include <ROOT/RNTuple.hxx>
20#include <ROOT/StringUtils.hxx>
21
22#include <TDirectory.h>
23
24#include <iomanip>
25
26std::unique_ptr<ROOT::Internal::RPageSource> ROOT::Experimental::RNTupleOpenSpec::CreatePageSource() const
27{
28 if (const std::string *storagePath = std::get_if<std::string>(&fStorage))
30
31 auto dir = std::get<TDirectory *>(fStorage);
32 auto ntuple = std::unique_ptr<ROOT::RNTuple>(dir->Get<ROOT::RNTuple>(fNTupleName.c_str()));
34}
35
36std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
38{
39 return std::unique_ptr<RNTupleSingleProcessor>(new RNTupleSingleProcessor(std::move(ntuple), processorName));
40}
41
42std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
43ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector<RNTupleOpenSpec> ntuples, std::string_view processorName)
44{
45 if (ntuples.empty())
46 throw RException(R__FAIL("at least one RNTuple must be provided"));
47
48 std::vector<std::unique_ptr<RNTupleProcessor>> innerProcessors;
49 innerProcessors.reserve(ntuples.size());
50
51 for (auto &ntuple : ntuples) {
52 innerProcessors.emplace_back(Create(std::move(ntuple)));
53 }
54
55 return CreateChain(std::move(innerProcessors), processorName);
56}
57
58std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
59ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector<std::unique_ptr<RNTupleProcessor>> innerProcessors,
60 std::string_view processorName)
61{
62 if (innerProcessors.empty())
63 throw RException(R__FAIL("at least one inner processor must be provided"));
64
65 return std::unique_ptr<RNTupleChainProcessor>(new RNTupleChainProcessor(std::move(innerProcessors), processorName));
66}
67
68std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
70 const std::vector<std::string> &joinFields,
71 std::string_view processorName)
72{
73 if (joinFields.size() > 4) {
74 throw RException(R__FAIL("a maximum of four join fields is allowed"));
75 }
76
77 if (std::unordered_set(joinFields.begin(), joinFields.end()).size() < joinFields.size()) {
78 throw RException(R__FAIL("join fields must be unique"));
79 }
80
81 std::unique_ptr<RNTupleProcessor> primaryProcessor = Create(std::move(primaryNTuple), processorName);
82
83 std::unique_ptr<RNTupleProcessor> auxProcessor = Create(std::move(auxNTuple));
84
85 return CreateJoin(std::move(primaryProcessor), std::move(auxProcessor), joinFields, processorName);
86}
87
88std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
90 std::unique_ptr<RNTupleProcessor> auxProcessor,
91 const std::vector<std::string> &joinFields,
92 std::string_view processorName)
93{
94 if (joinFields.size() > 4) {
95 throw RException(R__FAIL("a maximum of four join fields is allowed"));
96 }
97
98 if (std::unordered_set(joinFields.begin(), joinFields.end()).size() < joinFields.size()) {
99 throw RException(R__FAIL("join fields must be unique"));
100 }
101
102 return std::unique_ptr<RNTupleJoinProcessor>(
104}
105
106//------------------------------------------------------------------------------
107
116
118 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
119{
120 // The processor has already been initialized.
121 if (IsInitialized())
122 return;
123
124 if (!entry)
125 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
126 else
127 fEntry = entry;
128
129 fPageSource = fNTupleSpec.CreatePageSource();
130 fPageSource->Attach();
131
132 fNEntries = fPageSource->GetNEntries();
133}
134
136{
137 Initialize();
138 auto desc = fPageSource->GetSharedDescriptorGuard();
139 auto fieldZeroId = desc->GetFieldZeroId();
140
141 // TODO handle subfields
142 return desc->FindFieldId(fieldName, fieldZeroId) != ROOT::kInvalidDescriptorId;
143}
144
145std::unique_ptr<ROOT::RFieldBase>
147 const std::string &typeName)
148{
149 assert(fPageSource);
150
152
153 // Strip the "_join" prefix (for join fields) from the field name, if present.
154 if (onDiskFieldName.find("_join.") == 0) {
156 }
157
158 const auto &desc = fPageSource->GetSharedDescriptorGuard().GetRef();
161
162 const auto onDiskFieldId = desc.FindFieldId(onDiskFieldName);
163
165 return nullptr;
166 }
167
168 std::unique_ptr<ROOT::RFieldBase> field;
169 if (typeName.empty()) {
170 const auto &fieldDesc = desc.GetFieldDescriptor(onDiskFieldId);
171 field = fieldDesc.CreateField(desc);
172 } else {
173 // Strip the parent field name prefix(es), if present.
174 std::string subfieldName = onDiskFieldName;
175 auto posDot = onDiskFieldName.find_last_of('.');
176 if (posDot != std::string::npos)
177 subfieldName = onDiskFieldName.substr(posDot + 1);
178
179 field = ROOT::RFieldBase::Create(subfieldName, typeName).Unwrap();
180 }
181
182 field->SetOnDiskId(onDiskFieldId);
183 fieldZero.Attach(std::move(field));
185 return std::move(fieldZero.ReleaseSubfields()[0]);
186}
187
189ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
190 void *valuePtr,
192{
193 auto fieldIdx = fEntry->FindFieldIndex(fieldName, typeName);
194 if (!fieldIdx) {
195 // Strip the processor name prefix(es), if present.
196 std::string qualifiedFieldName = fieldName;
197 if (provenance.IsPresentInFieldName(qualifiedFieldName)) {
198 qualifiedFieldName = qualifiedFieldName.substr(provenance.Get().size() + 1);
199 }
200
201 auto field = CreateAndConnectField(qualifiedFieldName, typeName);
202
203 if (!field) {
204 throw RException(R__FAIL("cannot register field with name \"" + qualifiedFieldName +
205 "\" because it is not present in the on-disk information of the RNTuple(s) this "
206 "processor is created from"));
207 }
208
209 fieldIdx = fEntry->AddField(qualifiedFieldName, std::move(field), valuePtr, provenance);
210 }
211
212 return *fieldIdx;
213}
214
216{
217 if (entryNumber >= fNEntries || !fEntry)
218 return kInvalidNTupleIndex;
219
220 for (auto fieldIdx : fFieldIdxs) {
221 fEntry->ReadValue(fieldIdx, entryNumber);
222 }
223
224 fNEntriesProcessed++;
225 fCurrentEntryNumber = entryNumber;
226 return entryNumber;
227}
228
230 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
231 const Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields)
232{
233 Initialize();
234
235 fFieldIdxs = fieldIdxs;
236
237 if (updateFields) {
238 for (const auto &fieldIdx : fFieldIdxs) {
239 const auto &currField = fEntry->GetValue(fieldIdx).GetField();
240 auto newField = CreateAndConnectField(fEntry->GetQualifiedFieldName(fieldIdx), currField.GetTypeName());
241
242 fEntry->UpdateField(fieldIdx, std::move(newField));
243 }
244 }
245}
246
253
255{
256 static constexpr int width = 32;
257
258 std::string ntupleNameTrunc = fNTupleSpec.fNTupleName.substr(0, width - 4);
259 if (ntupleNameTrunc.size() < fNTupleSpec.fNTupleName.size())
260 ntupleNameTrunc = fNTupleSpec.fNTupleName.substr(0, width - 6) + "..";
261
262 output << "+" << std::setfill('-') << std::setw(width - 1) << "+\n";
263 output << std::setfill(' ') << "| " << ntupleNameTrunc << std::setw(width - 2 - ntupleNameTrunc.size()) << " |\n";
264
265 if (const std::string *storage = std::get_if<std::string>(&fNTupleSpec.fStorage)) {
266 std::string storageTrunc = storage->substr(0, width - 5);
267 if (storageTrunc.size() < storage->size())
268 storageTrunc = storage->substr(0, width - 8) + "...";
269
270 output << std::setfill(' ') << "| " << storageTrunc << std::setw(width - 2 - storageTrunc.size()) << " |\n";
271 } else {
272 output << "| " << std::setw(width - 2) << " |\n";
273 }
274
275 output << "+" << std::setfill('-') << std::setw(width - 1) << "+\n";
276}
277
278//------------------------------------------------------------------------------
279
281 std::vector<std::unique_ptr<RNTupleProcessor>> processors, std::string_view processorName)
282 : RNTupleProcessor(processorName), fInnerProcessors(std::move(processors))
283{
284 if (fProcessorName.empty()) {
285 // `CreateChain` ensures there is at least one inner processor.
286 fProcessorName = fInnerProcessors[0]->GetProcessorName();
287 }
288
290}
291
293 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
294{
295 if (IsInitialized())
296 return;
297
298 if (!entry)
299 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
300 else
301 fEntry = entry;
302
303 fInnerProcessors[0]->Initialize(fEntry);
304}
305
307{
308 if (fNEntries == kInvalidNTupleIndex) {
309 fNEntries = 0;
310
311 for (unsigned i = 0; i < fInnerProcessors.size(); ++i) {
312 if (fInnerNEntries[i] == kInvalidNTupleIndex) {
313 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
314 }
315
316 fNEntries += fInnerNEntries[i];
317 }
318 }
319
320 return fNEntries;
321}
322
324 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
325 const Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */)
326{
327 Initialize();
328 fFieldIdxs = fieldIdxs;
329 fProvenance = provenance;
330 ConnectInnerProcessor(fCurrentProcessorNumber);
331}
332
334{
335 auto &innerProc = fInnerProcessors[processorNumber];
336 innerProc->Initialize(fEntry);
337 innerProc->Connect(fFieldIdxs, fProvenance, /*updateFields=*/true);
338}
339
341ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
342 void *valuePtr,
344{
345 return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(fieldName, typeName, valuePtr, provenance);
346}
347
349{
350 // If the requested entry number is lower than the current entry number, we have to again localise the correct local
351 // entry number starting from the first processor in the chain. Otherwise, we can continue looking from the inner
352 // processor that is currently connected, which is much faster when the chain consists of many inner processors.
353 if (entryNumber < fCurrentEntryNumber) {
354 fCurrentProcessorNumber = 0;
355 ConnectInnerProcessor(fCurrentProcessorNumber);
356 }
357
358 std::size_t currProcessorNumber = fCurrentProcessorNumber;
360 for (unsigned i = 0; i < currProcessorNumber; ++i) {
361 if (fInnerNEntries[i] == kInvalidNTupleIndex) {
362 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
363 }
364 entriesSeen += fInnerNEntries[i];
365 }
367
368 // As long as the entry fails to load from the current processor, we decrement the local entry number with the number
369 // of entries in this processor and try with the next processor until we find the correct local entry number.
370 while (fInnerProcessors[currProcessorNumber]->LoadEntry(localEntryNumber) == kInvalidNTupleIndex) {
371 if (fInnerNEntries[currProcessorNumber] == kInvalidNTupleIndex) {
372 fInnerNEntries[currProcessorNumber] = fInnerProcessors[currProcessorNumber]->GetNEntries();
373 }
374
375 localEntryNumber -= fInnerNEntries[currProcessorNumber];
376
377 // The provided global entry number is larger than the number of available entries.
378 if (++currProcessorNumber >= fInnerProcessors.size())
379 return kInvalidNTupleIndex;
380
381 ConnectInnerProcessor(currProcessorNumber);
382 }
383
384 fCurrentProcessorNumber = currProcessorNumber;
385 fNEntriesProcessed++;
386 fCurrentEntryNumber = entryNumber;
387 return entryNumber;
388}
389
392{
393 for (unsigned i = 0; i < fInnerProcessors.size(); ++i) {
394 const auto &innerProc = fInnerProcessors[i];
395 // TODO can this be done (more) lazily? I.e. only when a match cannot be found in the current inner proc?
396 innerProc->Initialize(fEntry);
397 innerProc->AddEntriesToJoinTable(joinTable, entryOffset);
398 entryOffset += innerProc->GetNEntries();
399 }
400}
401
403{
404 for (const auto &innerProc : fInnerProcessors) {
405 innerProc->PrintStructure(output);
406 }
407}
408
409//------------------------------------------------------------------------------
410
412 std::unique_ptr<RNTupleProcessor> auxProcessor,
413 const std::vector<std::string> &joinFields,
414 std::string_view processorName)
416 fPrimaryProcessor(std::move(primaryProcessor)),
417 fAuxiliaryProcessor(std::move(auxProcessor)),
418 fJoinFieldNames(joinFields)
419{
420 if (fProcessorName.empty()) {
421 fProcessorName = fPrimaryProcessor->GetProcessorName();
422 }
423}
424
426 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
427{
428 if (IsInitialized())
429 return;
430
431 if (!entry)
432 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
433 else
434 fEntry = entry;
435
436 fPrimaryProcessor->Initialize(fEntry);
437 fAuxiliaryProcessor->Initialize(fEntry);
438
439 if (!fJoinFieldNames.empty()) {
440 for (const auto &joinField : fJoinFieldNames) {
441 if (!fPrimaryProcessor->CanReadFieldFromDisk(joinField)) {
442 throw RException(R__FAIL("could not find join field \"" + joinField + "\" in primary processor \"" +
443 fPrimaryProcessor->GetProcessorName() + "\""));
444 }
445 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(joinField)) {
446 throw RException(R__FAIL("could not find join field \"" + joinField + "\" in auxiliary processor \"" +
447 fAuxiliaryProcessor->GetProcessorName() + "\""));
448 }
449
450 // We prepend the name of the primary processor in this case to prevent reading from the wrong join field in
451 // composed join operations.
452 auto fieldIdx = AddFieldToEntry(fProcessorName + "._join." + joinField, "std::uint64_t", nullptr,
454 fJoinFieldIdxs.insert(fieldIdx);
455 }
456
457 fJoinTable = Internal::RNTupleJoinTable::Create(fJoinFieldNames);
458 }
459}
460
462 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
464{
465 Initialize();
466
467 auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->GetProcessorName());
468 for (const auto &fieldIdx : fieldIdxs) {
469 const auto &fieldProvenance = fEntry->GetFieldProvenance(fieldIdx);
470 if (fieldProvenance.Contains(auxProvenance))
471 fAuxiliaryFieldIdxs.insert(fieldIdx);
472 else
473 fFieldIdxs.insert(fieldIdx);
474 }
475
476 fPrimaryProcessor->Connect(fFieldIdxs, provenance, updateFields);
477 fAuxiliaryProcessor->Connect(fAuxiliaryFieldIdxs, auxProvenance, updateFields);
478}
479
481ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
482 void *valuePtr,
484{
485 auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->GetProcessorName());
486 if (auxProvenance.IsPresentInFieldName(fieldName)) {
487 // If the primaryProcessor has a field with the name of the auxProcessor (either as a "proper" field or because
488 // the primary processor itself is a join where its auxProcessor bears the same name as the current auxProcessor),
489 // there will be name conflicts, so error out.
490 if (fPrimaryProcessor->CanReadFieldFromDisk(fieldName)) {
491 throw RException(R__FAIL("ambiguous field name: \"" + fieldName +
492 "\" is present in the primary RNTupleProcessor \"" +
493 fPrimaryProcessor->GetProcessorName() +
494 "\", but may also refer to a field in the auxiliary RNTupleProcessor named \"" +
495 fAuxiliaryProcessor->GetProcessorName() +
496 "\". To avoid this ambiguity, rename the auxiliary RNTupleProcessor."));
497 }
498
499 auto fieldIdx = fAuxiliaryProcessor->AddFieldToEntry(fieldName, typeName, valuePtr, auxProvenance);
500 if (fieldIdx)
501 fAuxiliaryFieldIdxs.insert(fieldIdx);
502 return fieldIdx;
503 } else {
504 auto fieldIdx = fPrimaryProcessor->AddFieldToEntry(fieldName, typeName, valuePtr, provenance);
505 if (fieldIdx)
506 fFieldIdxs.insert(fieldIdx);
507 return fieldIdx;
508 }
509}
510
512{
513 for (const auto &fieldIdx : fAuxiliaryFieldIdxs) {
514 fEntry->SetFieldValidity(fieldIdx, isValid);
515 }
516}
517
519{
520 if (fPrimaryProcessor->LoadEntry(entryNumber) == kInvalidNTupleIndex) {
521 for (auto fieldIdx : fFieldIdxs) {
522 fEntry->SetFieldValidity(fieldIdx, false);
523 }
524 SetAuxiliaryFieldValidity(false);
525 return kInvalidNTupleIndex;
526 }
527
528 fCurrentEntryNumber = entryNumber;
529 fNEntriesProcessed++;
530
531 if (!fJoinTable) {
532 // The auxiliary processor's fields are valid if the entry could be loaded.
533 fAuxiliaryProcessor->LoadEntry(entryNumber);
534 return entryNumber;
535 }
536
537 if (!fJoinTableIsBuilt) {
538 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
539 fJoinTableIsBuilt = true;
540 }
541
542 // Collect the values of the join fields for this entry.
543 std::vector<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t> values;
544 values.reserve(fJoinFieldIdxs.size());
545 for (const auto &fieldIdx : fJoinFieldIdxs) {
546 auto val = fEntry->GetValue(fieldIdx).GetRef<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t>();
547 values.push_back(val);
548 }
549
550 // Find the entry index corresponding to the join field values for each auxiliary processor and load the
551 // corresponding entry.
552 const auto entryIdx = fJoinTable->GetEntryIndex(values);
553
555 SetAuxiliaryFieldValidity(false);
556 } else {
557 SetAuxiliaryFieldValidity(true);
558 fAuxiliaryProcessor->LoadEntry(entryIdx);
559 }
560
561 return entryNumber;
562}
563
565{
566 if (fNEntries == kInvalidNTupleIndex)
567 fNEntries = fPrimaryProcessor->GetNEntries();
568 return fNEntries;
569}
570
576
578{
579 std::ostringstream primaryStructureStr;
580 fPrimaryProcessor->PrintStructure(primaryStructureStr);
581 const auto primaryStructure = ROOT::Split(primaryStructureStr.str(), "\n", /*skipEmpty=*/true);
582 const auto primaryStructureWidth = primaryStructure.front().size();
583
584 std::ostringstream auxStructureStr;
585 fAuxiliaryProcessor->PrintStructure(auxStructureStr);
586 const auto auxStructure = ROOT::Split(auxStructureStr.str(), "\n", /*skipEmpty=*/true);
587
588 const auto maxLength = std::max(primaryStructure.size(), auxStructure.size());
589 for (unsigned i = 0; i < maxLength; i++) {
590 if (i < primaryStructure.size())
591 output << primaryStructure[i];
592 else
593 output << std::setw(primaryStructureWidth) << "";
594
595 if (i < auxStructure.size())
596 output << " " << auxStructure[i];
597
598 output << "\n";
599 }
600}
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:322
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t width
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.
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.
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.
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().
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.
Definition RError.hxx:78
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.
Definition RField.hxx:58
Representation of an RNTuple data set in a ROOT file.
Definition RNTuple.hxx:67
const_iterator begin() const
const_iterator end() const
void SetAllowFieldSubstitutions(RFieldZero &fieldZero, bool val)
Definition RField.cxx:35
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