Sha256: c3b3cd4c198d453cc64e3e13c4772657b75953161d4552ec9eff3b891c390e01

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 Bytes

Contents

module Fluent::Plugin
  class WebHDFSOutput < Output
    class SnappyCompressor < Compressor
      WebHDFSOutput.register_compressor('snappy', self)

      DEFAULT_BLOCK_SIZE = 32 * 1024

      desc 'Block size for compression algorithm'
      config_param :block_size, :integer, default: DEFAULT_BLOCK_SIZE

      def initialize(options = {})
        super()
        begin
          require "snappy"
        rescue LoadError
          raise Fluent::ConfigError, "Install snappy before using snappy compressor"
        end
      end

      def ext
        ".sz"
      end

      def compress(chunk, tmp)
        Snappy::Writer.new(tmp, @block_size) do |w|
          w << chunk.read
          w.flush
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluent-plugin-webhdfs-1.6.0 lib/fluent/plugin/webhdfs_compressor_snappy.rb
fluent-plugin-webhdfs-1.5.0 lib/fluent/plugin/webhdfs_compressor_snappy.rb
fluent-plugin-webhdfs-1.4.0 lib/fluent/plugin/webhdfs_compressor_snappy.rb