Skip to content

TBranch::GetBulkEntries does not work for variable-sized arrays #13239

@eguiraud

Description

@eguiraud

Check duplicate issues.

  • Checked for duplicates

Description

As per the title, TBranch::GetBulkEntries does not work for variable-sized arrays, while it works for static-sized arrays and scalars.

Reproducer

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>
#include <TBufferFile.h>
#include <TFile.h>
#include <TTree.h>

void FillTree(const char *filename, const char *treeName) {
  TFile f(filename, "recreate");
  TTree t(treeName, treeName);
  int n = 2;
  double *x = new double[2];
  x[0] = 42;
  x[1] = 84;
  t.Branch("n", &n);
  t.Branch("x", x, "x[n]/D");
  t.Fill();
  t.Write();
  f.Close();
}

int main() {
  auto filename = "repro_getbulkread.root";
  auto treename = "t";
  FillTree(filename, treename);

  TFile f(filename);
  auto *t = f.Get<TTree>(treename);

  t->Scan();
  
  auto *b = t->GetBranch("x");
  TBufferFile buf(TBuffer::kWrite, 10000);
  const auto n = b->GetBulkRead().GetBulkEntries(0, buf);
  assert(n == 1);
}

ROOT version

6.29

Installation method

any

Operating system

any

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions