Class: Fluent::Plugin::WebHDFSOutput::HadoopSnappyCompressor

Inherits:
Compressor
  • Object
show all
Defined in:
lib/fluent/plugin/webhdfs_compressor_hadoop_snappy.rb

Constant Summary collapse

DEFAULT_BLOCK_SIZE =
256 * 1024

Instance Method Summary collapse

Methods inherited from Compressor

#configure, #initialise

Constructor Details

#initialize(options = {}) ⇒ HadoopSnappyCompressor

Returns a new instance of HadoopSnappyCompressor.



11
12
13
14
15
16
17
18
# File 'lib/fluent/plugin/webhdfs_compressor_hadoop_snappy.rb', line 11

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

Instance Method Details

#compress(chunk, tmp) ⇒ Object



24
25
26
27
28
29
# File 'lib/fluent/plugin/webhdfs_compressor_hadoop_snappy.rb', line 24

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

#extObject



20
21
22
# File 'lib/fluent/plugin/webhdfs_compressor_hadoop_snappy.rb', line 20

def ext
  ".snappy"
end