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

GH-44337: [CI][GLib] Fix a flaky StreamDecoder and Buffer test #44341

Merged
merged 1 commit into from
Oct 9, 2024
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
9 changes: 8 additions & 1 deletion c_glib/test/test-stream-decoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ def test_consume_bytes
end

def test_consume_buffer
# We need to keep data that aren't processed yet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make any sense to proactively change test_consume_bytes too? Line 71 in this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. We don't need to change test_consume_bytes.
arrow::ipc::StreamDecoder::Consume(const uint8_t* data, int64_t size) copied the given data internally when they aren't enough size.
(arrow::ipc::StreamDecoder::Consume(std::shared_ptr<Buffer> buffer) refers them instead of copying.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't the Buffer object keep the Ruby object alive? PyArrow wouldn't have this problem AFAIR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we can do it by creating a sub Buffer class: #44349

data = []
@buffer.data.to_s.each_byte do |byte|
@decoder.consume_buffer(Arrow::Buffer.new(byte.chr))
data << byte.chr
can_clear = (@decoder.next_required_size == 1)
@decoder.consume_buffer(Arrow::Buffer.new(data.last))
# We can release a reference for kept data after they are
# processed.
data.clear if can_clear
end
assert_equal([
[:schema_decoded, @schema, @schema],
Expand Down
Loading