Sha256: ef58ce8f326dbaf95af893fb1454587cdc9ba3fce6c6e817f8942166ff1ec98b

Contents?: true

Size: 743 Bytes

Versions: 3

Compression:

Stored size: 743 Bytes

Contents

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

      config_param :command_parameter, :string, default: '-qf1'

      def initialize(options = {})
        super()
        check_command('lzop', 'LZO')
      end

      def ext
        '.lzo'
      end

      def compress(chunk, tmp)
        w = Tempfile.new("chunk-lzo-tmp-")
        w.binmode
        chunk.write_to(w)
        w.close

        # We don't check the return code because we can't recover lzop failure.
        system "lzop #{@command_parameter} -o #{tmp.path} #{w.path}"
      ensure
        w.close rescue nil
        w.unlink rescue nil
      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_lzo_command.rb
fluent-plugin-webhdfs-1.5.0 lib/fluent/plugin/webhdfs_compressor_lzo_command.rb
fluent-plugin-webhdfs-1.4.0 lib/fluent/plugin/webhdfs_compressor_lzo_command.rb