BioJulia / Libz.jl

Fast, flexible zlib bindings.
Other
27 stars 17 forks source link

Copy or checkpoint state of zstream? #11

Open robertfeldt opened 8 years ago

robertfeldt commented 8 years ago

I have a long string sl and an array of shorter strings S = [s1, s2, ..., sn] and need to know the length of the compressed strings one gets by concatenating sl with each of the strings in S. Is there a faster way than:

concatenated = map(s -> sl * s, S)
lengths = map(s -> length(Libz.deflate(s)), conctenated)

?

Basically I wonder if there is some way to create a Libz deflate stream, compress sl and then copy/reuse that stream and then write the strings in S to it (and then measure length of output from the closed stream). I assume it is not enough to add a copy method to ZStream since one might need to copy zlib internal data also?

Thanks in advance for any tips/advice.