Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ function unpack(io, tkey::TKey, refs::Dict{Int32, Any}, T::Type{RecoveredTBasket
fKeylen = readtype(io, Int16)
fCycle = readtype(io, Int16)

# Check if this is an embedded basket
# Embedded baskets have fNbytes <= fKeylen, meaning all data is inline
is_embedded = fNbytes <= fKeylen

# For embedded baskets, we still need to read through all the data
# to satisfy the parent TObjArray's byte count, even though we won't use it
# The embedded basket data is stored inline and we need to consume it

# Non-embedded basket handling (original logic for recovered baskets)
# skipping class name, name and title
seek(io, start + fKeylen - 18 - 1)

Expand Down
2 changes: 1 addition & 1 deletion src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function readtype(io, ::Type{T}) where T<:AbstractString
length = readtype(io, UInt32)
end

T(read(io, length))
T(read(io, Int(length)))
end

struct CString
Expand Down
20 changes: 20 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,23 @@ end
df = LazyTree(UnROOT.samplefile("TLeafC_pr342.root"), "G4Sim")
@test all(df.Process[1:10] .== ["Radioactivation", "msc", "eIoni", "Transportation", "ionIoni", "Radioactivation", "msc", "eIoni", "ionIoni", "Radioactivation"])
end

# Issue: EOF when trying to open files with recovered/embedded baskets
# Files with embedded baskets (fNbytes <= fKeylen) from premature closure
# are not yet fully supported. This is a known limitation.
# See: https://github.com/JuliaHEP/UnROOT.jl/issues/XXX
@testset "Embedded baskets limitation" begin
# This test documents the known limitation with files containing embedded baskets
# Such files occur when ROOT files are closed prematurely (e.g., process crash)
# and ROOT's recovery mechanism stores uncompressed basket data inline

# TODO: Add test file with embedded baskets when support is implemented
# For now, this serves as documentation that such files are not yet supported

# Example of what should eventually work:
# f = UnROOT.samplefile("file_with_embedded_baskets.root")
# tree = f["tree_name"]
# @test tree.fEntries > 0

@test_skip false # Placeholder - remove when support is added
end
Loading