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, dictionary, ordered) ⇒ DictionaryDataType #initialize(description) ⇒ DictionaryDataType

Creates a new Arrow::DictionaryDataType.

Overloads:

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

    Examples:

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

    index_data_type = :int8
    dictionary = Arrow::StringArray.new(["Hello", "World"])
    ordered = true
    Arrow::DictionaryDataType.new(index_data_type,
                                  dictionary,
                                  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.

    • dictionary (Arrow::Array)

      The real values of the dictionary data type.

    • ordered (Boolean)

      Whether dictionary contents are ordered or not.

  • #initialize(description) ⇒ DictionaryDataType

    Examples:

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

    dictionary = Arrow::StringArray.new(["Hello", "World"])
    Arrow::DictionaryDataType.new(index_data_type: :int8,
                                  dictionary: dictionary,
                                  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.

    • :dictionary (Arrow::Array)

      The real values of the dictionary data type.

    • :ordered (Boolean)

      Whether dictionary contents are ordered or not.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/arrow/dictionary-data-type.rb', line 88

def initialize(*args)
  n_args = args.size
  case n_args
  when 1
    description = args[0]
    index_data_type = description[:index_data_type]
    dictionary = description[:dictionary]
    ordered = description[:ordered]
  when 3
    index_data_type, dictionary, 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)
  initialize_raw(index_data_type, dictionary, ordered)
end