Sha256: 0adf44ec29234168f650000fcef1df4772d1c1fa752cb1a29f41431d57aa246c

Contents?: true

Size: 431 Bytes

Versions: 11

Compression:

Stored size: 431 Bytes

Contents

module Kafka
  class SnappyCodec
    def codec_id
      2
    end

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby-kafka-0.6.0.beta4 lib/kafka/snappy_codec.rb
ruby-kafka-0.6.0.beta3 lib/kafka/snappy_codec.rb
ruby-kafka-0.6.0.beta2 lib/kafka/snappy_codec.rb
ruby-kafka-0.6.0.beta1 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.5 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.4 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.4.beta1 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.3 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.2 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.2.beta3 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.2.beta2 lib/kafka/snappy_codec.rb