Skip to content

Commit

Permalink
Merge pull request #486 from pubnative/fix_snappy
Browse files Browse the repository at this point in the history
Update snappy repo path and encoding interface
  • Loading branch information
eapache committed Jul 17, 2015
2 parents c1d582e + 0aeb8f0 commit 094e483
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
5 changes: 1 addition & 4 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ func (m *Message) encode(pe packetEncoder) error {
m.compressedCache = buf.Bytes()
payload = m.compressedCache
case CompressionSnappy:
tmp, err := snappyEncode(m.Value)
if err != nil {
return err
}
tmp := snappyEncode(m.Value)
m.compressedCache = tmp
payload = m.compressedCache
default:
Expand Down
4 changes: 2 additions & 2 deletions snappy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"bytes"
"encoding/binary"

"github.com/golang/snappy/snappy"
"github.com/golang/snappy"
)

var snappyMagic = []byte{130, 83, 78, 65, 80, 80, 89, 0}

// SnappyEncode encodes binary data
func snappyEncode(src []byte) ([]byte, error) {
func snappyEncode(src []byte) []byte {
return snappy.Encode(nil, src)
}

Expand Down
6 changes: 2 additions & 4 deletions snappy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ var snappyStreamTestCases = map[string][]byte{

func TestSnappyEncode(t *testing.T) {
for src, exp := range snappyTestCases {
dst, err := snappyEncode([]byte(src))
if err != nil {
t.Error("Encoding error: ", err)
} else if !bytes.Equal(dst, exp) {
dst := snappyEncode([]byte(src))
if !bytes.Equal(dst, exp) {
t.Errorf("Expected %s to generate %v, but was %v", src, exp, dst)
}
}
Expand Down

0 comments on commit 094e483

Please sign in to comment.