Class: Cql::Compression::SnappyCompressor
- Inherits:
-
Object
- Object
- Cql::Compression::SnappyCompressor
- Defined in:
- lib/cql/compression/snappy_compressor.rb
Overview
Note:
This compressor requires the snappy gem (v0.0.10 or later for JRuby support).
A compressor that uses the Snappy compression library.
Instance Attribute Summary collapse
- #algorithm ⇒ String readonly
Instance Method Summary collapse
- #compress(str) ⇒ Object
-
#compress?(str) ⇒ true, false
Will return false for frames smaller than the
min_size
given to the constructor. - #decompress(str) ⇒ Object
-
#initialize(min_size = 64) ⇒ SnappyCompressor
constructor
A new instance of SnappyCompressor.
Constructor Details
#initialize(min_size = 64) ⇒ SnappyCompressor
Returns a new instance of SnappyCompressor.
22 23 24 25 |
# File 'lib/cql/compression/snappy_compressor.rb', line 22 def initialize(min_size=64) @algorithm = 'snappy'.freeze @min_size = min_size end |
Instance Attribute Details
#algorithm ⇒ String (readonly)
18 19 20 |
# File 'lib/cql/compression/snappy_compressor.rb', line 18 def algorithm @algorithm end |
Instance Method Details
#compress(str) ⇒ Object
33 34 35 |
# File 'lib/cql/compression/snappy_compressor.rb', line 33 def compress(str) Snappy.deflate(str) end |
#compress?(str) ⇒ true, false
Returns will return false for frames smaller than the
min_size
given to the constructor.
29 30 31 |
# File 'lib/cql/compression/snappy_compressor.rb', line 29 def compress?(str) str.bytesize > @min_size end |
#decompress(str) ⇒ Object
37 38 39 |
# File 'lib/cql/compression/snappy_compressor.rb', line 37 def decompress(str) Snappy.inflate(str) end |