Skip to content

Commit

Permalink
refactor: Simplify ZSTD compression implementation
Browse files Browse the repository at this point in the history
Use direct chunk.read method instead of intermediate StringIO.
This simplification maintains the same functionality while
making the code more straightforward and easier to understand.

Co-authored-by: Daijiro Fukuda <[email protected]>
Signed-off-by: ddukbg <[email protected]>
  • Loading branch information
ddukbg and daipom committed Nov 6, 2024
1 parent fa2a609 commit 08448a1
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/fluent/plugin/s3_compressor_zstd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ def content_type
end

def compress(chunk, tmp)
w = StringIO.new
chunk.write_to(w)
w.rewind
compressed = Zstd.compress(w.read, level: @compress_config.level)
tmp.binmode
tmp.rewind
compressed = Zstd.compress(chunk.read, level: @compress_config.level)
tmp.write(compressed)
tmp.rewind
rescue => e
log.warn "zstd compression failed: #{e.message}"
raise
Expand Down

0 comments on commit 08448a1

Please sign in to comment.