Coder Social home page Coder Social logo

libz.jl's Introduction

Build Status Build status codecov.io

This is yet another zlib interface for Julia. It's intended to replace the two prior zlib packages.

Both have shortcomings that this package aims to address, specifically:

  • Zlib.jl is very slow.
  • GZip.jl is not as slow as Zlib.jl, but still slower than it could to be.
  • GZip.jl only supports file I/O.
  • GZip.jl doesn't support reading/writing plain zlib data.

API

This library exports four stream types:

Type Description
ZlibInflateOutputStream read and decompress data
ZlibDeflateOutputStream read and compress data
ZlibInflateInputStream write and decompress data
ZlibDeflateInputStream write and compress data

These work like regular IO objects. Each takes as a parameter either in input or output source.

Examples

# read lines from a compressed file
for line in eachline(open("data.txt.gz") |> ZlibInflateInputStream)
    # do something...
end

# write compressed data to a file
io = open("data.txt.gz", "w")
stream = ZlibDeflateOutputStream(io)
for c in rand(UInt8, 10000)
    write(stream, c)
end
close(stream)  # this closes not only `stream` but also `io`

# pointlessly compress and decompress some data (use `read` on v0.5)
readbytes(rand(UInt8, 10000) |> ZlibDeflateInputStream |> ZlibInflateInputStream)

Other functions

There are convenience Libz.inflate(::Vector{UInt8}) and Libz.deflate(::Vector{UInt8}) functions that take a byte array and return another compressed or decompressed byte array.

Checksum functions are exposed as Libz.crc32(::Vector{UInt8}) and Libz.adler32(::Vector{UInt8}).

See BufferedStreams.jl for benchmarks of this library.

libz.jl's People

Contributors

bicycle1885 avatar dcjones avatar samoconnor avatar juliangehring avatar tkelman avatar yuyichao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.