Skip to content

Commit 7e28a32

Browse files
ddukbgdaipom
andcommitted
refactor: Remove unnecessary whitespace
Remove redundant spaces to improve code readability and consistency Co-authored-by: Daijiro Fukuda <[email protected]> Signed-off-by: ddukbg <[email protected]> refactor: Simplify data compression logic refactor: Simplify data compression logic Remove duplicate file reading and streamline compression process Co-authored-by: Daijiro Fukuda <[email protected]> Signed-off-by: ddukbg <[email protected]>
1 parent 0ad8cdf commit 7e28a32

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

lib/fluent/plugin/out_s3.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,7 @@ def content_type
641641
end
642642

643643
def compress(chunk, tmp)
644-
uncompressed_data = ''
645-
chunk.open do |io|
646-
uncompressed_data = io.read
647-
end
648-
compressed_data = Zstd.compress(uncompressed_data, level: @level)
644+
compressed_data = Zstd.compress(chunk.read, level: @level)
649645
tmp.write(compressed_data)
650646
rescue => e
651647
log.warn "zstd compression failed: #{e.message}"

test/test_out_s3.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,20 +467,20 @@ def test_write_with_custom_s3_object_key_format_containing_hex_random_placeholde
467467
def test_write_with_zstd
468468
setup_mocks(true)
469469
s3_local_file_path = "/tmp/s3-test.zst"
470-
470+
471471
expected_s3path = "log/events/ts=20110102-13/events_0-#{Socket.gethostname}.zst"
472-
472+
473473
setup_s3_object_mocks(s3_local_file_path: s3_local_file_path, s3path: expected_s3path)
474-
474+
475475
config = CONFIG_TIME_SLICE + "\nstore_as zstd\n"
476476
d = create_time_sliced_driver(config)
477-
477+
478478
time = event_time("2011-01-02 13:14:15 UTC")
479479
d.run(default_tag: "test") do
480480
d.feed(time, { "a" => 1 })
481481
d.feed(time, { "a" => 2 })
482482
end
483-
483+
484484
File.open(s3_local_file_path, 'rb') do |file|
485485
compressed_data = file.read
486486
uncompressed_data = Zstd.decompress(compressed_data)

0 commit comments

Comments
 (0)