Class: Nanoarrow::ArrayFromIterableBuilder

Inherits:
ArrayBuilder show all
Defined in:
lib/nanoarrow/array_builder.rb

Instance Method Summary collapse

Methods inherited from ArrayBuilder

#build_c_array

Constructor Details

#initialize(schema) ⇒ ArrayFromIterableBuilder

Returns a new instance of ArrayFromIterableBuilder.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nanoarrow/array_builder.rb', line 18

def initialize(schema)
  super(schema)

  type_id = @schema_view.type_id
  if !ARRAY_BUILDER_FROM_ITERABLE_METHOD.include?(type_id)
    raise ArgumentError, "Can't build array of type #{@schema_view.type} from iterable"
  end

  method_name = ARRAY_BUILDER_FROM_ITERABLE_METHOD.fetch(type_id)
  @append_impl = method(method_name)
end

Instance Method Details

#append(obj) ⇒ Object



34
35
36
# File 'lib/nanoarrow/array_builder.rb', line 34

def append(obj)
  @append_impl.(obj)
end

#finish_buildingObject



38
39
40
# File 'lib/nanoarrow/array_builder.rb', line 38

def finish_building
  @c_builder.finish
end

#start_buildingObject



30
31
32
# File 'lib/nanoarrow/array_builder.rb', line 30

def start_building
  @c_builder.start_appending
end