Ensures returning the same data type array from the given array. @return [Arrow::Array] @overload resolve(other_raw_array) @param other_raw_array [::Array] A raw Ruby Array. A new Arrow::Array is built by `self.class.new`. @example Raw Ruby Array int32_array = Arrow::Int32Array.new([1]) other_array = int32_array.resolve([2, 3, 4]) other_array # => Arrow::Int32Array.new([2, 3, 4]) @overload re
(other_array)
| 236 | # |
| 237 | # @since 4.0.0 |
| 238 | def resolve(other_array) |
| 239 | if other_array.is_a?(::Array) |
| 240 | builder_class = self.class.builder_class |
| 241 | if builder_class.nil? |
| 242 | message = |
| 243 | "[array][resolve] can't build #{value_data_type} array " + |
| 244 | "from raw Ruby Array" |
| 245 | raise ArgumentError, message |
| 246 | end |
| 247 | if builder_class.buildable?([other_array]) |
| 248 | other_array = builder_class.build(other_array) |
| 249 | elsif builder_class.buildable?([value_data_type, other_array]) |
| 250 | other_array = builder_class.build(value_data_type, other_array) |
| 251 | else |
| 252 | message = |
| 253 | "[array][resolve] need to implement " + |
| 254 | "a feature that building #{value_data_type} array " + |
| 255 | "from raw Ruby Array" |
| 256 | raise NotImplementedError, message |
| 257 | end |
| 258 | other_array |
| 259 | elsif other_array.respond_to?(:value_data_type) |
| 260 | return other_array if value_data_type == other_array.value_data_type |
| 261 | other_array.cast(value_data_type) |
| 262 | else |
| 263 | message = |
| 264 | "[array][resolve] can't build #{value_data_type} array: " + |
| 265 | "#{other_array.inspect}" |
| 266 | raise ArgumentError, message |
| 267 | end |
| 268 | end |
| 269 | end |
| 270 | end |
no test coverage detected