Class: Arrow::SparseUnionDataType

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow/sparse-union-data-type.rb

Instance Method Summary collapse

Constructor Details

#initialize(fields, type_codes) ⇒ SparseUnionDataType #initialize(description) ⇒ SparseUnionDataType

Overloads:

  • #initialize(fields, type_codes) ⇒ SparseUnionDataType

    Examples:

    Create a sparse union data type for visible, 9: count

    fields = [
      Arrow::Field.new("visible", :boolean),
      {
        name: "count",
        type: :int32,
      },
    ]
    Arrow::SparseUnionDataType.new(fields, [2, 9])

    Parameters:

    • fields (::Array<Arrow::Field, Hash>)

      The fields of the sparse union data type. You can mix Field and field description in the fields.

      See Field.new how to specify field description.

    • type_codes (::Array<Integer>)

      The IDs that indicates corresponding fields.

  • #initialize(description) ⇒ SparseUnionDataType

    Examples:

    Create a sparse union data type for visible, 9: count

    fields = [
      Arrow::Field.new("visible", :boolean),
      {
        name: "count",
        type: :int32,
      },
    ]
    Arrow::SparseUnionDataType.new(fields: fields,
                                   type_codes: [2, 9])

    Parameters:

    • description (Hash)

      The description of the sparse union data type. It must have ‘:fields` and `:type_codes` values.

    Options Hash (description):

    • :fields (::Array<Arrow::Field, Hash>)

      The fields of the sparse union data type. You can mix Field and field description in the fields.

      See Field.new how to specify field description.

    • :type_codes (::Array<Integer>)

      The IDs that indicates corresponding fields.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/arrow/sparse-union-data-type.rb', line 70

def initialize(*args)
  n_args = args.size
  case n_args
  when 1
    description = args[0]
    fields = description[:fields]
    type_codes = description[:type_codes]
  when 2
    fields, type_codes = args
  else
    message = "wrong number of arguments (given, #{n_args}, expected 1..2)"
    raise ArgumentError, message
  end
  fields = fields.collect do |field|
    field = Field.new(field) unless field.is_a?(Field)
    field
  end
  initialize_raw(fields, type_codes)
end