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), options));
40}
41
42std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
44 const RNTupleProcessorOptions &options)
45{
46 if (ntuples.empty())
47 throw RException(R__FAIL("at least one RNTuple must be provided"));
48
49 std::vector<std::unique_ptr<RNTupleProcessor>> innerProcessors;
50 innerProcessors.reserve(ntuples.size());
51
52 for (auto &ntuple : ntuples) {
53 innerProcessors.emplace_back(Create(std::move(ntuple)));
54 }
55
56 return CreateChain(std::move(innerProcessors), options);
57}
58
59std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
60ROOT::Experimental::RNTupleProcessor::CreateChain(std::vector<std::unique_ptr<RNTupleProcessor>> innerProcessors,
61 const RNTupleProcessorOptions &options)
62{
63 if (innerProcessors.empty())
64 throw RException(R__FAIL("at least one inner processor must be provided"));
65
66 return std::unique_ptr<RNTupleChainProcessor>(new RNTupleChainProcessor(std::move(innerProcessors), options));
67}
68
69std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
71 const std::vector<std::string> &joinFields,
72 const RNTupleProcessorOptions &options)
73{
74 if (joinFields.size() > 4) {
75 throw RException(R__FAIL("a maximum of four join fields is allowed"));
76 }
77
78 if (std::unordered_set(joinFields.begin(), joinFields.end()).size() < joinFields.size()) {
79 throw RException(R__FAIL("join fields must be unique"));
80 }
81
82 std::unique_ptr<RNTupleProcessor> primaryProcessor = Create(std::move(primaryNTuple), options);
83
84 std::unique_ptr<RNTupleProcessor> auxProcessor = Create(std::move(auxNTuple));
85
86 return CreateJoin(std::move(primaryProcessor), std::move(auxProcessor), joinFields, options);
87}
88
89std::unique_ptr<ROOT::Experimental::RNTupleProcessor>
91 std::unique_ptr<RNTupleProcessor> auxProcessor,
92 const std::vector<std::string> &joinFields,
93 const RNTupleProcessorOptions &options)
94{
95 if (joinFields.size() > 4) {
96 throw RException(R__FAIL("a maximum of four join fields is allowed"));
97 }
98
99 if (std::unordered_set(joinFields.begin(), joinFields.end()).size() < joinFields.size()) {
100 throw RException(R__FAIL("join fields must be unique"));
101 }
102
103 return std::unique_ptr<RNTupleJoinProcessor>(
104 new RNTupleJoinProcessor(std::move(primaryProcessor), std::move(auxProcessor), joinFields, options));
105}
106
107//------------------------------------------------------------------------------
108
117
119 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
120{
121 // The processor has already been initialized.
122 if (IsInitialized())
123 return;
124
125 if (!entry)
126 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
127 else
128 fEntry = entry;
129
130 fPageSource = fNTupleSpec.CreatePageSource();
131 fPageSource->Attach();
132
133 fNEntries = fPageSource->GetNEntries();
134}
135
137{
138 Initialize();
139 auto desc = fPageSource->GetSharedDescriptorGuard();
140 auto fieldZeroId = desc->GetFieldZeroId();
141
142 // TODO handle subfields
143 return desc->FindFieldId(fieldName, fieldZeroId) != ROOT::kInvalidDescriptorId;
144}
145
146std::unique_ptr<ROOT::RFieldBase>
148 const std::string &typeName)
149{
150 assert(fPageSource);
151
153
154 // Strip the "_join" prefix (for join fields) from the field name, if present.
155 if (onDiskFieldName.find("_join.") == 0) {
157 }
158
159 const auto &desc = fPageSource->GetSharedDescriptorGuard().GetRef();
162
163 const auto onDiskFieldId = desc.FindFieldId(onDiskFieldName);
164
166 return nullptr;
167 }
168
169 std::unique_ptr<ROOT::RFieldBase> field;
170 if (typeName.empty()) {
171 const auto &fieldDesc = desc.GetFieldDescriptor(onDiskFieldId);
172 field = fieldDesc.CreateField(desc);
173 } else {
174 // Strip the parent field name prefix(es), if present.
175 std::string subfieldName = onDiskFieldName;
176 auto posDot = onDiskFieldName.find_last_of('.');
177 if (posDot != std::string::npos)
178 subfieldName = onDiskFieldName.substr(posDot + 1);
179
180 field = ROOT::RFieldBase::Create(subfieldName, typeName).Unwrap();
181 }
182
183 field->SetOnDiskId(onDiskFieldId);
184 fieldZero.Attach(std::move(field));
186 return std::move(fieldZero.ReleaseSubfields()[0]);
187}
188
190ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
191 void *valuePtr,
193{
194 auto fieldIdx = fEntry->FindFieldIndex(fieldName, typeName);
195 if (!fieldIdx) {
196 // Strip the processor name prefix(es), if present.
197 std::string qualifiedFieldName = fieldName;
198 if (provenance.IsPresentInFieldName(qualifiedFieldName)) {
199 qualifiedFieldName = qualifiedFieldName.substr(provenance.Get().size() + 1);
200 }
201
202 auto field = CreateAndConnectField(qualifiedFieldName, typeName);
203
204 if (!field) {
205 throw RException(R__FAIL("cannot register field with name \"" + qualifiedFieldName +
206 "\" because it is not present in the on-disk information of the RNTuple(s) this "
207 "processor is created from"));
208 }
209
210 fieldIdx = fEntry->AddField(qualifiedFieldName, std::move(field), valuePtr, provenance);
211 }
212
213 return *fieldIdx;
214}
215
217{
218 if (entryNumber >= fNEntries || !fEntry)
219 return kInvalidNTupleIndex;
220
221 for (auto fieldIdx : fFieldIdxs) {
222 fEntry->ReadValue(fieldIdx, entryNumber);
223 }
224
225 fNEntriesProcessed++;
226 fCurrentEntryNumber = entryNumber;
227 return entryNumber;
228}
229
231 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
232 const Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields)
233{
234 Initialize();
235
236 fFieldIdxs = fieldIdxs;
237
238 if (updateFields) {
239 for (const auto &fieldIdx : fFieldIdxs) {
240 const auto &currField = fEntry->GetValue(fieldIdx).GetField();
241 auto newField = CreateAndConnectField(fEntry->GetQualifiedFieldName(fieldIdx), currField.GetTypeName());
242
243 fEntry->UpdateField(fieldIdx, std::move(newField));
244 }
245 }
246}
247
254
256{
257 static constexpr int width = 32;
258
259 std::string ntupleNameTrunc = fNTupleSpec.fNTupleName.substr(0, width - 4);
260 if (ntupleNameTrunc.size() < fNTupleSpec.fNTupleName.size())
261 ntupleNameTrunc = fNTupleSpec.fNTupleName.substr(0, width - 6) + "..";
262
263 output << "+" << std::setfill('-') << std::setw(width - 1) << "+\n";
264 output << std::setfill(' ') << "| " << ntupleNameTrunc << std::setw(width - 2 - ntupleNameTrunc.size()) << " |\n";
265
266 if (const std::string *storage = std::get_if<std::string>(&fNTupleSpec.fStorage)) {
267 std::string storageTrunc = storage->substr(0, width - 5);
268 if (storageTrunc.size() < storage->size())
269 storageTrunc = storage->substr(0, width - 8) + "...";
270
271 output << std::setfill(' ') << "| " << storageTrunc << std::setw(width - 2 - storageTrunc.size()) << " |\n";
272 } else {
273 output << "| " << std::setw(width - 2) << " |\n";
274 }
275
276 output << "+" << std::setfill('-') << std::setw(width - 1) << "+\n";
277}
278
279//------------------------------------------------------------------------------
280
282 std::vector<std::unique_ptr<RNTupleProcessor>> processors, const RNTupleProcessorOptions &options)
283 : RNTupleProcessor(options), fInnerProcessors(std::move(processors))
284{
285 if (fOptions.GetProcessorName().empty()) {
286 // `CreateChain` ensures there is at least one inner processor.
288 }
289
291}
292
294 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
295{
296 if (IsInitialized())
297 return;
298
299 if (!entry)
300 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
301 else
302 fEntry = entry;
303
304 fInnerProcessors[0]->Initialize(fEntry);
305}
306
308{
309 if (fNEntries == kInvalidNTupleIndex) {
310 fNEntries = 0;
311
312 for (unsigned i = 0; i < fInnerProcessors.size(); ++i) {
313 if (fInnerNEntries[i] == kInvalidNTupleIndex) {
314 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
315 }
316
317 fNEntries += fInnerNEntries[i];
318 }
319 }
320
321 return fNEntries;
322}
323
325 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
326 const Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */)
327{
328 Initialize();
329 fFieldIdxs = fieldIdxs;
330 fProvenance = provenance;
331 ConnectInnerProcessor(fCurrentProcessorNumber);
332}
333
335{
336 auto &innerProc = fInnerProcessors[processorNumber];
337 innerProc->Initialize(fEntry);
338 innerProc->Connect(fFieldIdxs, fProvenance, /*updateFields=*/true);
339}
340
342ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
343 void *valuePtr,
345{
346 return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(fieldName, typeName, valuePtr, provenance);
347}
348
350{
351 // If the requested entry number is lower than the current entry number, we have to again localise the correct local
352 // entry number starting from the first processor in the chain. Otherwise, we can continue looking from the inner
353 // processor that is currently connected, which is much faster when the chain consists of many inner processors.
354 if (entryNumber < fCurrentEntryNumber) {
355 fCurrentProcessorNumber = 0;
356 ConnectInnerProcessor(fCurrentProcessorNumber);
357 }
358
359 std::size_t currProcessorNumber = fCurrentProcessorNumber;
361 for (unsigned i = 0; i < currProcessorNumber; ++i) {
362 if (fInnerNEntries[i] == kInvalidNTupleIndex) {
363 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
364 }
365 entriesSeen += fInnerNEntries[i];
366 }
368
369 // As long as the entry fails to load from the current processor, we decrement the local entry number with the number
370 // of entries in this processor and try with the next processor until we find the correct local entry number.
371 while (fInnerProcessors[currProcessorNumber]->LoadEntry(localEntryNumber) == kInvalidNTupleIndex) {
372 if (fInnerNEntries[currProcessorNumber] == kInvalidNTupleIndex) {
373 fInnerNEntries[currProcessorNumber] = fInnerProcessors[currProcessorNumber]->GetNEntries();
374 }
375
376 localEntryNumber -= fInnerNEntries[currProcessorNumber];
377
378 // The provided global entry number is larger than the number of available entries.
379 if (++currProcessorNumber >= fInnerProcessors.size())
380 return kInvalidNTupleIndex;
381
382 ConnectInnerProcessor(currProcessorNumber);
383 }
384
385 fCurrentProcessorNumber = currProcessorNumber;
386 fNEntriesProcessed++;
387 fCurrentEntryNumber = entryNumber;
388 return entryNumber;
389}
390
393{
394 for (unsigned i = 0; i < fInnerProcessors.size(); ++i) {
395 const auto &innerProc = fInnerProcessors[i];
396 // TODO can this be done (more) lazily? I.e. only when a match cannot be found in the current inner proc?
397 innerProc->Initialize(fEntry);
398 innerProc->AddEntriesToJoinTable(joinTable, entryOffset);
399 entryOffset += innerProc->GetNEntries();
400 }
401}
402
404{
405 for (const auto &innerProc : fInnerProcessors) {
406 innerProc->PrintStructure(output);
407 }
408}
409
410//------------------------------------------------------------------------------
411
413 std::unique_ptr<RNTupleProcessor> auxProcessor,
414 const std::vector<std::string> &joinFields,
415 const RNTupleProcessorOptions &options)
416 : RNTupleProcessor(options),
417 fPrimaryProcessor(std::move(primaryProcessor)),
418 fAuxiliaryProcessor(std::move(auxProcessor)),
419 fJoinFieldNames(joinFields)
420{
421 if (fOptions.GetProcessorName().empty()) {
422 fOptions.SetProcessorName(fPrimaryProcessor->fOptions.GetProcessorName());
423 }
424}
425
427 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
428{
429 if (IsInitialized())
430 return;
431
432 if (!entry)
433 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
434 else
435 fEntry = entry;
436
437 fPrimaryProcessor->Initialize(fEntry);
438 fAuxiliaryProcessor->Initialize(fEntry);
439
440 if (!fJoinFieldNames.empty()) {
441 for (const auto &joinField : fJoinFieldNames) {
442 if (!fPrimaryProcessor->CanReadFieldFromDisk(joinField)) {
443 throw RException(R__FAIL("could not find join field \"" + joinField + "\" in primary processor \"" +
444 fPrimaryProcessor->fOptions.GetProcessorName() + "\""));
445 }
446 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(joinField)) {
447 throw RException(R__FAIL("could not find join field \"" + joinField + "\" in auxiliary processor \"" +
448 fAuxiliaryProcessor->fOptions.GetProcessorName() + "\""));
449 }
450
451 // We prepend the name of the primary processor in this case to prevent reading from the wrong join field in
452 // composed join operations.
453 auto fieldIdx = AddFieldToEntry(fOptions.GetProcessorName() + "._join." + joinField, "std::uint64_t", nullptr,
454 Internal::RNTupleProcessorProvenance(fOptions.GetProcessorName()));
455 fJoinFieldIdxs.insert(fieldIdx);
456 }
457
458 fJoinTable = Internal::RNTupleJoinTable::Create(fJoinFieldNames);
459 }
460}
461
463 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
465{
466 Initialize();
467
468 auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->fOptions.GetProcessorName());
469 for (const auto &fieldIdx : fieldIdxs) {
470 const auto &fieldProvenance = fEntry->GetFieldProvenance(fieldIdx);
471 if (fieldProvenance.Contains(auxProvenance))
472 fAuxiliaryFieldIdxs.insert(fieldIdx);
473 else
474 fFieldIdxs.insert(fieldIdx);
475 }
476
477 fPrimaryProcessor->Connect(fFieldIdxs, provenance, updateFields);
478 fAuxiliaryProcessor->Connect(fAuxiliaryFieldIdxs, auxProvenance, updateFields);
479}
480
482ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
483 void *valuePtr,
485{
486 auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->fOptions.GetProcessorName());
487 if (auxProvenance.IsPresentInFieldName(fieldName)) {
488 // If the primaryProcessor has a field with the name of the auxProcessor (either as a "proper" field or because
489 // the primary processor itself is a join where its auxProcessor bears the same name as the current auxProcessor),
490 // there will be name conflicts, so error out.
491 if (fPrimaryProcessor->CanReadFieldFromDisk(fieldName)) {
492 throw RException(R__FAIL("ambiguous field name: \"" + fieldName +
493 "\" is present in the primary RNTupleProcessor \"" +
494 fPrimaryProcessor->fOptions.GetProcessorName() +
495 "\", but may also refer to a field in the auxiliary RNTupleProcessor named \"" +
496 fAuxiliaryProcessor->fOptions.GetProcessorName() +
497 "\". To avoid this ambiguity, rename the auxiliary RNTupleProcessor."));
498 }
499
500 auto fieldIdx = fAuxiliaryProcessor->AddFieldToEntry(fieldName, typeName, valuePtr, auxProvenance);
501 if (fieldIdx)
502 fAuxiliaryFieldIdxs.insert(fieldIdx);
503 return fieldIdx;
504 } else {
505 auto fieldIdx = fPrimaryProcessor->AddFieldToEntry(fieldName, typeName, valuePtr, provenance);
506 if (fieldIdx)
507 fFieldIdxs.insert(fieldIdx);
508 return fieldIdx;
509 }
510}
511
513{
514 for (const auto &fieldIdx : fAuxiliaryFieldIdxs) {
515 fEntry->SetFieldValidity(fieldIdx, isValid);
516 }
517}
518
520{
521 if (fPrimaryProcessor->LoadEntry(entryNumber) == kInvalidNTupleIndex) {
522 for (auto fieldIdx : fFieldIdxs) {
523 fEntry->SetFieldValidity(fieldIdx, false);
524 }
525 SetAuxiliaryFieldValidity(false);
526 return kInvalidNTupleIndex;
527 }
528
529 fCurrentEntryNumber = entryNumber;
530 fNEntriesProcessed++;
531
532 if (!fJoinTable) {
533 // The auxiliary processor's fields are valid if the entry could be loaded.
534 fAuxiliaryProcessor->LoadEntry(entryNumber);
535 return entryNumber;
536 }
537
538 if (!fJoinTableIsBuilt) {
539 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
540 fJoinTableIsBuilt = true;
541 }
542
543 // Collect the values of the join fields for this entry.
544 std::vector<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t> values;
545 values.reserve(fJoinFieldIdxs.size());
546 for (const auto &fieldIdx : fJoinFieldIdxs) {
547 auto val = fEntry->GetValue(fieldIdx).GetRef<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t>();
548 values.push_back(val);
549 }
550
551 // Find the entry index corresponding to the join field values for each auxiliary processor and load the
552 // corresponding entry.
553 const auto entryIdx = fJoinTable->GetEntryIndex(values);
554
556 SetAuxiliaryFieldValidity(false);
557 } else {
558 SetAuxiliaryFieldValidity(true);
559 fAuxiliaryProcessor->LoadEntry(entryIdx);
560 }
561
562 return entryNumber;
563}
564
566{
567 if (fNEntries == kInvalidNTupleIndex)
568 fNEntries = fPrimaryProcessor->GetNEntries();
569 return fNEntries;
570}
571
577
579{
580 std::ostringstream primaryStructureStr;
581 fPrimaryProcessor->PrintStructure(primaryStructureStr);
582 const auto primaryStructure = ROOT::Split(primaryStructureStr.str(), "\n", /*skipEmpty=*/true);
583 const auto primaryStructureWidth = primaryStructure.front().size();
584
585 std::ostringstream auxStructureStr;
586 fAuxiliaryProcessor->PrintStructure(auxStructureStr);
587 const auto auxStructure = ROOT::Split(auxStructureStr.str(), "\n", /*skipEmpty=*/true);
588
589 const auto maxLength = std::max(primaryStructure.size(), auxStructure.size());
590 for (unsigned i = 0; i < maxLength; i++) {
591 if (i < primaryStructure.size())
592 output << primaryStructure[i];
593 else
594 output << std::setw(primaryStructureWidth) << "";
595
596 if (i < auxStructure.size())
597 output << " " << auxStructure[i];
598
599 output << "\n";
600 }
601}
#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 > CreateChain(std::vector< RNTupleOpenSpec > ntuples, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.
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.
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().
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