Class: Arrow::MapDataType

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

Instance Method Summary collapse

Constructor Details

#initialize(key, item) ⇒ MapDataType #initialize(description) ⇒ MapDataType

Creates a new Arrow::MapDataType.

Overloads:

  • #initialize(key, item) ⇒ MapDataType

    Examples:

    Create a map data type for ‘“Hello”, 1: “World”`

    key = :int8
    item = :string
    Arrow::MapDataType.new(key, item)

    Parameters:

    • key (Arrow::DataType, Hash, String, Symbol)

      The key data type of the map data type.

      You can specify data type as a description by ‘Hash`.

      See DataType.resolve how to specify data type description.

    • item (Arrow::DataType, Hash, String, Symbol)

      The item data type of the map data type.

      You can specify data type as a description by ‘Hash`.

      See DataType.resolve how to specify data type description.

  • #initialize(description) ⇒ MapDataType

    Examples:

    Create a map data type for ‘“Hello”, 1: “World”`

    Arrow::MapDataType.new(key: :int8, item: :string)

    Parameters:

    • description (Hash)

      The description of the map data type. It must have ‘:key`, `:item` values.

    Options Hash (description):

    • :key (Arrow::DataType, Hash, String, Symbol)

      The key data type of the map data type.

      You can specify data type as a description by ‘Hash`.

      See DataType.resolve how to specify data type description.

    • :item (Arrow::DataType, Hash, String, Symbol)

      The item data type of the map data type.

      You can specify data type as a description by ‘Hash`.

      See DataType.resolve how to specify data type description.



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

def initialize(*args)
  n_args = args.size
  case n_args
  when 1
    description = args[0]
    key = description[:key]
    item = description[:item]
  when 2
    key, item = args
  else
    message = "wrong number of arguments (given, #{n_args}, expected 1..2)"
    raise ArgumentError, message
  end
  key = DataType.resolve(key)
  item = DataType.resolve(item)
  initialize_raw(key, item)
end