kou commented on code in PR #48489:
URL: https://github.com/apache/arrow/pull/48489#discussion_r2637496375
##########
c_glib/arrow-glib/compute.cpp:
##########
@@ -7498,6 +7501,217 @@ garrow_list_flatten_options_new(void)
return GARROW_LIST_FLATTEN_OPTIONS(options);
}
+enum {
+ PROP_LIST_SLICE_OPTIONS_START = 1,
+ PROP_LIST_SLICE_OPTIONS_STOP,
+ PROP_LIST_SLICE_OPTIONS_STEP,
+ PROP_LIST_SLICE_OPTIONS_RETURN_FIXED_SIZE_LIST,
+};
+
+G_DEFINE_TYPE(GArrowListSliceOptions,
+ garrow_list_slice_options,
+ GARROW_TYPE_FUNCTION_OPTIONS)
+
+static void
+garrow_list_slice_options_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto options =
garrow_list_slice_options_get_raw(GARROW_LIST_SLICE_OPTIONS(object));
+
+ switch (prop_id) {
+ case PROP_LIST_SLICE_OPTIONS_START:
+ options->start = g_value_get_int64(value);
+ break;
+ case PROP_LIST_SLICE_OPTIONS_STOP:
+ {
+ gint64 stop_value = g_value_get_int64(value);
Review Comment:
```suggestion
auto stop_value = g_value_get_int64(value);
```
##########
c_glib/test/test-list-slice-options.rb:
##########
@@ -0,0 +1,122 @@
+# 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 TestListSliceOptions < Test::Unit::TestCase
+ include Helper::Buildable
+
+ def setup
+ @options = Arrow::ListSliceOptions.new
+ end
+
+ def test_start_property
+ assert_equal(0, @options.start)
+ @options.start = 2
+ assert_equal(2, @options.start)
+ end
+
+ def test_stop_property
+ assert_equal(Arrow::LIST_SLICE_OPTIONS_STOP_UNSPECIFIED, @options.stop)
+ @options.stop = 5
+ assert_equal(5, @options.stop)
+ @options.stop = Arrow::LIST_SLICE_OPTIONS_STOP_UNSPECIFIED
+ assert_equal(LIST_SLICE_OPTIONS_STOP_UNSPECIFIED, @options.stop)
Review Comment:
```suggestion
assert_equal(Arrow::LIST_SLICE_OPTIONS_STOP_UNSPECIFIED, @options.stop)
```
##########
ruby/red-arrow/lib/arrow/list-slice-options.rb:
##########
@@ -0,0 +1,64 @@
+# 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.
+
+module Arrow
+ class ListSliceOptions
+ alias_method :return_fixed_size_list_raw, :return_fixed_size_list
+ private :return_fixed_size_list_raw
+
+ RETURN_FIXED_SIZE_GLIB_TO_RUBY = {
+ ListSliceReturnFixedSizeList::AUTO => nil,
+ ListSliceReturnFixedSizeList::TRUE => true,
+ ListSliceReturnFixedSizeList::FALSE => false,
+ }.freeze
+
+ RETURN_FIXED_SIZE_RUBY_TO_GLIB =
RETURN_FIXED_SIZE_GLIB_TO_RUBY.invert.freeze
+
+ # Whether to return a FixedSizeListArray. If true _and_ stop is after a
+ # list element’s length, nil values will be appended to create the
requested
+ # slice size. The default of nil will return the same type which was
passed in.
+ def return_fixed_size_list
+ RETURN_FIXED_SIZE_GLIB_TO_RUBY.fetch(
+ return_fixed_size_list_raw,
+ return_fixed_size_list_raw)
+ end
+
+ # Whether to return a FixedSizeListArray. If true _and_ stop is after a
+ # list element’s length, nil values will be appended to create the
requested
+ # slice size. The default of nil will return the same type which was
passed in.
Review Comment:
```suggestion
# slice size. The default of nil will return the same type which was
passed in.
#
# @since 23.0.0
```
##########
ruby/red-arrow/lib/arrow/list-slice-options.rb:
##########
@@ -0,0 +1,64 @@
+# 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.
+
+module Arrow
+ class ListSliceOptions
+ alias_method :return_fixed_size_list_raw, :return_fixed_size_list
+ private :return_fixed_size_list_raw
+
+ RETURN_FIXED_SIZE_GLIB_TO_RUBY = {
+ ListSliceReturnFixedSizeList::AUTO => nil,
+ ListSliceReturnFixedSizeList::TRUE => true,
+ ListSliceReturnFixedSizeList::FALSE => false,
+ }.freeze
+
+ RETURN_FIXED_SIZE_RUBY_TO_GLIB =
RETURN_FIXED_SIZE_GLIB_TO_RUBY.invert.freeze
+
+ # Whether to return a FixedSizeListArray. If true _and_ stop is after a
+ # list element’s length, nil values will be appended to create the
requested
+ # slice size. The default of nil will return the same type which was
passed in.
Review Comment:
```suggestion
# slice size. The default of nil will return the same type which was
passed in.
#
# @since 23.0.0
```
##########
ruby/red-arrow/lib/arrow/list-slice-options.rb:
##########
@@ -0,0 +1,64 @@
+# 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.
+
+module Arrow
+ class ListSliceOptions
+ alias_method :return_fixed_size_list_raw, :return_fixed_size_list
+ private :return_fixed_size_list_raw
+
+ RETURN_FIXED_SIZE_GLIB_TO_RUBY = {
+ ListSliceReturnFixedSizeList::AUTO => nil,
+ ListSliceReturnFixedSizeList::TRUE => true,
+ ListSliceReturnFixedSizeList::FALSE => false,
+ }.freeze
+
+ RETURN_FIXED_SIZE_RUBY_TO_GLIB =
RETURN_FIXED_SIZE_GLIB_TO_RUBY.invert.freeze
+
+ # Whether to return a FixedSizeListArray. If true _and_ stop is after a
+ # list element’s length, nil values will be appended to create the
requested
+ # slice size. The default of nil will return the same type which was
passed in.
+ def return_fixed_size_list
+ RETURN_FIXED_SIZE_GLIB_TO_RUBY.fetch(
+ return_fixed_size_list_raw,
+ return_fixed_size_list_raw)
+ end
+
+ # Whether to return a FixedSizeListArray. If true _and_ stop is after a
+ # list element’s length, nil values will be appended to create the
requested
+ # slice size. The default of nil will return the same type which was
passed in.
+ def return_fixed_size_list=(return_fixed_size_list)
+ set_property(
+ :return_fixed_size_list,
+ RETURN_FIXED_SIZE_RUBY_TO_GLIB.fetch(
+ return_fixed_size_list,
+ return_fixed_size_list))
Review Comment:
Could you define `return_fixed_size_list_raw=` alias and use it here?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]