Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Fast lossless compression of floating point data in Go

License

NotificationsYou must be signed in to change notification settings

spenczar/fpc

Repository files navigation

GoDoc

fpc is a Go implementation of Burtscher and Ratanaworabhan's'FPC' algorithm for compressing a stream of floating point data.

Why?

The FPC algorithm can losslessly encode and decode huge amounts offloating-point data very quickly. It scales well togigabyte-per-second streams. Compression ratios are better than justabout any generic compressor like gzip or bzip, and compression anddecompression throughput are much better (like, 8x to 300x faster)than other algorithms. For more on this,the paper introducing FPCis really readable - I highly recommend it!

Usage

fpc provides aWriter and aReader, following the pattern set bythe Go standard library's compression packages. The Writer wraps anio.Writer that you want to write compressed data into, and the Readerwraps an io.Reader that you want to read compressed data out of.

Since FPC encodes streams of float64s, they impose some additionalexpectations on callers: when callingReader.Read(p []byte) orWriter.Write(p []byte), the length ofp must be a multiple of 8,to match the expectation that the bytes represent a stream of 8-bytefloat64s.

In addition, utility methods are provided:Reader has aReadFloats(fs []float64) (int, error) method which will read bytesfrom its underlying source, parse them as float64s, put them infs,and return the number of float64s it placed in fs. When it reaches theend of the compressed stream, it will return0, io.EOF.

Similarly,Writer has aWriteFloat(f float64) error method whichwrites a single float64 to the compressed stream.

Performance

In benchmarks on a fairly vanilla laptop, reading or writing from anin-memory stream,fpc is able to encode at about 1.2 gigabytes persecond, and it can decode at about 0.9 gigabytes persecond. Benchmarks can be run on your own hardware withgo test -bench "Read|Write" ..

About

Fast lossless compression of floating point data in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp