Skip to content

[ntuple] Add support for attributes reading#21778

Open
silverweed wants to merge 8 commits intoroot-project:masterfrom
silverweed:ntuple_attr_read
Open

[ntuple] Add support for attributes reading#21778
silverweed wants to merge 8 commits intoroot-project:masterfrom
silverweed:ntuple_attr_read

Conversation

@silverweed
Copy link
Copy Markdown
Contributor

@silverweed silverweed commented Apr 2, 2026

Adds support for RNTuple attribute reading in the form of the ROOT::Experimental::RNTupleAttrSetReader class plus some ancillary classes.

Main features added:

  • RNTupleReader::OpenAttributeSet -> returns an RNTupleAttrSetReader for a specific attribute set
  • RNTupleAttrSetReader::GetAttributes* -> various methods that return iterables over attribute entry indices
  • RNTupleAttrSetReader::LoadEntry(index[, entry]) -> loads index-th attribute entry (similar to RNTupleReader::LoadEntry). Meant to be used with RNTupleAttrSetReader::GetAttributes*

See the tests for basic usage, e.g. BasicReadingWriting in ntuple_attributes.cxx

@silverweed silverweed self-assigned this Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Test Results

    21 files      21 suites   3d 4h 16m 37s ⏱️
 3 830 tests  3 829 ✅  1 💤 0 ❌
71 882 runs  71 864 ✅ 18 💤 0 ❌

Results for commit e1b0b9f.

♻️ This comment has been updated with latest results.

@silverweed silverweed added the clean build Ask CI to do non-incremental build on PR label Apr 7, 2026
@silverweed silverweed force-pushed the ntuple_attr_read branch 4 times, most recently from 487b964 to 5da9754 Compare April 7, 2026 08:23
@silverweed silverweed force-pushed the ntuple_attr_read branch 3 times, most recently from d68c286 to 28e4497 Compare April 9, 2026 07:47
@silverweed silverweed marked this pull request as ready for review April 9, 2026 09:40
@silverweed silverweed requested review from enirolf and hahnjo April 9, 2026 09:40
Copy link
Copy Markdown
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass of the PR

Comment on lines +20 to +22
for (const auto *field : userFieldRoot->GetConstSubfields()) {
fUserModel->AddField(field->Clone(field->GetFieldName()));
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to construct the fields directly from the constructor: When calling RNTupleReader::GetModel to reconstruct the full model, it will register all fields / columns and prefetch + decompress all pages. That's probably not what we want with the views below.

}

ROOT::Experimental::RNTupleAttrEntryIterable::RIterator::Iter_t
ROOT::Experimental::RNTupleAttrEntryIterable::RIterator::Next() const
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the name since, without a filter, Next() may not actually advance to the next attribute. Can ++fCur be moved here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I'm wondering how to set the initial value of fCur in the constructor if we do...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right... So in the end, it's something like SkipFiltered() though with that name I would more expect it to modify fCur directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I can definitely change the name to make it more explicit.

This makes it easier to keep the meta fields names and indices in sync
and to automatically define and verify their count
// Initialize user model
fUserModel = RNTupleModel::Create();

// Validate meta model format
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually checking the schema version major and minor somewhere? Maybe I'm missing it in another place...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really for now. I guess we want to do the check in the Serializer, but probably in a way that if the version differs, reading the whole RNTuple doesn't fail and it only fails if you actually try to open the attribute set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:RNTuple

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants