Skip to content

Commit

Permalink
Showing 2 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnROOT"
uuid = "3cd96dde-e98d-4713-81e9-a4a1b0235ce9"
authors = ["Tamas Gal", "Jerry Ling", "Johannes Schumann", "Nick Amin"]
version = "0.4.0"
version = "0.4.1"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
56 changes: 30 additions & 26 deletions src/root.jl
Original file line number Diff line number Diff line change
@@ -419,36 +419,40 @@ function readbasketseek(
f::ROOTFile, branch::Union{TBranch, TBranchElement}, seek_pos::Int
)::Tuple{Vector{UInt8},Vector{Int32}} # just being extra careful
lock(f)
seek(f.fobj, seek_pos)
basketkey = unpack(f.fobj, TBasketKey)
compressedbytes = compressed_datastream(f.fobj, basketkey)
unlock(f)

basketrawbytes = decompress_datastreambytes(compressedbytes, basketkey)

@debug begin
ibasket = findfirst(==(seek_pos), branch.fBasketSeek)
mbcompressed = length(compressedbytes)/1024^2
mbuncompressed = length(basketrawbytes)/1024^2
"Read branch $(branch.fName), basket $(ibasket), $(mbcompressed) MB compressed, $(mbuncompressed) MB uncompressed"
end
try
seek(f.fobj, seek_pos)
basketkey = unpack(f.fobj, TBasketKey)
compressedbytes = compressed_datastream(f.fobj, basketkey)

Keylen = basketkey.fKeylen
contentsize = Int32(basketkey.fLast - Keylen)
basketrawbytes = decompress_datastreambytes(compressedbytes, basketkey)

offsetbytesize = basketkey.fObjlen - contentsize - 8
@debug begin
ibasket = findfirst(==(seek_pos), branch.fBasketSeek)
mbcompressed = length(compressedbytes)/1024^2
mbuncompressed = length(basketrawbytes)/1024^2
"Read branch $(branch.fName), basket $(ibasket), $(mbcompressed) MB compressed, $(mbuncompressed) MB uncompressed"
end

data = @view basketrawbytes[1:contentsize]
if offsetbytesize > 0
Keylen = basketkey.fKeylen
contentsize = Int32(basketkey.fLast - Keylen)

#indexing is inclusive on both ends
offbytes = @view basketrawbytes[(contentsize + 4 + 1):(end - 4)]
offsetbytesize = basketkey.fObjlen - contentsize - 8

# offsets starts at -fKeylen, same as the `local_offset` we pass in in the loop
offset = ntoh.(reinterpret(Int32, offbytes)) .- Keylen
push!(offset, contentsize)
data, offset
else
data, Int32[]
data = @view basketrawbytes[1:contentsize]
if offsetbytesize > 0

#indexing is inclusive on both ends
offbytes = @view basketrawbytes[(contentsize + 4 + 1):(end - 4)]

# offsets starts at -fKeylen, same as the `local_offset` we pass in in the loop
offset = ntoh.(reinterpret(Int32, offbytes)) .- Keylen
push!(offset, contentsize)
return data, offset
else
return data, Int32[]
end
catch
finally
unlock(f)
end
end

2 comments on commit 9dc7f67

@Moelf
Copy link
Member Author

@Moelf Moelf commented on 9dc7f67 Sep 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/44253

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" 9dc7f67cb14997d72a80da44a209b2812968ceeb
git push origin v0.4.1

Please sign in to comment.