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

groot: mbr/obj-wise streaming support for types with private fields #882

Open
sbinet opened this issue Dec 16, 2021 · 2 comments
Open

groot: mbr/obj-wise streaming support for types with private fields #882

sbinet opened this issue Dec 16, 2021 · 2 comments
Labels

Comments

@sbinet
Copy link
Member

sbinet commented Dec 16, 2021

in #880, we "discovered" the reflect-based approach for reading (and writing) values for which a r/w-streamer has been generated (roops, woops, rmops, wmops) won't work when the fields of those values are not exported.

what was done in #881 was to detect when a type implements rbytes.Unmarshaler and use that (so the reflect-based code isn't used).

options to generally address this:

  • use an unsafe scheme
  • introduce a new interface/protocol
@bburghgr
Copy link

Thinking aloud, I would probably not go the unsafe route if I was writing this. As far as I can tell, the standard convention for (de)serialization code in Go seems handle user defined structs in one of two ways:

  1. If a type implements some appropriate {Un|M}arshalX method, then use that.
  2. Otherwise, (de)serialize the exported fields of the struct.

Personally, I don't think it would be much of a problem to live with the same requirements here. Especially if code generation tools can provide {Un|M}arshalROOT implementations in common use cases. Knowing very little about the groot internals, it's also the behavior I would naively expect, from having used other libraries in the past. That said, I haven't had a close look at the existing streamer code, so a little unsafe pointer math may turn out to be a less disruptive change overall.

@sbinet
Copy link
Member Author

sbinet commented Dec 18, 2021

yeah, I was just brainstorming as well.

groot already has some support for automatically generating (de)serialization code from a streamer:

a bit of work could be applied to only generate the (un)marshaling part.
keeping in mind one needs to handle UnmarshalROOT methods with multiple vX versions of a type.
(some kind of registry + dispatch, probably)

or use reflect.Value.UnsafeAddr() instead of reflect.Value.Addr().

the reflect-based solution is still appealing because there's no (manual, or through a command) code generation required.
(even if it's probably slower than the code generation approach)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants