@@ -351,6 +351,8 @@ ROOT::Experimental::RNTupleJoinProcessor::RNTupleJoinProcessor(const RNTupleOpen
351
351
352
352
for (const auto &auxNTuple : auxNTuples) {
353
353
fAuxiliaryPageSources .emplace_back (Internal::RPageSource::Create (auxNTuple.fNTupleName , auxNTuple.fStorage ));
354
+ if (!joinFields.empty ())
355
+ fJoinTables .emplace_back (Internal::RNTupleJoinTable::Create (joinFields));
354
356
}
355
357
356
358
if (!primaryModel)
@@ -374,12 +376,6 @@ ROOT::Experimental::RNTupleJoinProcessor::RNTupleJoinProcessor(const RNTupleOpen
374
376
auto &field = value.GetField ();
375
377
const auto &fieldName = field.GetQualifiedFieldName ();
376
378
377
- auto isAuxParent = std::find_if (auxNTuples.cbegin (), auxNTuples.cend (), [&fieldName](const RNTupleOpenSpec &n) {
378
- return fieldName.substr (0 , n.fNTupleName .size ()) == n.fNTupleName ;
379
- });
380
- if (isAuxParent != auxNTuples.end ())
381
- continue ;
382
-
383
379
// If the model provided by the user has a default entry, use the value pointers from the default entry of the
384
380
// model that was passed to this constructor. This way, the pointers returned by RNTupleModel::MakeField can be
385
381
// used in the processor loop to access the corresponding field values.
@@ -388,11 +384,18 @@ ROOT::Experimental::RNTupleJoinProcessor::RNTupleJoinProcessor(const RNTupleOpen
388
384
fEntry ->BindValue (fieldName, valuePtr);
389
385
}
390
386
391
- fFieldContexts .try_emplace (fieldName, field.Clone (fieldName), fEntry ->GetToken (fieldName));
392
- }
387
+ auto auxNTupleName = std::find_if (auxNTuples.cbegin (), auxNTuples.cend (), [&fieldName](const RNTupleOpenSpec &n) {
388
+ return fieldName.substr (0 , n.fNTupleName .size ()) == n.fNTupleName ;
389
+ });
393
390
394
- for (unsigned i = 0 ; i < auxNTuples.size (); ++i) {
395
- AddAuxiliary (auxNTuples[i], joinFields, i + 1 /* ntupleIdx */ );
391
+ if (auxNTupleName == auxNTuples.end ()) {
392
+ fFieldContexts .try_emplace (fieldName, field.Clone (field.GetFieldName ()), fEntry ->GetToken (fieldName));
393
+ } else if (fieldName != auxNTupleName->fNTupleName ) {
394
+ // Add 1 because we also have to take into account the primary ntuple.
395
+ auto ntupleIdx = std::distance (auxNTuples.begin (), auxNTupleName) + 1 ;
396
+ fFieldContexts .try_emplace (fieldName, field.Clone (field.GetFieldName ()), fEntry ->GetToken (fieldName),
397
+ ntupleIdx);
398
+ }
396
399
}
397
400
}
398
401
@@ -435,32 +438,6 @@ void ROOT::Experimental::RNTupleJoinProcessor::SetModel(std::unique_ptr<RNTupleM
435
438
fModel ->Freeze ();
436
439
}
437
440
438
- void ROOT::Experimental::RNTupleJoinProcessor::AddAuxiliary (const RNTupleOpenSpec &auxNTuple,
439
- const std::vector<std::string> &joinFields,
440
- std::size_t ntupleIdx)
441
- {
442
- assert (fNEntriesProcessed == 0 && " cannot add auxiliary ntuples after processing has started" );
443
-
444
- auto &auxParentField = fModel ->GetConstField (auxNTuple.fNTupleName );
445
-
446
- for (const auto &field : auxParentField.GetConstSubfields ()) {
447
- // If the model was provided by the user and it has a default entry, use the value pointers from the entry in
448
- // the entry managed by the processor. This way, the pointers returned by RNTupleModel::MakeField can be used
449
- // in the processor loop to access the corresponding field values.
450
- if (!fModel ->IsBare ()) {
451
- auto valuePtr = fModel ->GetDefaultEntry ().GetPtr <void >(field->GetQualifiedFieldName ());
452
- fEntry ->BindValue (field->GetQualifiedFieldName (), valuePtr);
453
- }
454
-
455
- auto token = fEntry ->GetToken (field->GetQualifiedFieldName ());
456
- fFieldContexts .try_emplace (field->GetQualifiedFieldName (), field->Clone (field->GetFieldName ()), token, ntupleIdx);
457
- }
458
-
459
- // If no join fields have been specified, an aligned join is assumed and an join table won't be created.
460
- if (!joinFields.empty ())
461
- fJoinTables .emplace_back (Internal::RNTupleJoinTable::Create (joinFields));
462
- }
463
-
464
441
void ROOT::Experimental::RNTupleJoinProcessor::ConnectFields ()
465
442
{
466
443
for (auto &[_, fieldContext] : fFieldContexts ) {
0 commit comments