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 = std::move(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
152 // Strip the "R_rntproc_join_" prefix (for join fields) from the field name, if present.
153 const std::string onDiskFieldName =
154 qualifiedFieldName.find("R_rntproc_join_") == 0 ? qualifiedFieldName.substr(15) : qualifiedFieldName;
155
156 auto descGuard = fPageSource->GetSharedDescriptorGuard();
157 const auto &desc = descGuard.GetRef();
160
161 const auto onDiskFieldId = desc.FindFieldId(onDiskFieldName);
162
164 return nullptr;
165 }
166
167 std::unique_ptr<ROOT::RFieldBase> field;
168 if (typeName.empty()) {
169 const auto &fieldDesc = desc.GetFieldDescriptor(onDiskFieldId);
170 field = fieldDesc.CreateField(desc);
171 } else {
172 // Strip the parent field name prefix(es), if present.
173 std::string subfieldName = onDiskFieldName;
174 auto posDot = onDiskFieldName.find_last_of('.');
175 if (posDot != std::string::npos)
176 subfieldName = onDiskFieldName.substr(posDot + 1);
177
178 field = ROOT::RFieldBase::Create(subfieldName, typeName).Unwrap();
179 }
180
181 field->SetOnDiskId(onDiskFieldId);
182 fieldZero.Attach(std::move(field));
184 return std::move(fieldZero.ReleaseSubfields()[0]);
185}
186
188ROOT::Experimental::RNTupleSingleProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
189 void *valuePtr,
191{
192 auto fieldIdx = fEntry->FindFieldIndex(fieldName, typeName);
193 if (!fieldIdx) {
194 // Strip the processor name prefix(es), if present.
195 std::string qualifiedFieldName = fieldName;
196 if (provenance.IsPresentInFieldName(qualifiedFieldName)) {
197 qualifiedFieldName = qualifiedFieldName.substr(provenance.Get().size() + 1);
198 }
199
200 auto field = CreateAndConnectField(qualifiedFieldName, typeName);
201
202 if (!field) {
203 throw RException(R__FAIL("cannot register field with name \"" + qualifiedFieldName +
204 "\" because it is not present in the on-disk information of the RNTuple(s) this "
205 "processor is created from"));
206 }
207
208 fieldIdx = fEntry->AddField(qualifiedFieldName, std::move(field), valuePtr, provenance);
209 }
210
211 return *fieldIdx;
212}
213
215{
216 if (entryNumber >= fNEntries || !fEntry)
217 return kInvalidNTupleIndex;
218
219 for (auto fieldIdx : fFieldIdxs) {
220 fEntry->ReadValue(fieldIdx, entryNumber);
221 }
222
223 fNEntriesProcessed++;
224 return entryNumber;
225}
226
228 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
229 const Internal::RNTupleProcessorProvenance & /* provenance */, bool updateFields)
230{
231 Initialize();
232
233 fFieldIdxs = fieldIdxs;
234
235 if (updateFields) {
236 for (const auto &fieldIdx : fFieldIdxs) {
237 const auto &currField = fEntry->GetValue(fieldIdx).GetField();
238 auto newField = CreateAndConnectField(fEntry->GetQualifiedFieldName(fieldIdx), currField.GetTypeName());
239
240 fEntry->UpdateField(fieldIdx, std::move(newField));
241 }
242 }
243}
244
251
253{
254 static constexpr int width = 32;
255
256 std::string ntupleNameTrunc = fNTupleSpec.fNTupleName.substr(0, width - 4);
257 if (ntupleNameTrunc.size() < fNTupleSpec.fNTupleName.size())
258 ntupleNameTrunc = fNTupleSpec.fNTupleName.substr(0, width - 6) + "..";
259
260 output << "+" << std::setfill('-') << std::setw(width - 1) << "+\n";
261 output << std::setfill(' ') << "| " << ntupleNameTrunc << std::setw(width - 2 - ntupleNameTrunc.size()) << " |\n";
262
263 if (const std::string *storage = std::get_if<std::string>(&fNTupleSpec.fStorage)) {
264 std::string storageTrunc = storage->substr(0, width - 5);
265 if (storageTrunc.size() < storage->size())
266 storageTrunc = storage->substr(0, width - 8) + "...";
267
268 output << std::setfill(' ') << "| " << storageTrunc << std::setw(width - 2 - storageTrunc.size()) << " |\n";
269 } else {
270 output << "| " << std::setw(width - 2) << " |\n";
271 }
272
273 output << "+" << std::setfill('-') << std::setw(width - 1) << "+\n";
274}
275
276//------------------------------------------------------------------------------
277
279 std::vector<std::unique_ptr<RNTupleProcessor>> processors, const RNTupleProcessorOptions &options)
280 : RNTupleProcessor(options), fInnerProcessors(std::move(processors))
281{
282 if (fOptions.GetProcessorName().empty()) {
283 // `CreateChain` ensures there is at least one inner processor.
285 }
286
288}
289
291 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
292{
293 if (IsInitialized())
294 return;
295
296 if (!entry)
297 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
298 else
299 fEntry = std::move(entry);
300
301 fInnerProcessors[0]->Initialize(fEntry);
302}
303
305{
306 if (fNEntries == kInvalidNTupleIndex) {
307 fNEntries = 0;
308
309 for (unsigned i = 0; i < fInnerProcessors.size(); ++i) {
310 if (fInnerNEntries[i] == kInvalidNTupleIndex) {
311 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
312 }
313
314 fNEntries += fInnerNEntries[i];
315 }
316 }
317
318 return fNEntries;
319}
320
322 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
323 const Internal::RNTupleProcessorProvenance &provenance, bool /* updateFields */)
324{
325 Initialize();
326 fFieldIdxs = fieldIdxs;
327 fProvenance = provenance;
328 ConnectInnerProcessor(fCurrentProcessorNumber);
329}
330
332{
333 auto &innerProc = fInnerProcessors[processorNumber];
334 innerProc->Initialize(fEntry);
335 innerProc->Connect(fFieldIdxs, fProvenance, /*updateFields=*/true);
336}
337
339ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
340 void *valuePtr,
342{
343 return fInnerProcessors[fCurrentProcessorNumber]->AddFieldToEntry(fieldName, typeName, valuePtr, provenance);
344}
345
347{
348 // If the requested entry number is lower than the current entry number, we have to again localise the correct local
349 // entry number starting from the first processor in the chain. Otherwise, we can continue looking from the inner
350 // processor that is currently connected, which is much faster when the chain consists of many inner processors.
351 if (entryNumber < fLastLoadedEntry) {
352 fCurrentProcessorNumber = 0;
353 ConnectInnerProcessor(fCurrentProcessorNumber);
354 }
355
356 std::size_t currProcessorNumber = fCurrentProcessorNumber;
358 for (unsigned i = 0; i < currProcessorNumber; ++i) {
359 if (fInnerNEntries[i] == kInvalidNTupleIndex) {
360 fInnerNEntries[i] = fInnerProcessors[i]->GetNEntries();
361 }
362 entriesSeen += fInnerNEntries[i];
363 }
365
366 // As long as the entry fails to load from the current processor, we decrement the local entry number with the number
367 // of entries in this processor and try with the next processor until we find the correct local entry number.
368 while (fInnerProcessors[currProcessorNumber]->LoadEntry(localEntryNumber) == kInvalidNTupleIndex) {
369 if (fInnerNEntries[currProcessorNumber] == kInvalidNTupleIndex) {
370 fInnerNEntries[currProcessorNumber] = fInnerProcessors[currProcessorNumber]->GetNEntries();
371 }
372
373 localEntryNumber -= fInnerNEntries[currProcessorNumber];
374
375 // The provided global entry number is larger than the number of available entries.
376 if (++currProcessorNumber >= fInnerProcessors.size())
377 return kInvalidNTupleIndex;
378
379 ConnectInnerProcessor(currProcessorNumber);
380 }
381
382 fCurrentProcessorNumber = currProcessorNumber;
383 fNEntriesProcessed++;
384 fLastLoadedEntry = entryNumber;
385 return entryNumber;
386}
387
390{
391 for (unsigned i = 0; i < fInnerProcessors.size(); ++i) {
392 const auto &innerProc = fInnerProcessors[i];
393 // TODO can this be done (more) lazily? I.e. only when a match cannot be found in the current inner proc?
394 innerProc->Initialize(fEntry);
395 innerProc->AddEntriesToJoinTable(joinTable, entryOffset);
396 entryOffset += innerProc->GetNEntries();
397 }
398}
399
401{
402 for (const auto &innerProc : fInnerProcessors) {
403 innerProc->PrintStructure(output);
404 }
405}
406
407//------------------------------------------------------------------------------
408
410 std::unique_ptr<RNTupleProcessor> auxProcessor,
411 const std::vector<std::string> &joinFields,
412 const RNTupleProcessorOptions &options)
413 : RNTupleProcessor(options),
414 fPrimaryProcessor(std::move(primaryProcessor)),
415 fAuxiliaryProcessor(std::move(auxProcessor)),
416 fJoinFieldNames(joinFields)
417{
418 if (fOptions.GetProcessorName().empty()) {
419 fOptions.SetProcessorName(fPrimaryProcessor->fOptions.GetProcessorName());
420 }
421}
422
424 std::shared_ptr<ROOT::Experimental::Internal::RNTupleProcessorEntry> entry)
425{
426 if (IsInitialized())
427 return;
428
429 if (!entry)
430 fEntry = std::make_shared<Internal::RNTupleProcessorEntry>();
431 else
432 fEntry = std::move(entry);
433
434 fPrimaryProcessor->Initialize(fEntry);
435 fAuxiliaryProcessor->Initialize(fEntry);
436
437 if (!fJoinFieldNames.empty()) {
438 for (const auto &joinField : fJoinFieldNames) {
439 if (!fPrimaryProcessor->CanReadFieldFromDisk(joinField)) {
440 throw RException(R__FAIL("could not find join field \"" + joinField + "\" in primary processor \"" +
441 fPrimaryProcessor->fOptions.GetProcessorName() + "\""));
442 }
443 if (!fAuxiliaryProcessor->CanReadFieldFromDisk(joinField)) {
444 throw RException(R__FAIL("could not find join field \"" + joinField + "\" in auxiliary processor \"" +
445 fAuxiliaryProcessor->fOptions.GetProcessorName() + "\""));
446 }
447
448 // We prepend the name of the primary processor in this case to prevent reading from the wrong join field in
449 // composed join operations.
450 auto fieldIdx = AddFieldToEntry(fOptions.GetProcessorName() + ".R_rntproc_join_" + joinField, "std::uint64_t",
451 nullptr, Internal::RNTupleProcessorProvenance(fOptions.GetProcessorName()));
452 fJoinFieldIdxs.insert(fieldIdx);
453 }
454
455 fJoinTable = Internal::RNTupleJoinTable::Create(fJoinFieldNames);
456 }
457}
458
460 const std::unordered_set<ROOT::Experimental::Internal::RNTupleProcessorEntry::FieldIndex_t> &fieldIdxs,
462{
463 Initialize();
464
465 auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->fOptions.GetProcessorName());
466 for (const auto &fieldIdx : fieldIdxs) {
467 const auto &fieldProvenance = fEntry->GetFieldProvenance(fieldIdx);
468 if (fieldProvenance.Contains(auxProvenance))
469 fAuxiliaryFieldIdxs.insert(fieldIdx);
470 else
471 fFieldIdxs.insert(fieldIdx);
472 }
473
474 fPrimaryProcessor->Connect(fFieldIdxs, provenance, updateFields);
475 fAuxiliaryProcessor->Connect(fAuxiliaryFieldIdxs, auxProvenance, updateFields);
476}
477
479ROOT::Experimental::RNTupleJoinProcessor::AddFieldToEntry(const std::string &fieldName, const std::string &typeName,
480 void *valuePtr,
482{
483 auto auxProvenance = provenance.Evolve(fAuxiliaryProcessor->fOptions.GetProcessorName());
484 if (auxProvenance.IsPresentInFieldName(fieldName)) {
485 // If the primaryProcessor has a field with the name of the auxProcessor (either as a "proper" field or because
486 // the primary processor itself is a join where its auxProcessor bears the same name as the current auxProcessor),
487 // there will be name conflicts, so error out.
488 if (fPrimaryProcessor->CanReadFieldFromDisk(fieldName)) {
489 throw RException(R__FAIL("ambiguous field name: \"" + 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."));
495 }
496
497 auto fieldIdx = fAuxiliaryProcessor->AddFieldToEntry(fieldName, typeName, valuePtr, auxProvenance);
498 if (fieldIdx)
499 fAuxiliaryFieldIdxs.insert(fieldIdx);
500 return fieldIdx;
501 } else {
502 auto fieldIdx = fPrimaryProcessor->AddFieldToEntry(fieldName, typeName, valuePtr, provenance);
503 if (fieldIdx)
504 fFieldIdxs.insert(fieldIdx);
505 return fieldIdx;
506 }
507}
508
510{
511 for (const auto &fieldIdx : fAuxiliaryFieldIdxs) {
512 fEntry->SetFieldValidity(fieldIdx, isValid);
513 }
514}
515
517{
518 if (fPrimaryProcessor->LoadEntry(entryNumber) == kInvalidNTupleIndex) {
519 for (auto fieldIdx : fFieldIdxs) {
520 fEntry->SetFieldValidity(fieldIdx, false);
521 }
522 SetAuxiliaryFieldValidity(false);
523 return kInvalidNTupleIndex;
524 }
525
526 fNEntriesProcessed++;
527
528 if (!fJoinTable) {
529 // The auxiliary processor's fields are valid if the entry could be loaded.
530 fAuxiliaryProcessor->LoadEntry(entryNumber);
531 return entryNumber;
532 }
533
534 if (!fJoinTableIsBuilt) {
535 fAuxiliaryProcessor->AddEntriesToJoinTable(*fJoinTable);
536 fJoinTableIsBuilt = true;
537 }
538
539 // Collect the values of the join fields for this entry.
540 std::vector<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t> values;
541 values.reserve(fJoinFieldIdxs.size());
542 for (const auto &fieldIdx : fJoinFieldIdxs) {
543 auto val = fEntry->GetValue(fieldIdx).GetRef<ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t>();
544 values.push_back(val);
545 }
546
547 // Find the entry index corresponding to the join field values for each auxiliary processor and load the
548 // corresponding entry.
549 const auto entryIdx = fJoinTable->GetEntryIndex(values);
550
552 SetAuxiliaryFieldValidity(false);
553 } else {
554 SetAuxiliaryFieldValidity(true);
555 fAuxiliaryProcessor->LoadEntry(entryIdx);
556 }
557
558 return entryNumber;
559}
560
562{
563 if (fNEntries == kInvalidNTupleIndex)
564 fNEntries = fPrimaryProcessor->GetNEntries();
565 return fNEntries;
566}
567
573
575{
576 std::ostringstream primaryStructureStr;
577 fPrimaryProcessor->PrintStructure(primaryStructureStr);
578 const auto primaryStructure = ROOT::Split(primaryStructureStr.str(), "\n", /*skipEmpty=*/true);
579 const auto primaryStructureWidth = primaryStructure.front().size();
580
581 std::ostringstream auxStructureStr;
582 fAuxiliaryProcessor->PrintStructure(auxStructureStr);
583 const auto auxStructure = ROOT::Split(auxStructureStr.str(), "\n", /*skipEmpty=*/true);
584
585 const auto maxLength = std::max(primaryStructure.size(), auxStructure.size());
586 for (unsigned i = 0; i < maxLength; i++) {
587 if (i < primaryStructure.size())
588 output << primaryStructure[i];
589 else
590 output << std::setw(primaryStructureWidth) << "";
591
592 if (i < auxStructure.size())
593 output << " " << auxStructure[i];
594
595 output << "\n";
596 }
597}
#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