Skip to content

Buffered data in deflated output stream #7

@juliangehring

Description

@juliangehring

Perhaps it's me misunderstanding how to use the Libz correctly, but there may be an issue with writing all buffered data to an output stream. When I follow the example from the readme

r = rand(UInt8, 1000)

using Libz
stream1 = open("data1.txt.gz", "w") |> ZlibDeflateOutputStream
for c in r
    write(stream1, c)
end
close(stream1)

this results in an empty file on disk. The compressed data is only written when the julia session is exited. Larger data sizes that exceed the buffer size are written to disk, except the last chunk - this is again written once the session is closed. I would have expected that any data in the buffer is written once close is explicitly called. This seems to be specific for Libz, as GZip writes out the compressed data directly:

using GZip
stream2 = gzopen("data2.txt.gz", "w")
for c in r
    write(stream2, c)
end
close(stream2)

I can reproduce this with julia 0.4.0, Libz master/0.0.2 and zlib versions 1.2.3 (centos 6.5)/1.2.8(ubuntu 14.04). If I can help with more details, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions