Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunk: add fast path to join chunk data #4765

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
daipom marked this conversation as resolved.
Show resolved Hide resolved
end
end
concat(adding, data.size)
end
Expand Down
Loading