snappy

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package snappy provides Snappy compression for the Cassandra Native Protocol.

Snappy compresses Native Protocol frame payloads as defined in the Cassandra Native Protocol specification. The protocol supports both compressed and uncompressed frame formats, with compression applied to frame payloads containing CQL envelopes.

Basic Usage

To enable Snappy compression:

import (
	"github.com/apache/cassandra-gocql-driver/v2"
	"github.com/apache/cassandra-gocql-driver/v2/snappy"
)

cluster := gocql.NewCluster("127.0.0.1")
cluster.Compressor = &snappy.SnappyCompressor{}

Native Protocol Compression

According to the Cassandra Native Protocol specification, compression operates on frame payloads containing streams of CQL envelopes. Each frame payload is compressed independently with no compression context between frames.

Protocol and Cassandra Version Support

Snappy compression support varies by Cassandra version due to Native Protocol changes:

  • Protocol v2 (Cassandra 2.0.x): LZ4 and Snappy supported
  • Protocol v3 (Cassandra 2.1.x): LZ4 and Snappy supported
  • Protocol v4 (Cassandra 2.2.x, 3.0.x, 3.x): LZ4 and Snappy supported
  • Protocol v5 (Cassandra 4.0+): Only LZ4 supported (Snappy removed)

Snappy is supported from Cassandra 2.0.x through 3.x, but is not available in Cassandra 4.0+. For applications targeting Cassandra 4.0+, use LZ4 compression.

Compatibility Notes

When connecting to Cassandra 4.0+ clusters, Snappy compression will not be available as the protocol only supports LZ4. Applications should use LZ4 for maximum compatibility or implement version-specific compression selection.

Performance Characteristics

LZ4 is generally recommended as the default choice for most applications. For performance optimization, benchmark your specific workload with both compression algorithms, though Snappy is mainly useful if benchmarking shows it performs better for your specific use case.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SnappyCompressor

type SnappyCompressor struct{}

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.

func (SnappyCompressor) AppendCompressed

func (s SnappyCompressor) AppendCompressed(dst, src []byte) ([]byte, error)

func (SnappyCompressor) AppendCompressedWithLength

func (s SnappyCompressor) AppendCompressedWithLength(dst, src []byte) ([]byte, error)

func (SnappyCompressor) AppendDecompressed

func (s SnappyCompressor) AppendDecompressed(dst, src []byte, decompressedLength uint32) ([]byte, error)

func (SnappyCompressor) AppendDecompressedWithLength

func (s SnappyCompressor) AppendDecompressedWithLength(dst, src []byte) ([]byte, error)

func (SnappyCompressor) Name

func (s SnappyCompressor) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL