JuliaHEP / AwkwardArray.jl

Awkward Array in Julia mirrors the Python library, enabling effortless zero-copy data exchange between Julia and Python
https://juliahep.github.io/AwkwardArray.jl/dev/
MIT License
33 stars 2 forks source link

`StackOverflow` in `from_table()` #115

Open Moelf opened 1 month ago

Moelf commented 1 month ago

I think this really is telling us that our type-based recursive construction/deconstruction is no godd:

works

julia> using UnROOT, AwkwardArray

julia> df = LazyTree("/home/akako/.julia/dev/UnROOT/test/samples/RNTuple/Run2012BC_DoubleMuParked_Muons_rntuple_1000evts.root", "Events");

julia> ak = AwkwardArray.from_table(df);

julia> ak[1]
{_collection0: [{Muon_pt: ..., ...}, ...], Muon_pt: [...], Muon_eta: [...], ...}

doesn't work

julia> df = LazyTree("/home/akako/.julia/dev/UnROOT/test/samples/NanoAODv5_sample.root", "Events");

julia> ak = AwkwardArray.from_table(df);

...

ROOT.Nojagg, Array{Bool, 1}}, UnROOT.LazyBranch{Bool, UnROOT.Nojagg, Array{Bool, 1}}, UnROOT.LazyBranch{Bool, UnROOT.Nojagg, Array{Bool, 1}}, UnROOT.LazyBranch{UInt8, UnROOT.Nojagg, Array{UInt8, 1}}, UnROOT.LazyBranch{Bool, UnROOT.Nojagg, Array{Bool, 1}}}}})
Encountered stack overflow.
This might be caused by recursion over very long tuples or argument lists.
Moelf commented 1 month ago

Actually, the StackOverflow stems from this line:

https://github.com/JuliaHEP/AwkwardArray.jl/blob/1af9378753a282de8b36162af3ff97a2cd7c94b2/src/tables.jl#L17

and if we replace NT -> NamedTuple it will work, at least for this particular NanoAOD LazyEvent.