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

Allow hooking into parsetobject #304

Merged
merged 2 commits into from
Jan 24, 2024
Merged

Allow hooking into parsetobject #304

merged 2 commits into from
Jan 24, 2024

Conversation

tamasgal
Copy link
Member

Currently, when calling _getindex(f::ROOTFile, s) a streamer is picked up and when the corresponding type is defined, the streamer is then called with the file object, tkey and refs. The point is that objects can also sit at top-level. In _getindex the type has to be defined in the namespace of UnROOT. That's still something I am not fully happy with but it works so far.

If there is no type defined (called tkey.fClassName, in the namespace of UnROOT), the function parsetobject is called which essentially tries to instantiate the full data as a last resort. This approach completely goes another path and the Lazy* mechanics are also bypassed.

As of now, passing customstructs=Dict{String, Type}(...) to the ROOTFile allows to hook into the streamer logic at the late auto_T_JaggT stage which is only reached for objects in a ROOTDirectory, via getindex(d::ROOTDirectory, s).

This PR adds the ability to use a custom streamer directly inside the parsetobject function, using the same customstructs dictionary.

We really(!) need to refactor these stuff at some point; we can unify a couple of things already, but this is a lot of work.

@tamasgal
Copy link
Member Author

I decided to increase only the patch version. Let us hide this behind the scenes for now. I need to use this mechanism but I need to think about the future implementation before I feel confident to make it fully public.

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4d11965) 87.02% compared to head (42349bd) 86.34%.
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
- Coverage   87.02%   86.34%   -0.69%     
==========================================
  Files          18       18              
  Lines        2404     2438      +34     
==========================================
+ Hits         2092     2105      +13     
- Misses        312      333      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tamasgal tamasgal merged commit 09bfa8d into main Jan 24, 2024
9 of 11 checks passed
@tamasgal tamasgal deleted the add-hook-for-parsetobject branch January 24, 2024 07:39
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.

1 participant