Class: ArrowFormat::PrimitiveArray

Inherits:
Array
  • Object
show all
Defined in:
lib/arrow-format/array.rb

Instance Attribute Summary

Attributes inherited from Array

#offset, #size, #type, #validity_buffer

Instance Method Summary collapse

Methods inherited from Array

#empty?, #n_nulls, #null?, #slice, #valid?

Constructor Details

#initialize(type, size, validity_buffer, values_buffer) ⇒ PrimitiveArray

Returns a new instance of PrimitiveArray.



161
162
163
164
# File 'lib/arrow-format/array.rb', line 161

def initialize(type, size, validity_buffer, values_buffer)
  super(type, size, validity_buffer)
  @values_buffer = values_buffer
end

Instance Method Details

#each_buffer {|slice_bitmap_buffer(:validity, @validity_buffer)| ... } ⇒ Object

Yields:



173
174
175
176
177
178
179
180
# File 'lib/arrow-format/array.rb', line 173

def each_buffer
  return to_enum(__method__) unless block_given?

  yield(slice_bitmap_buffer(:validity, @validity_buffer))
  yield(slice_fixed_element_size_buffer(:values,
                                        @values_buffer,
                                        element_size))
end

#to_aObject



166
167
168
169
170
171
# File 'lib/arrow-format/array.rb', line 166

def to_a
  return [] if empty?

  offset = element_size * @offset
  apply_validity(@values_buffer.values(@type.buffer_type, offset, @size))
end