Skip to content

Commit 61eb610

Browse files
committed
[ntuple] apply field substitutions in ConnectPageSource()
1 parent f861861 commit 61eb610

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tree/ntuple/src/RFieldBase.cxx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,26 @@ void ROOT::RFieldBase::ConnectPageSource(ROOT::Internal::RPageSource &pageSource
959959
if (!fDescription.empty())
960960
throw RException(R__FAIL("setting description only valid when connecting to a page sink"));
961961

962-
BeforeConnectPageSource(pageSource);
962+
auto substitute = BeforeConnectPageSource(pageSource);
963+
if (substitute) {
964+
const RFieldBase *itr = this;
965+
while (itr->GetParent()) {
966+
itr = itr->GetParent();
967+
}
968+
if (typeid(*itr) == typeid(RFieldZero) && static_cast<const RFieldZero *>(itr)->GetAllowFieldSubstitutions()) {
969+
for (auto &f : fParent->fSubfields) {
970+
if (f.get() != this)
971+
continue;
972+
973+
f = std::move(substitute);
974+
f->ConnectPageSource(pageSource);
975+
return;
976+
}
977+
R__ASSERT(false); // never here
978+
} else {
979+
throw RException(R__FAIL("invalid attempt to substitute field " + GetQualifiedFieldName()));
980+
}
981+
}
963982

964983
if (!fIsArtificial) {
965984
R__ASSERT(fOnDiskId != kInvalidDescriptorId);

0 commit comments

Comments
 (0)