Class: Fluent::Plugin::WebHDFSOutput::ZstdCompressor

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

Instance Method Summary collapse

Methods inherited from Compressor

#configure, #initialise

Constructor Details

#initialize(options = {}) ⇒ ZstdCompressor

Returns a new instance of ZstdCompressor.



6
7
8
9
10
11
12
# File 'lib/fluent/plugin/webhdfs_compressor_zstd.rb', line 6

def initialize(options = {})
  begin
    require "zstandard"
  rescue LoadError
    raise Fluent::ConfigError, "Install zstandard gem before use of zstd compressor"
  end
end

Instance Method Details

#compress(chunk, tmp) ⇒ Object



18
19
20
21
# File 'lib/fluent/plugin/webhdfs_compressor_zstd.rb', line 18

def compress(chunk, tmp)
  tmp.binmode
  tmp.write Zstandard.deflate(chunk.read)
end

#extObject



14
15
16
# File 'lib/fluent/plugin/webhdfs_compressor_zstd.rb', line 14

def ext
  ".zst"
end