You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "stenlarsson (via GitHub)" <gi...@apache.org> on 2025/12/05 14:09:35 UTC
[PR] GH-48362: [GLib][Ruby] Add FixedSizeListArray [arrow]
stenlarsson opened a new pull request, #48369:
URL: https://github.com/apache/arrow/pull/48369
### Rationale for this change
The `FixedSizeListArray` class is not available in GLib/Ruby, and it can be the result of e.g. the `extract_regex_span` and `list_slice` compute functions.
### What changes are included in this PR?
This adds the `GArrowFixedSizeListArray` and `GArrowFixedSizeListArrayBuilder` to GLib.
### Are these changes tested?
Yes, with Ruby unit tests.
### Are there any user-facing changes?
Yes, new classes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48362: [GLib][Ruby] Add FixedSizeListArray [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #48369:
URL: https://github.com/apache/arrow/pull/48369#issuecomment-3617079297
:warning: GitHub issue #48362 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48362: [GLib][Ruby] Add FixedSizeListArray [arrow]
Posted by "stenlarsson (via GitHub)" <gi...@apache.org>.
stenlarsson commented on PR #48369:
URL: https://github.com/apache/arrow/pull/48369#issuecomment-3637960012
Thanks for the review @kou. Updated according to your suggestions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48362: [GLib][Ruby] Add FixedSizeListArray [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #48369:
URL: https://github.com/apache/arrow/pull/48369#issuecomment-3679943861
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit d5171c6b69b4bc987b1835efc4c1d104dfc05c5b.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/58667446574) has more details.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48362: [GLib][Ruby] Add FixedSizeListArray [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #48369:
URL: https://github.com/apache/arrow/pull/48369#discussion_r2594182257
##########
c_glib/test/test-fixed-size-list-array-builder.rb:
##########
@@ -0,0 +1,93 @@
+# 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 TestFixedSizeListArrayBuilder < Test::Unit::TestCase
+ include Helper::Buildable
+ include Helper::Omittable
+
+ def setup
+ require_gi_bindings(3, 1, 9)
+ end
+
+ def test_new
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ assert_equal(data_type, builder.value_data_type)
+ end
+
+ def test_append_value
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append second list: [3, 4]
+ builder.append_value
+ value_builder.append_value(3)
+ value_builder.append_value(4)
+
+ array = builder.finish
+ assert_equal(2, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
+ assert_equal([3, 4], array.get_value(1).length.times.collect {|i|
+ array.get_value(1).get_value(i)})
Review Comment:
```suggestion
assert_equal([1, 2], get_value(array, 0))
assert_equal([3, 4], get_value(array, 1))
```
##########
c_glib/test/test-fixed-size-list-array-builder.rb:
##########
@@ -0,0 +1,93 @@
+# 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 TestFixedSizeListArrayBuilder < Test::Unit::TestCase
+ include Helper::Buildable
+ include Helper::Omittable
+
+ def setup
+ require_gi_bindings(3, 1, 9)
+ end
+
+ def test_new
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ assert_equal(data_type, builder.value_data_type)
+ end
+
+ def test_append_value
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append second list: [3, 4]
+ builder.append_value
+ value_builder.append_value(3)
+ value_builder.append_value(4)
+
+ array = builder.finish
+ assert_equal(2, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
+ assert_equal([3, 4], array.get_value(1).length.times.collect {|i|
+ array.get_value(1).get_value(i)})
+ end
+
+ def test_append_null
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append null list
+ builder.append_null
+
+ # Append third list: [5, 6]
+ builder.append_value
+ value_builder.append_value(5)
+ value_builder.append_value(6)
+
+ array = builder.finish
+ assert_equal(3, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
+ assert_equal(true, array.null?(1))
+ assert_equal([5, 6], array.get_value(2).length.times.collect {|i|
+ array.get_value(2).get_value(i)})
Review Comment:
```suggestion
assert_equal([5, 6], get_value(array, 2))
```
##########
c_glib/test/test-fixed-size-list-array-builder.rb:
##########
@@ -0,0 +1,93 @@
+# 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 TestFixedSizeListArrayBuilder < Test::Unit::TestCase
+ include Helper::Buildable
+ include Helper::Omittable
+
+ def setup
+ require_gi_bindings(3, 1, 9)
+ end
+
Review Comment:
Could you define a helper method that gets the i-th value to shorten test code?
```suggestion
def get_value(array, i)
value = array.get_value(i)
value.length.times.collect do |j|
value.get_value(j)
end
end
```
##########
c_glib/test/test-fixed-size-list-array-builder.rb:
##########
@@ -0,0 +1,93 @@
+# 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 TestFixedSizeListArrayBuilder < Test::Unit::TestCase
+ include Helper::Buildable
+ include Helper::Omittable
+
+ def setup
+ require_gi_bindings(3, 1, 9)
+ end
+
+ def test_new
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ assert_equal(data_type, builder.value_data_type)
+ end
+
+ def test_append_value
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append second list: [3, 4]
+ builder.append_value
+ value_builder.append_value(3)
+ value_builder.append_value(4)
+
+ array = builder.finish
+ assert_equal(2, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
+ assert_equal([3, 4], array.get_value(1).length.times.collect {|i|
+ array.get_value(1).get_value(i)})
+ end
+
+ def test_append_null
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append null list
+ builder.append_null
+
+ # Append third list: [5, 6]
+ builder.append_value
+ value_builder.append_value(5)
+ value_builder.append_value(6)
+
+ array = builder.finish
+ assert_equal(3, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
+ assert_equal(true, array.null?(1))
Review Comment:
Could you use `assert` with block for predicate? It shows more useful information on failure.
```suggestion
assert do
array.null?(1)
end
```
##########
c_glib/test/test-fixed-size-list-array-builder.rb:
##########
@@ -0,0 +1,93 @@
+# 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 TestFixedSizeListArrayBuilder < Test::Unit::TestCase
+ include Helper::Buildable
+ include Helper::Omittable
+
+ def setup
+ require_gi_bindings(3, 1, 9)
+ end
+
+ def test_new
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ assert_equal(data_type, builder.value_data_type)
+ end
+
+ def test_append_value
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append second list: [3, 4]
+ builder.append_value
+ value_builder.append_value(3)
+ value_builder.append_value(4)
+
+ array = builder.finish
+ assert_equal(2, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
+ assert_equal([3, 4], array.get_value(1).length.times.collect {|i|
+ array.get_value(1).get_value(i)})
+ end
+
+ def test_append_null
+ field = Arrow::Field.new("value", Arrow::Int8DataType.new)
+ data_type = Arrow::FixedSizeListDataType.new(field, 2)
+ builder = Arrow::FixedSizeListArrayBuilder.new(data_type)
+ value_builder = builder.value_builder
+
+ # Append first list: [1, 2]
+ builder.append_value
+ value_builder.append_value(1)
+ value_builder.append_value(2)
+
+ # Append null list
+ builder.append_null
+
+ # Append third list: [5, 6]
+ builder.append_value
+ value_builder.append_value(5)
+ value_builder.append_value(6)
+
+ array = builder.finish
+ assert_equal(3, array.length)
+ assert_equal([1, 2], array.get_value(0).length.times.collect {|i|
+ array.get_value(0).get_value(i)})
Review Comment:
```suggestion
assert_equal([1, 2], get_value(array, 0))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-48362: [GLib][Ruby] Add FixedSizeListArray [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou merged PR #48369:
URL: https://github.com/apache/arrow/pull/48369
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org