kou commented on a change in pull request #10937:
URL: https://github.com/apache/arrow/pull/10937#discussion_r690922785



##########
File path: ruby/red-arrow/test/test-map-data-type.rb
##########
@@ -0,0 +1,36 @@
+# 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 MapDataTypeTest < Test::Unit::TestCase
+  sub_test_case(".new") do
+    def setup
+      @key = :int8
+      @item = :string
+    end
+
+    test("ordered arguments") do
+      assert_equal("map<int8, string>",
+                   Arrow::MapDataType.new(@key, @item).to_s)
+    end
+
+    test("description") do
+      assert_equal("map<int8, string>",
+                   Arrow::MapDataType.new(key: @key,
+                                          item: @item,).to_s)

Review comment:
       ```suggestion
                                             item: @item).to_s)
   ```

##########
File path: ruby/red-arrow/test/values/test-sparse-union-array.rb
##########
@@ -373,6 +373,20 @@ def test_struct
     assert_equal(values, target.values)
   end
 
+  def test_map
+    values = [
+      {"0" => {"key1" => true}},
+      {"1" => nil},
+      {"0" => {"key2" => nil}},
+    ]
+    target = build({
+                     type: :map,
+                     key: :string,
+                     item: :boolean,
+                   },
+                   values)
+    assert_equal(values, target.values)
+  end

Review comment:
       ```suggestion
     end
   
   ```

##########
File path: ruby/red-arrow/lib/arrow/map-array-builder.rb
##########
@@ -0,0 +1,109 @@
+# 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 MapArrayBuilder
+    class << self
+      def build(data_type, values)
+        builder = new(data_type)
+        builder.build(values)
+      end
+    end
+
+    alias_method :append_value_raw, :append_value
+
+    # @overload append_value
+    #
+    #   Starts appending a map record. You need to append
+    #   values of map by {#key_builder} and {#item_builder}.
+    #
+    # @overload append_value(value)
+    #
+    #   Appends a map record including key and item values.
+    #
+    #   @param value [nil, #each] The map record.
+    #
+    #     If this is `nil`, the map record is null.
+    #
+    #     If this is an `Object` that has `#each`, each value is a pair of key 
and item.
+    #
+    # @since 5.0.0

Review comment:
       ```suggestion
       # @since 6.0.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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to