Skip to content

Commit

Permalink
Revert "Add workaround for an empty zstd message"
Browse files Browse the repository at this point in the history
This reverts commit 0f30d97.

The issue was fixed in DataDog/zstd#42
  • Loading branch information
bobrik committed Oct 2, 2018
1 parent 7479983 commit 7d77064
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
13 changes: 4 additions & 9 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,11 @@ func (m *Message) encode(pe packetEncoder) error {
m.compressedCache = buf.Bytes()
payload = m.compressedCache
case CompressionZSTD:
if len(m.Value) == 0 {
// Hardcoded empty ZSTD frame, see: https://github.com/DataDog/zstd/issues/41
m.compressedCache = []byte{0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x00, 0x01, 0x00, 0x00, 0x99, 0xe9, 0xd8, 0x51}
} else {
c, err := zstd.CompressLevel(nil, m.Value, m.CompressionLevel)
if err != nil {
return err
}
m.compressedCache = c
c, err := zstd.CompressLevel(nil, m.Value, m.CompressionLevel)
if err != nil {
return err
}
m.compressedCache = c
payload = m.compressedCache
default:
return PacketEncodingError{fmt.Sprintf("unsupported compression codec (%d)", m.Codec)}
Expand Down
8 changes: 4 additions & 4 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ var (
}

emptyZSTDMessage = []byte{
252, 62, 137, 23, // CRC
180, 172, 84, 179, // CRC
0x01, // version byte
0x04, // attribute flags: lz4
0x04, // attribute flags: zstd
0, 0, 1, 88, 141, 205, 89, 56, // timestamp
0xFF, 0xFF, 0xFF, 0xFF, // key
0x00, 0x00, 0x00, 0x0d, // len
0x00, 0x00, 0x00, 0x09, // len
// ZSTD data
0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x00, 0x01, 0x00, 0x00, 0x99, 0xe9, 0xd8, 0x51,
0x28, 0xb5, 0x2f, 0xfd, 0x20, 0x00, 0x01, 0x00, 0x00,
}

emptyBulkSnappyMessage = []byte{
Expand Down

0 comments on commit 7d77064

Please sign in to comment.