]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow/lib/arrow/dictionary-data-type.rb
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
19 class DictionaryDataType
20 alias_method
:initialize_raw, :initialize
21 private :initialize_raw
23 # Creates a new {Arrow::DictionaryDataType}.
25 # @overload initialize(index_data_type, value_data_type, ordered)
27 # @param index_data_type [Arrow::DataType, Hash, String, Symbol]
28 # The index data type of the dictionary data type. It must be
29 # signed integer data types. Here are available signed integer
32 # * Arrow::Int8DataType
33 # * Arrow::Int16DataType
34 # * Arrow::Int32DataType
35 # * Arrow::Int64DataType
37 # You can specify data type as a description by `Hash`.
39 # See {Arrow::DataType.resolve} how to specify data type
42 # @param value_data_type [Arrow::DataType, Hash, String, Symbol]
43 # The value data type of the dictionary data type.
45 # You can specify data type as a description by `Hash`.
47 # See {Arrow::DataType.resolve} how to specify data type
50 # @param ordered [Boolean] Whether dictionary contents are
53 # @example Create a dictionary data type for `{0: "Hello", 1: "World"}`
54 # index_data_type = :int8
55 # value_data_type = :string
57 # Arrow::DictionaryDataType.new(index_data_type,
61 # @overload initialize(description)
63 # @param description [Hash] The description of the dictionary
64 # data type. It must have `:index_data_type`, `:dictionary`
65 # and `:ordered` values.
67 # @option description [Arrow::DataType, Hash, String, Symbol]
68 # :index_data_type The index data type of the dictionary data
69 # type. It must be signed integer data types. Here are
70 # available signed integer data types:
72 # * Arrow::Int8DataType
73 # * Arrow::Int16DataType
74 # * Arrow::Int32DataType
75 # * Arrow::Int64DataType
77 # You can specify data type as a description by `Hash`.
79 # See {Arrow::DataType.resolve} how to specify data type
82 # @option description [Arrow::DataType, Hash, String, Symbol]
84 # The value data type of the dictionary data type.
86 # You can specify data type as a description by `Hash`.
88 # See {Arrow::DataType.resolve} how to specify data type
91 # @option description [Boolean] :ordered Whether dictionary
92 # contents are ordered or not.
94 # @example Create a dictionary data type for `{0: "Hello", 1: "World"}`
95 # Arrow::DictionaryDataType.new(index_data_type: :int8,
96 # value_data_type: :string,
102 description
= args
[0]
103 index_data_type
= description
[:index_data_type]
104 value_data_type
= description
[:value_data_type]
105 ordered
= description
[:ordered]
107 index_data_type
, value_data_type
, ordered
= args
109 message
= "wrong number of arguments (given, #{n_args}, expected 1 or 3)"
110 raise ArgumentError
, message
112 index_data_type
= DataType
.resolve(index_data_type
)
113 value_data_type
= DataType
.resolve(value_data_type
)
114 initialize_raw(index_data_type
, value_data_type
, ordered
)