Class: ArrowFormat::DenseUnionArray

Inherits:
UnionArray show all
Defined in:
lib/arrow-format/array.rb

Instance Attribute Summary

Attributes inherited from UnionArray

#children, #types_buffer

Attributes inherited from Array

#offset, #size, #type, #validity_buffer

Instance Method Summary collapse

Methods inherited from UnionArray

#each_type

Methods inherited from Array

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

Constructor Details

#initialize(type, size, types_buffer, offsets_buffer, children) ⇒ DenseUnionArray

Returns a new instance of DenseUnionArray.



725
726
727
728
729
730
731
732
# File 'lib/arrow-format/array.rb', line 725

def initialize(type,
               size,
               types_buffer,
               offsets_buffer,
               children)
  super(type, size, types_buffer, children)
  @offsets_buffer = offsets_buffer
end

Instance Method Details

#each_buffer {|@types_buffer| ... } ⇒ Object

Yields:



734
735
736
737
738
739
740
# File 'lib/arrow-format/array.rb', line 734

def each_buffer(&block)
  return to_enum(__method__) unless block_given?

  # TODO: Dictionary delta support (slice support)
  yield(@types_buffer)
  yield(@offsets_buffer)
end

#each_offset(&block) ⇒ Object



742
743
744
745
746
747
748
749
750
751
752
# File 'lib/arrow-format/array.rb', line 742

def each_offset(&block)
  return [].each(&block) if empty?

  return to_enum(__method__) unless block_given?

  @offsets_buffer.each(@type.offset_buffer_type,
                       offset_element_size * @offset,
                       @size) do |_, offset|
    yield(offset)
  end
end

#to_aObject



754
755
756
757
758
759
760
761
762
# File 'lib/arrow-format/array.rb', line 754

def to_a
  return [] if empty?

  children_values = @children.collect(&:to_a)
  each_type.zip(each_offset).collect do |type, offset|
    index = @type.resolve_type_index(type)
    children_values[index][offset]
  end
end