golang / snappy

The Snappy compression format in the Go programming language.
BSD 3-Clause "New" or "Revised" License
1.52k stars 164 forks source link

Why does snappy encodes the file ( increases the size ) instead of compressing it ? #43

Open Praveenrajmani opened 6 years ago

Praveenrajmani commented 6 years ago

I tried compressing a dd generated file of bigger size using snappy. And i found the resulting compressed size to be larger than the actual size. How to avoid it ? Is fixed size compression possible?

creachadair commented 5 years ago

Any compression algorithm that reduces the length of some strings will necessarily increase the length of others (intuitively, there are fewer possible codes of length n than strings of length n+1). Typically random-looking data will result in at least some expansion, since each literal will have some framing and Snappy doesn't use entropy coding.

I wouldn't expect more than a couple percent overhead even from a random file, but some expansion is possible.