This is an automated email from the ASF dual-hosted git repository. joaoreis pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-gocql-driver.git
The following commit(s) were added to refs/heads/trunk by this push: new f5fe4834 Move the snappy compressor into a separate go package f5fe4834 is described below commit f5fe4834ef2d97982d8f471c15d8cfd6b851373f Author: mykyta.oleksiienko <mykyta.oleksiie...@gmail.com> AuthorDate: Tue Mar 25 12:32:38 2025 +0200 Move the snappy compressor into a separate go package Currently, Snappy is downloaded and included even when users only require LZ4 compression. To streamline the driver and reduce unnecessary dependency overhead for users who don't utilize Snappy, move the Snappy compressor into its own separate package. This will allow users to include only the compression dependencies they need. Patch by Mykyta Oleksiienko; reviewed by Joao Reis CASSGO-33 --- CHANGELOG.md | 2 ++ common_test.go | 3 ++- compressor.go | 27 ------------------------ snappy/compressor.go | 28 +++++++++++++++++++++++++ compressor_test.go => snappy/compressor_test.go | 2 +- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f642ef90..ea0d600c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Moved the Snappy compressor into its own separate package (CASSGO-33) + - Move lz4 compressor to lz4 package within the gocql module (CASSGO-32) - Don't restrict server authenticator unless PasswordAuthentictor.AllowedAuthenticators is provided (CASSGO-19) - Cleanup of deprecated elements (CASSGO-12) diff --git a/common_test.go b/common_test.go index 0ef0acad..1aa4dba2 100644 --- a/common_test.go +++ b/common_test.go @@ -37,6 +37,7 @@ import ( "time" "github.com/gocql/gocql/lz4" + "github.com/gocql/gocql/snappy" ) var ( @@ -117,7 +118,7 @@ func createCluster(opts ...func(*ClusterConfig)) *ClusterConfig { switch *flagCompressTest { case "snappy": - cluster.Compressor = &SnappyCompressor{} + cluster.Compressor = &snappy.SnappyCompressor{} case "lz4": cluster.Compressor = &lz4.LZ4Compressor{} case "no-compression": diff --git a/compressor.go b/compressor.go index c1b7b2b6..a4c305b7 100644 --- a/compressor.go +++ b/compressor.go @@ -24,8 +24,6 @@ package gocql -import "github.com/golang/snappy" - type Compressor interface { Name() string @@ -47,28 +45,3 @@ type Compressor interface { // It returns a new byte slice that is the result of the append operation. AppendDecompressed(dst, src []byte, decompressedLength uint32) ([]byte, error) } - -// SnappyCompressor implements the Compressor interface and can be used to -// compress incoming and outgoing frames. The snappy compression algorithm -// aims for very high speeds and reasonable compression. -type SnappyCompressor struct{} - -func (s SnappyCompressor) Name() string { - return "snappy" -} - -func (s SnappyCompressor) AppendCompressedWithLength(dst, src []byte) ([]byte, error) { - return snappy.Encode(dst, src), nil -} - -func (s SnappyCompressor) AppendDecompressedWithLength(dst, src []byte) ([]byte, error) { - return snappy.Decode(dst, src) -} - -func (s SnappyCompressor) AppendCompressed(dst, src []byte) ([]byte, error) { - panic("SnappyCompressor.AppendCompressed is not supported") -} - -func (s SnappyCompressor) AppendDecompressed(dst, src []byte, decompressedLength uint32) ([]byte, error) { - panic("SnappyCompressor.AppendDecompressed is not supported") -} diff --git a/snappy/compressor.go b/snappy/compressor.go new file mode 100644 index 00000000..faec4a72 --- /dev/null +++ b/snappy/compressor.go @@ -0,0 +1,28 @@ +package snappy + +import "github.com/golang/snappy" + +// SnappyCompressor implements the Compressor interface and can be used to +// compress incoming and outgoing frames. The snappy compression algorithm +// aims for very high speeds and reasonable compression. +type SnappyCompressor struct{} + +func (s SnappyCompressor) Name() string { + return "snappy" +} + +func (s SnappyCompressor) AppendCompressedWithLength(dst, src []byte) ([]byte, error) { + return snappy.Encode(dst, src), nil +} + +func (s SnappyCompressor) AppendDecompressedWithLength(dst, src []byte) ([]byte, error) { + return snappy.Decode(dst, src) +} + +func (s SnappyCompressor) AppendCompressed(dst, src []byte) ([]byte, error) { + panic("SnappyCompressor.AppendCompressed is not supported") +} + +func (s SnappyCompressor) AppendDecompressed(dst, src []byte, decompressedLength uint32) ([]byte, error) { + panic("SnappyCompressor.AppendDecompressed is not supported") +} diff --git a/compressor_test.go b/snappy/compressor_test.go similarity index 99% rename from compressor_test.go rename to snappy/compressor_test.go index d2d2de04..3efe3fa7 100644 --- a/compressor_test.go +++ b/snappy/compressor_test.go @@ -22,7 +22,7 @@ * See the NOTICE file distributed with this work for additional information. */ -package gocql +package snappy import ( "bytes" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org