Skip to content
Draft
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
9 changes: 7 additions & 2 deletions tree/tree/src/TBranch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,13 @@ Int_t TBranch::GetBulkEntries(Long64_t entry, TBuffer &user_buf)
Int_t N = ((fNextBasketEntry < 0) ? fEntryNumber : fNextBasketEntry) - first;
//printf("Requesting %d events; fNextBasketEntry=%lld; first=%lld.\n", N, fNextBasketEntry, first);
if (R__unlikely(!leaf->ReadBasketFast(user_buf, N))) {
Error("GetBulkEntries", "Leaf failed to read.\n");
return -1;
if (N == 1) {
N = leaf->GetNdata();
leaf->ReadBasket(user_buf);
} else {
Error("GetBulkEntries", "Leaf failed to read.\n");
return -1;
}
}
user_buf.SetBufferOffset(bufbegin);

Expand Down
30 changes: 30 additions & 0 deletions tree/tree/test/BulkApiVarLength.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "TFile.h"
#include "TTree.h"
#include "TStopwatch.h"
#include "TSystem.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
#include "TTreeReaderArray.h"
Expand Down Expand Up @@ -235,3 +236,32 @@ TEST_F(BulkApiVariableTest, serializedRead)
printf("Bulk Serialized API: Successful read of all events.\n");
printf("Bulk Serialized API: Total elapsed time (seconds) for API: %.2f\n", sw.RealTime());
}

// https://github.com/root-project/root/issues/13239
TEST(TBranch, GetBulkEntriesVariableArray)
{
auto filename = "repro13239_getbulkread.root";
auto treename = "t";
{
TFile f(filename, "RECREATE");
TTree t(treename, treename);
int n = 2;
double x[2];
x[0] = 42;
x[1] = 84;
t.Branch("n", &n);
t.Branch("x", x, "x[n]/D");
t.Fill();
t.Write();
f.Close();
}
{
TFile f(filename, "READ");
auto *t = f.Get<TTree>(treename);
auto *b = t->GetBranch("x");
TBufferFile buf(TBuffer::kWrite, 10000);
const auto n = b->GetBulkRead().GetBulkEntries(0, buf);
EXPECT_EQ(n, 2);
}
gSystem->Unlink(filename);
}
Loading