Sha256: ed496f54fbe5bf46be197a5077e0c01891ed00e766932b9f08f85815ae79137f

Contents?: true

Size: 437 Bytes

Versions: 28

Compression:

Stored size: 437 Bytes

Contents

module Kafka
  class SnappyCodec
    def initialize
      require "snappy"
    rescue LoadError
      raise LoadError,
        "Using snappy compression requires adding a dependency on the `snappy` gem to your Gemfile."
    end

    def codec_id
      2
    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

28 entries across 28 versions & 1 rubygems

Version Path
ruby-kafka-0.5.2.beta1 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.1 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.1.beta2 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.1.beta1 lib/kafka/snappy_codec.rb
ruby-kafka-0.4.4 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.0 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.0.beta6 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.0.beta5 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.0.beta4 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.0.beta3 lib/kafka/snappy_codec.rb
ruby-kafka-0.5.0.beta2 lib/kafka/snappy_codec.rb
ruby-kafka-0.4.3 lib/kafka/snappy_codec.rb
ruby-kafka-0.4.2 lib/kafka/snappy_codec.rb
ruby-kafka-0.4.1 lib/kafka/snappy_codec.rb
ruby-kafka-0.4.0 lib/kafka/snappy_codec.rb
ruby-kafka-0.4.0.beta1 lib/kafka/snappy_codec.rb
ruby-kafka-0.3.18.beta2 lib/kafka/snappy_codec.rb
ruby-kafka-0.3.18.beta1 lib/kafka/snappy_codec.rb
ruby-kafka-0.3.17 lib/kafka/snappy_codec.rb
ruby-kafka-0.3.16 lib/kafka/snappy_codec.rb