Skip to content

[ntuple] Attributes: add support for writing#21289

Open
silverweed wants to merge 10 commits intoroot-project:masterfrom
silverweed:ntuple_attr_write
Open

[ntuple] Attributes: add support for writing#21289
silverweed wants to merge 10 commits intoroot-project:masterfrom
silverweed:ntuple_attr_write

Conversation

@silverweed
Copy link
Contributor

This Pull request:

adds the RNTupleAttrSetWriter class and initial support for writing attributes. This involves touching, among other classes, the RNTupleWriter, RNTupleFillContext, RPageSink and RMiniFile.

Original reference PR (now quite outdated): #19153

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

@github-actions
Copy link

github-actions bot commented Feb 16, 2026

Test Results

    17 files      17 suites   2d 11h 58m 51s ⏱️
 3 815 tests  3 815 ✅ 0 💤 0 ❌
57 969 runs  57 969 ✅ 0 💤 0 ❌

Results for commit 0e6734f.

♻️ This comment has been updated with latest results.

@silverweed silverweed added the clean build Ask CI to do non-incremental build on PR label Feb 18, 2026
@silverweed silverweed force-pushed the ntuple_attr_write branch 4 times, most recently from 16e0a45 to 9b598df Compare February 23, 2026 10:05
Copy link
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.

A first review... I think one high-level decision to make is where to build RNTupleAttrSetDescriptor. RNTupleFileWriter feels like the wrong place to do this.

Comment on lines +8 to +9
#ifndef ROOT7_RNTuple_Attributes
#define ROOT7_RNTuple_Attributes
Copy link
Member

Choose a reason for hiding this comment

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

A while ago, we started having one header per class. I think we should keep this pattern and split the header RNTupleAttributes.hxx proposed here

Copy link
Contributor Author

@silverweed silverweed Feb 25, 2026

Choose a reason for hiding this comment

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

We still have some exceptions where it makes sense (RNTupleDescriptor.hxx, RNTupleUtils.hxx, ...); I'm not sure that splitting this would bring much value - perhaps the splitting could be made at the reading vs writing level?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, some classes are still "bundled" - agreed on the reading vs writing level. Probably that will need some more headers for classes shared between the two (?)

Comment on lines +58 to +59
inline const std::uint16_t kSchemaVersionMajor = 1;
inline const std::uint16_t kSchemaVersionMinor = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Should these move into the RNTuple class where we have the other constants such as kVersionEpoch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly; though these only concern attributes so it's not necessarily interesting for users of the RNTuple class. It's a matter of deciding whether we want to centralize these binary specs-related constants or not.
I have no strong opinion either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking again about this, I'd not put these in RNTuple as that's only one specific anchor, whereas these constants are anchor-agnostic.
If anything they might live in the Serializer, but I'd rather keep them close to the other related constants (rangeStartFieldName etc).
Probably in a separate header that is only included by some cxx file and not directly exposed to users.

Copy link
Member

Choose a reason for hiding this comment

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

AFAICT we are already using the constants in RNTuple to initialize the RNTupleDescriptorBuilder...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, but I'm not sure that was the best decision on our side. In retrospect, I'd probably have put them in some dedicated namespace (although I see the argument of using the RNTuple name to namespace them)...

@silverweed
Copy link
Contributor Author

Thanks for the thorough review @hahnjo! For the descriptor building I agree it feels weird to have it in the Writer; let's talk about it offline.

@silverweed silverweed force-pushed the ntuple_attr_write branch 8 times, most recently from 2d7c429 to b20c52b Compare March 4, 2026 15:03
@silverweed silverweed requested a review from hahnjo March 5, 2026 09:07
Comment on lines +160 to +161
friend class ROOT::RNTupleFillContext;
friend class ROOT::RNTupleWriter;
Copy link
Member

Choose a reason for hiding this comment

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

The wrong friend declaration should probably be removed from the original commit...

Comment on lines +222 to +223
friend class ROOT::RNTupleFillContext;
friend class ROOT::RNTupleWriter;
Copy link
Member

Choose a reason for hiding this comment

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

same

Comment on lines +91 to +92
/// NOTE: this is a deque to keep pointers stable upon adding/removing, but have deterministic iteration at the
/// same time.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this stability guarantee?

Comment on lines +197 to +199
// NOTE: references into attrSets are guaranteed to be stable, so we can hand out the reference
// to the AttrSetWriter's shared_ptr into the handle.
return Experimental::RNTupleAttrSetWriterHandle{addedSet};
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this guarantee? RNTupleAttrSetWriterHandle (currently) creates a std::weak_ptr, which precisely has the point that the shared_ptr doesn't need to stay around...

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.

3 participants