andrew-d / snappy-go

Automatically exported from code.google.com/p/snappy-go
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Why no io.Reader and io.Writer interface for snappy? #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Interested to find out why there's no streaming interface for snappy?  Wouldn't 
the protocol support it?  Would be nice to know that data streams could use 
snappy too like the json stuff: `json.NewEncoder(w).Encode(obj)` 

Original issue reported on code.google.com by m...@stretchr.com on 25 Jul 2014 at 5:20

GoogleCodeExporter commented 9 years ago
I've taken a go at implementing Reader/Writers for the framing format at 
https://github.com/twotwotwo/sz/ but beware: there're no tests (I've only 
played with the trivial toy program in cmd/sz) and I played the dangerous game 
of tweaking code right before pushing, so there may be embarrassing mistakes, 
caveat emptor, etc. 

I don't love the current design--it internally buffers up 64KB blocks so that 
tiny writes don't lead to a bad compression ratio. It should probably expose 
Reader/Writers that don't buffer to the extent possible, and convenience 
functions that wrap them in bufio.Reader/Writer.

Original comment by twotwo...@gmail.com on 7 Aug 2014 at 8:14