Skip to content

Commit 26b5b2d

Browse files
ktfalcaliva
authored andcommitted
DPL Analysis: make sure VLAs use only one basket
Otherwise it seems to create issues with ROOT bulk reading if the baskets are split across multiple clusters. In particular, each row needs 4 bytes for the size of the elements in the row and the _size branch needs to also have its size correctly set. (cherry picked from commit 1561ebb)
1 parent a1bbf95 commit 26b5b2d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Framework/Core/include/Framework/TableTreeHelpers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ class ColumnToBranch
8383
ColumnToBranch(ColumnToBranch const& other) = delete;
8484
ColumnToBranch(ColumnToBranch&& other) = delete;
8585
void at(const int64_t* pos);
86-
int fieldSize() const { return mFieldSize; }
87-
char const* branchName() const { return mBranchName.c_str(); }
86+
[[nodiscard]] int fieldSize() const { return mFieldSize; }
87+
[[nodiscard]] int columnEntries() const { return mColumn->length(); }
88+
[[nodiscard]] char const* branchName() const { return mBranchName.c_str(); }
8889

8990
private:
9091
void accessChunk();

Framework/Core/src/TableTreeHelpers.cxx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,23 @@ std::shared_ptr<TTree> TableToTree::process()
454454
}
455455

456456
for (auto& reader : mColumnReaders) {
457-
int idealBasketSize = 1024 + reader->fieldSize() * mRows; // minimal additional size needed, otherwise we get 2 baskets
457+
int idealBasketSize = 1024 + reader->fieldSize() * reader->columnEntries(); // minimal additional size needed, otherwise we get 2 baskets
458458
int basketSize = std::max(32000, idealBasketSize); // keep a minimum value
459+
// std::cout << "Setting baskets size for " << reader->branchName() << " to " << basketSize << " = 1024 + "
460+
// << reader->fieldSize() << " * " << reader->columnEntries() << ". mRows was " << mRows << std::endl;
459461
mTree->SetBasketSize(reader->branchName(), basketSize);
462+
// If it starts with fIndexArray, also set the size branch basket size
463+
if (strncmp(reader->branchName(), "fIndexArray", strlen("fIndexArray")) == 0) {
464+
std::string sizeBranch = reader->branchName();
465+
sizeBranch += "_size";
466+
// std::cout << "Setting baskets size for " << sizeBranch << " to " << basketSize << " = 1024 + "
467+
// << reader->fieldSize() << " * " << reader->columnEntries() << ". mRows was " << mRows << std::endl;
468+
// One int per array to keep track of the size
469+
int idealBasketSize = 4 * mRows + 1024 + reader->fieldSize() * reader->columnEntries(); // minimal additional size needed, otherwise we get 2 baskets
470+
int basketSize = std::max(32000, idealBasketSize); // keep a minimum value
471+
mTree->SetBasketSize(sizeBranch.c_str(), basketSize);
472+
mTree->SetBasketSize(reader->branchName(), basketSize);
473+
}
460474
}
461475

462476
while (row < mRows) {

0 commit comments

Comments
 (0)