Class: Nanoarrow::ArrayStream

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoarrow/array_stream.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj, schema = nil) ⇒ ArrayStream

Returns a new instance of ArrayStream.



3
4
5
# File 'lib/nanoarrow/array_stream.rb', line 3

def initialize(obj, schema = nil)
  @c_array_stream = Utils.c_array_stream(obj, schema)
end

Instance Method Details

#arrow_c_streamObject



11
12
13
# File 'lib/nanoarrow/array_stream.rb', line 11

def arrow_c_stream
  @c_array_stream.arrow_c_stream
end

#eachObject



24
25
26
27
28
29
30
# File 'lib/nanoarrow/array_stream.rb', line 24

def each
  return to_enum(:each) unless block_given?

  while (c_array = @c_array_stream.get_next)
    yield Array.new(CMaterializedArrayStream.from_c_array(c_array))
  end
end

#read_allObject



15
16
17
# File 'lib/nanoarrow/array_stream.rb', line 15

def read_all
  Array.new(@c_array_stream)
end

#read_nextObject



19
20
21
22
# File 'lib/nanoarrow/array_stream.rb', line 19

def read_next
  c_array = @c_array_stream.get_next
  Array.new(CMaterializedArrayStream.from_c_array(c_array)) if c_array
end

#schemaObject



7
8
9
# File 'lib/nanoarrow/array_stream.rb', line 7

def schema
  Schema.new(@c_array_stream.get_cached_schema)
end