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