Skip to content

Commit

Permalink
chunk: add fast path to join chunk data
Browse files Browse the repository at this point in the history
Signed-off-by: Shizuo Fujita <[email protected]>
  • Loading branch information
Watson1978 committed Jan 10, 2025
1 parent 43437e6 commit a16c0cd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/fluent/plugin/buffer/chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ def modified_at
# data is array of formatted record string
def append(data, **kwargs)
raise ArgumentError, '`compress: gzip` can be used for Compressable module' if kwargs[:compress] == :gzip
adding = ''.b
data.each do |d|
adding << d.b
begin
adding = data.join.force_encoding(Encoding::ASCII_8BIT)
rescue
# Fallback
# Array#join throws an exception if data contains strings with a different encoding.
# Although such cases may be rare, it should be considered as a safety precaution.
adding = ''.force_encoding(Encoding::ASCII_8BIT)
data.each do |d|
adding << d.b
end
end
concat(adding, data.size)
end
Expand Down

0 comments on commit a16c0cd

Please sign in to comment.