Skip to content

Commit

Permalink
test zstd compression (#129)
Browse files Browse the repository at this point in the history
* add zstd compression tests
  • Loading branch information
aminnj authored Oct 5, 2021
1 parent 26eb99c commit 2e510c9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/streamers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Streamers(io)
elseif cname == "XZ"
IOBuffer(transcode(XzDecompressor, compressedbytes))
elseif cname == "ZS"
IOBuffer(transcode(ZstdDecompressor, io))
IOBuffer(transcode(ZstdDecompressor, compressedbytes))
elseif cname == "L4"
IOBuffer(lz4_decompress(compressedbytes[9:end], tkey.fObjlen))
else
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ end
@test 100000 == length(arr)
@test [0.0, 1.0588236, 2.1176472, 3.1764705, 4.2352943] arr[1:5] atol=1e-7
close(rootfile)

rootfile = ROOTFile(joinpath(SAMPLES_DIR, "tree_with_int_array_zstd.root"))
arr = collect(rootfile["t1/a"])
@test arr == 0:99
close(rootfile)
end

@testset "ROOTDirectoryHeader" begin
Expand Down
Binary file added test/samples/tree_with_int_array_zstd.root
Binary file not shown.
18 changes: 18 additions & 0 deletions test/samples/zstd_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Run this with a newer version of ROOT
# Otherwise zstd isn't available and the
# 505 will fall back to zlib
from ROOT import TFile, TTree
from array import array

f = TFile('tree_with_int_array_zstd.root', 'recreate', "filename", 505)
t = TTree('t1', '')

n = array('i', [0])
t.Branch('a', n, 'a/I')

for i in range(100):
n[0] = i
t.Fill()

f.Write()
f.Close()

0 comments on commit 2e510c9

Please sign in to comment.