MCPcopy Create free account
hub / github.com/apache/arrow / resolve

Method resolve

ruby/red-arrow/lib/arrow/array.rb:238–268  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
270end

Callers 13

resolve_data_typeMethod · 0.45
add_sort_keyMethod · 0.45
add_column_typeMethod · 0.45
initializeMethod · 0.45
initializeMethod · 0.45
build_bufferMethod · 0.45
indexMethod · 0.45
initializeMethod · 0.45
initializeMethod · 0.45
SortKeyTestClass · 0.45
ScalarTestClass · 0.45
ArrayTestClass · 0.45

Calls 6

builder_classMethod · 0.80
buildable?Method · 0.45
buildMethod · 0.45
value_data_typeMethod · 0.45
castMethod · 0.45
inspectMethod · 0.45

Tested by

no test coverage detected