Class: Kafka::SnappyCodec

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka/snappy_codec.rb

Instance Method Summary collapse

Instance Method Details

#codec_idObject


5
6
7
# File 'lib/kafka/snappy_codec.rb', line 5

def codec_id
  2
end

#compress(data) ⇒ Object


20
21
22
# File 'lib/kafka/snappy_codec.rb', line 20

def compress(data)
  Snappy.deflate(data)
end

#decompress(data) ⇒ Object


24
25
26
27
# File 'lib/kafka/snappy_codec.rb', line 24

def decompress(data)
  buffer = StringIO.new(data)
  Snappy::Reader.new(buffer).read
end

#loadObject


13
14
15
16
17
18
# File 'lib/kafka/snappy_codec.rb', line 13

def load
  require "snappy"
rescue LoadError
  raise LoadError,
    "Using snappy compression requires adding a dependency on the `snappy` gem to your Gemfile."
end

#produce_api_min_versionObject


9
10
11
# File 'lib/kafka/snappy_codec.rb', line 9

def produce_api_min_version
  0
end