Skip to content

Commit

Permalink
GH-39488: [Ruby] Add support for ChunkedArray in Ractor
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 7, 2024
1 parent 37a8bf0 commit ff4ed07
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ruby/red-arrow/lib/arrow/chunked-array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class ChunkedArray
include GenericTakeable
include InputReferable

def freeze
unless frozen?
# Ensure caching
chunks
end
super
end

def to_arrow
self
end
Expand Down
31 changes: 31 additions & 0 deletions ruby/red-arrow/test/test-ractor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

class RactorTest < Test::Unit::TestCase
ractor
test("ChunkedArray") do
array = Arrow::Array.new([1, 2, 3])
chunked_array = Arrow::ChunkedArray.new([array])
Ractor.make_shareable(chunked_array)
ractor = Ractor.new do
recived_chunked_array = Ractor.receive
recived_chunked_array.chunks
end
ractor.send(chunked_array)
assert_equal([array], ractor.take)
end
end

0 comments on commit ff4ed07

Please sign in to comment.