Class: Arrow::DictionaryDataType

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

Instance Method Summary collapse

Constructor Details

#initialize(index_data_type, value_data_type, ordered) ⇒ DictionaryDataType #initialize(description) ⇒ DictionaryDataType

Creates a new Arrow::DictionaryDataType.

Overloads:

  • #initialize(index_data_type, value_data_type, ordered) ⇒ DictionaryDataType

    Examples:

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

    index_data_type = :int8
    value_data_type = :string
    ordered = true
    Arrow::DictionaryDataType.new(index_data_type,
                                  value_data_type,
                                  ordered)

    Parameters:

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

      The index data type of the dictionary data type. It must be signed integer data types. Here are available signed integer data types:

      * Arrow::Int8DataType
      * Arrow::Int16DataType
      * Arrow::Int32DataType
      * Arrow::Int64DataType
      

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

      See Arrow::DataType.resolve how to specify data type description.

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

      The value data type of the dictionary data type.

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

      See Arrow::DataType.resolve how to specify data type description.

    • ordered (Boolean)

      Whether dictionary contents are ordered or not.

  • #initialize(description) ⇒ DictionaryDataType

    Examples:

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

    Arrow::DictionaryDataType.new(index_data_type: :int8,
                                  value_data_type: :string,
                                  ordered: true)

    Parameters:

    • description (Hash)

      The description of the dictionary data type. It must have ‘:index_data_type`, `:dictionary` and `:ordered` values.

    Options Hash (description):

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

      The index data type of the dictionary data type. It must be signed integer data types. Here are available signed integer data types:

      * Arrow::Int8DataType
      * Arrow::Int16DataType
      * Arrow::Int32DataType
      * Arrow::Int64DataType
      

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

      See Arrow::DataType.resolve how to specify data type description.

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

      The value data type of the dictionary data type.

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

      See Arrow::DataType.resolve how to specify data type description.

    • :ordered (Boolean)

      Whether dictionary contents are ordered or not.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/arrow/dictionary-data-type.rb', line 98

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