Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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)
Expand Down
3 changes: 2 additions & 1 deletion common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"time"

"github.com/gocql/gocql/lz4"
"github.com/gocql/gocql/snappy"
)

var (
Expand Down Expand Up @@ -112,7 +113,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":
Expand Down
27 changes: 0 additions & 27 deletions compressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

package gocql

import "github.com/golang/snappy"

type Compressor interface {
Name() string

Expand All @@ -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")
}
28 changes: 28 additions & 0 deletions snappy/compressor.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 1 addition & 1 deletion compressor_test.go → snappy/compressor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* See the NOTICE file distributed with this work for additional information.
*/

package gocql
package snappy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is missing

//go:build all || unit
// +build all unit

so it runs in the CI unit tests step


import (
"bytes"
Expand Down