Skip to content

[tree] properly copy entry list, also queried indices #19036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tree/tree/src/TEntryList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,8 @@ void TEntryList::SetTree(const char *treename, const char *filename)
elist->fBlocks = fBlocks;
fBlocks = nullptr;
elist->fNBlocks = fNBlocks;
elist->fLastIndexQueried = fLastIndexQueried;
elist->fLastIndexReturned = fLastIndexReturned;
fLists->Add(elist);
elist = new TEntryList("", "", treename, fn.Data());
if (elist->GetDirectory()) {
Expand Down
27 changes: 27 additions & 0 deletions tree/tree/test/chain_setentrylist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,30 @@ TEST(TChain, SetEntryListSyncWrongNumberOfSubLists) {
gSystem->Unlink(filename1);
gSystem->Unlink(filename2);
}

TEST(TTree, SetEntryListPreUsed)
{
// https://github.com/root-project/root/issues/13338
// Define and fill an entry list
TEntryList entryList;
const std::vector<long long int> entries{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
for (long long int entry : entries)
entryList.Enter(entry);
// Read tree
TTree tree("t", "t");
unsigned int x1;
tree.Branch("x1", &x1);
unsigned int NEntries = 100;
for (unsigned int iEntry = 0; iEntry < NEntries; iEntry++) {
x1 = iEntry;
tree.Fill();
}
// On purpose get entry 15 before setting entry list for tree
entryList.GetEntry(15);
tree.SetEntryList(&entryList);
// Check results
for (long long int entry : entries) {
EXPECT_EQ(tree.GetEntryNumber(entry), entry);
EXPECT_EQ(tree.GetEntryNumber(entry), entry);
}
}
Loading