Ver Fonte

Revert "Add workaround for an empty zstd message"

This reverts commit 0f30d9760beb21bf0fc07612077a21770917807a.

The issue was fixed in https://github.com/DataDog/zstd/pull/42
Ivan Babrou há 5 anos atrás
pai
commit
7d77064a4d
2 ficheiros alterados com 8 adições e 13 exclusões
  1. 4 9
      message.go
  2. 4 4
      message_test.go

+ 4 - 9
message.go

@@ -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)}

+ 4 - 4
message_test.go

@@ -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{