Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update snappy repo path and encoding interface #486

Merged
merged 1 commit into from
Jul 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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