Skip to content

Commit 121dc61

Browse files
committed
tree: Fix address for nested split obj with io rule.
In the case a nested split object has a rule applying to it, we need to read its component (the sub-branches) into the 'fOnfileObject' rather than the user in-memory object
1 parent 56fc871 commit 121dc61

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

tree/tree/inc/TBranch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class TBranch : public TNamed, public TAttFill {
176176

177177
TString GetRealFileName() const;
178178

179-
virtual void SetAddressImpl(void *addr, bool /* implied */) { SetAddress(addr); }
179+
virtual void SetAddressImpl(void *addr, bool /* implied */, Int_t /* offset */) { SetAddress(addr); }
180180

181181
private:
182182
Int_t GetBasketAndFirst(TBasket*& basket, Long64_t& first, TBuffer* user_buffer);

tree/tree/inc/TBranchElement.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class TBranchElement : public TBranch {
145145
void SetReadLeavesPtr();
146146
void SetReadActionSequence();
147147
void SetupAddressesImpl();
148-
void SetAddressImpl(void *addr, bool implied) override;
148+
void SetAddressImpl(void *addr, bool implied, Int_t offset) override;
149149

150150
void FillLeavesImpl(TBuffer& b);
151151
void FillLeavesMakeClass(TBuffer& b);

tree/tree/src/TBranchElement.cxx

+10-3
Original file line numberDiff line numberDiff line change
@@ -4964,13 +4964,16 @@ void TBranchElement::ResetInitInfo(bool recurse)
49644964

49654965
void TBranchElement::SetAddress(void* addr)
49664966
{
4967-
SetAddressImpl(addr, (addr == nullptr));
4967+
SetAddressImpl(addr, (addr == nullptr), 0);
49684968
}
49694969

49704970
/// See TBranchElement::SetAddress.
49714971
/// If implied is true, we do not over-ride existing address for
49724972
/// sub-branches.
4973-
void TBranchElement::SetAddressImpl(void* addr, bool implied)
4973+
/// The `offset` is the offset of the sub-object within its parent,
4974+
/// it is already included in the addr but is still needed to be added
4975+
/// the OnfileObject address when/if we need to use that address.
4976+
void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset)
49744977
{
49754978
//
49764979
// Don't bother if we are disabled.
@@ -5495,11 +5498,15 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied)
54955498
//
54965499
// FIXME: This is a tail recursion, we burn stack.
54975500
Int_t nbranches = fBranches.GetEntriesFast();
5501+
char *localObject = fObject;
5502+
if (fOnfileObject && this != GetMother()) {
5503+
localObject = fOnfileObject->GetObjectAt(0) + offset;
5504+
}
54985505
for (Int_t i = 0; i < nbranches; ++i) {
54995506
TBranch *abranch = (TBranch*) fBranches.UncheckedAt(i);
55005507
// FIXME: This is a tail recursion!
55015508
if (fBranchOffset[i] != TStreamerInfo::kMissing && !(implied && abranch->TestBit(kAddressSet))) {
5502-
abranch->SetAddressImpl(fObject + fBranchOffset[i], implied);
5509+
abranch->SetAddressImpl(localObject + fBranchOffset[i], implied, fBranchOffset[i]);
55035510
abranch->SetBit(kAddressSet);
55045511
if (TestBit(kDecomposedObj) != abranch->TestBit(kDecomposedObj))
55055512
abranch->SetMakeClass(TestBit(kDecomposedObj));

0 commit comments

Comments
 (0)