Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RNTuple writer after API break in ROOT #547

Merged
merged 6 commits into from
Apr 2, 2024

Conversation

tmadlener
Copy link
Collaborator

BEGINRELEASENOTES

ENDRELEASENOTES

@tmadlener
Copy link
Collaborator Author

It looks like RNTuple is undergoing some API work on the ROOT side, so it probably makes sense fix things in one go, once that is done. Coming back to this, once that is the case.

@tmadlener tmadlener marked this pull request as draft January 26, 2024 13:26
@jmcarcell
Copy link
Member

This isn't needed with ROOT 6.30.04 released a few days ago but the PRs that change the API are not in any tag yet

@tmadlener
Copy link
Collaborator Author

Yeah, they will presumably be part of 6.32. I am still waiting for the message from the root devs to see how this looks afterwards. Then we can see whether we can have both versions or whether we need to bump the minimal root version for RNTuple support.

@tmadlener
Copy link
Collaborator Author

Things should be more stable again in ROOT, so we could try to revive this.

@tmadlener
Copy link
Collaborator Author

I got things to work again for the writing side, where it was really mainly an API change as far as I can tell. I have kept backwards compatibility using pre-processor version checks for now.

On the reading side the API has changed a bit more drastically and things are not yet compiling, mainly because
RNTupleModel::GetDefaultEntry now returns a const REntry& instead of a Rentry*, so we cannot call BindRawPtr on it. Maybe @jblomer can shed some light on what we have to change conceptually. What we did until now was something along the lines of

auto reader = ROOT::Experimental::RNTupleReader{};
auto entry = reader.GetModel()->GetDefaultEntry();

auto buffers = BufferFactory::createBuffers("<coll-type>", schemaVersion);
dentry->CaptureValueUnsafe("<branch-name>", buffers.data);

reader.LoadEntry(entry);

buffers are podio::CollectionReadBuffers in this case, and buffers.data is a void*.

@jblomer
Copy link

jblomer commented Feb 29, 2024

Instead of using the default entry, you can create a dedicated entry with reader.GetModel().CreateEntry(). If you bind all the fields of your entry, then you can use reader.GetModel().CreateBareEntry(), which will not try to instantiate objects for the entry's fields.

On the entry, you can call entry->BindValue (requires an std::shared_ptr to the buffer) or entry->BindRawPtr()

@tmadlener
Copy link
Collaborator Author

Thanks for the pointers. Things are compiling again now, but there is an error in the test that reads back the rntuple file again. I have to figure out whether the problem is on the writing or on the reading side.

@tmadlener
Copy link
Collaborator Author

@jblomer do I have to do something more than CreateBareEntry and then binding all of the fields with BindRawPtr and then LoadEntry? It currently looks like everything is working on the writing side, but when I try to read back things, I effectively get only empty vectors. Those are as far as I can tell the empty ones we pass to BindRawPtr in the first place. Can (unique) ownership of these pointers play a role here?

@jblomer
Copy link

jblomer commented Mar 13, 2024

Apologies, this last comment slipped through!

What you describe sounds correct. You use CreateBareEntry and then bind all top-level fields with BindRawPtr.

I think what is missing is poassing that entry to LoadEntry() as a second parameter. Otherwise LoadEntry() fills the default entry.

@tmadlener tmadlener force-pushed the rntuple-api-compat branch from 4653166 to 1baf596 Compare March 13, 2024 08:53
@tmadlener
Copy link
Collaborator Author

tmadlener commented Mar 13, 2024

No worries. The information would have been readily available from the documentation, if I had read that a bit more carefully. ;) This seems to do the trick. I am not entirely sure why but dev3 seems to be broken for other reasons at the moment, but I can build this locally against dev3 from last week.

I realized that we need to CreateEntry instead of CreateBareEntry, because we do not explicitly set all the fields in the entry.

Thanks again for your help.

@tmadlener tmadlener marked this pull request as ready for review March 13, 2024 09:38
@tmadlener tmadlener force-pushed the rntuple-api-compat branch from d1b156e to f0c6cbd Compare April 2, 2024 19:33
@tmadlener
Copy link
Collaborator Author

Merging this since the RNTuple I/O is fixed with ROOT master. The remaining failing tests are unrelated and possibly due to other upstream ROOT changes. They are partially addressed in #575 and will be fully fixed in another PR.

@tmadlener tmadlener merged commit 14109ff into AIDASoft:master Apr 2, 2024
16 of 18 checks passed
@tmadlener tmadlener deleted the rntuple-api-compat branch April 2, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RNTuple interface changed in ROOT
3 participants