Class: ArrowFormat::UnionType

Inherits:
Type
  • Object
show all
Defined in:
lib/arrow-format/type.rb

Direct Known Subclasses

DenseUnionType, SparseUnionType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode, children, type_ids) ⇒ UnionType

Returns a new instance of UnionType.



962
963
964
965
966
967
968
# File 'lib/arrow-format/type.rb', line 962

def initialize(mode, children, type_ids)
  super()
  @mode = mode
  @children = children
  @type_ids = type_ids
  @type_indexes = {}
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



960
961
962
# File 'lib/arrow-format/type.rb', line 960

def children
  @children
end

#type_idsObject (readonly)

Returns the value of attribute type_ids.



961
962
963
# File 'lib/arrow-format/type.rb', line 961

def type_ids
  @type_ids
end

Instance Method Details

#resolve_type_index(type) ⇒ Object



970
971
972
# File 'lib/arrow-format/type.rb', line 970

def resolve_type_index(type)
  @type_indexes[type] ||= @type_ids.index(type)
end

#to_flatbuffersObject



981
982
983
984
985
986
# File 'lib/arrow-format/type.rb', line 981

def to_flatbuffers
  fb_type = FB::Union::Data.new
  fb_type.mode = FB::UnionMode.try_convert(@mode.to_s.capitalize)
  fb_type.type_ids = @type_ids
  fb_type
end

#to_sObject



974
975
976
977
978
979
# File 'lib/arrow-format/type.rb', line 974

def to_s
  children = @children.collect.with_index do |child, i|
    "#{child.name}: #{child.type}=#{@type_ids[i]}"
  end
  "#{super}<#{children.join(", ")}>"
end