JuliaHEP / UnROOT.jl

Native Julia I/O package to work with CERN ROOT files objects (TTree and RNTuple)
https://juliahep.github.io/UnROOT.jl/
MIT License
102 stars 17 forks source link

Cannot read empty collections from a RNTuple file #305

Closed peremato closed 9 months ago

peremato commented 9 months ago

Using the RNTuple file https://github.com/peremato/EDM4hep.jl/blob/main/examples/Output_REC_rntuple.root I cannot read an empty collection. The file has been written with ROOT v6.30/00 and I am using UnROOT v0.10.22.

julia> using UnROOT

julia> f = joinpath(@__DIR__, "examples", "Output_REC_rntuple.root")
"/Users/mato/Development/EDM4hep.jl/examples/Output_REC_rntuple.root"

julia> tfile = ROOTFile(f)
ROOTFile with 3 entries and 1 streamer.
/Users/mato/Development/EDM4hep.jl/examples/Output_REC_rntuple.root
├─ events (ROOT::Experimental::RNTuple)
├─ runs (ROOT::Experimental::RNTuple)
└─ podio_metadata (ROOT::Experimental::RNTuple)

julia> events = LazyTree(tfile, "events");

julia> evt = events[1];

julia> hasproperty(evt, :_SiTracks_trackerHits)
true

julia> evt._SiTracks_trackerHits
ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] reduce_empty(op::Base.MappingRF{UnROOT.var"#273#274", Base.BottomRF{…}}, ::Type{UnROOT.PageDescription})
    @ Base ./reduce.jl:361
  [2] reduce_empty_iter
    @ ./reduce.jl:384 [inlined]
  [3] reduce_empty_iter
    @ ./reduce.jl:383 [inlined]
  [4] foldl_impl
    @ ./reduce.jl:49 [inlined]
  [5] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
  [6] mapfoldl
    @ ./reduce.jl:175 [inlined]
  [7] mapreduce
    @ ./reduce.jl:307 [inlined]
  [8] sum
    @ ./reduce.jl:535 [inlined]
  [9] sum
    @ ./reduce.jl:564 [inlined]
 [10] read_pagedesc(io::UnROOT.MmapStream, pagedescs::Vector{UnROOT.PageDescription}, nbits::Int64; split::Bool)
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/footer.jl:115
 [11] read_pagedesc
    @ ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/footer.jl:114 [inlined]
 [12] read_field(io::UnROOT.MmapStream, field::UnROOT.LeafField{Int32}, page_list::Vector{Vector{UnROOT.PageDescription}})
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/fieldcolumn_reading.jl:94
 [13] #302
    @ ./none:0 [inlined]
 [14] iterate
    @ ./generator.jl:47 [inlined]
 [15] collect
    @ ./array.jl:834 [inlined]
 [16] _totuple
    @ ./tuple.jl:425 [inlined]
 [17] Tuple
    @ ./tuple.jl:391 [inlined]
 [18] NamedTuple
    @ ./namedtuple.jl:149 [inlined]
 [19] read_field(io::UnROOT.MmapStream, field::UnROOT.StructField{…}, page_list::Vector{…})
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/fieldcolumn_reading.jl:147
 [20] read_field(io::UnROOT.MmapStream, field::UnROOT.VectorField{…}, page_list::Vector{…})
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/fieldcolumn_reading.jl:125
 [21] _localindex_newcluster!(rf::UnROOT.RNTupleField{…}, idx::Int64, tid::Int64)
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/highlevel.jl:119
 [22] macro expansion
    @ ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/highlevel.jl:96 [inlined]
 [23] macro expansion
    @ ./lock.jl:267 [inlined]
 [24] getindex(rf::UnROOT.RNTupleField{…}, idx::Int64)
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/RNTuple/highlevel.jl:93
 [25] getproperty(evt::UnROOT.LazyEvent, s::Symbol)
    @ UnROOT ~/.julia/packages/UnROOT/UTbmc/src/iteration.jl:226
 [26] top-level scope
    @ REPL[13]:1
Some type information was truncated. Use `show(err)` to see complete types.
Moelf commented 9 months ago

We're not fixing bugs that predate the RC2 specification of RNTuple because it will not be in production and RC2 is both forward and backward incompatible