Class: Cql::Compression::Compressor

Inherits:
Object
  • Object
show all
Defined in:
lib/cql/compression.rb

Overview

Note:

Compressors given to Cql::Client.connect as the :compressor option don't need to be subclasses of this class, but need to implement the same methods. This class exists only for documentation purposes.

Instance Method Summary collapse

Instance Method Details

#algorithmString

Returns the name of the algorithm this compressor supports, e.g. "snappy" or "lz4".

Returns:

  • (String)


# File 'lib/cql/compression.rb', line 12

#compressString

Compresses the raw bytes of a frame.

Parameters:

  • frame (String)

    the bytes of the frame to be compressed

Returns:

  • (String)

    the compressed frame



# File 'lib/cql/compression.rb', line 37

#compress?true, false

Before compressing a frame the compressor will be asked if it wants to compress it or not. One reason it could say no is if the frame is small enough that compression would be unlikely to decrease its size.

If your operations consist mostly of small prepared statement executions it might not be useful to compress the frames being sent to Cassandra, but enabling compression can still be useful on the frames coming from Cassandra. Making this method always return false disables request compression, but will still make the client tell Cassandra that it supports compressed frames.

The bytes given to #compress? are the same as to #compress

Parameters:

  • frame (String)

    the bytes of the frame to be compressed

Returns:

  • (true, false)


# File 'lib/cql/compression.rb', line 19

#decompressString

Decompresses the raw bytes of a compressed frame.

Parameters:

  • compressed_frame (String)

    the bytes of the compressed frame to be uncompressed

Returns:

  • (String)


# File 'lib/cql/compression.rb', line 44