red-arrow 8.0.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -7
  3. data/ext/arrow/arrow.cpp +67 -0
  4. data/ext/arrow/converters.cpp +10 -0
  5. data/ext/arrow/converters.hpp +310 -46
  6. data/ext/arrow/extconf.rb +41 -22
  7. data/ext/arrow/raw-records.cpp +165 -2
  8. data/ext/arrow/red-arrow.hpp +2 -0
  9. data/ext/arrow/values.cpp +6 -2
  10. data/lib/arrow/array-builder.rb +89 -14
  11. data/{test/test-time32-data-type.rb → lib/arrow/array-computable.rb} +24 -16
  12. data/{test/test-buffer.rb → lib/arrow/array-statistics.rb} +19 -24
  13. data/lib/arrow/array.rb +40 -4
  14. data/lib/arrow/chunked-array.rb +56 -1
  15. data/lib/arrow/column-containable.rb +9 -0
  16. data/lib/arrow/column.rb +49 -4
  17. data/{test/test-tensor.rb → lib/arrow/csv-write-options.rb} +28 -31
  18. data/lib/arrow/data-type.rb +17 -3
  19. data/lib/arrow/decimal128-array-builder.rb +16 -6
  20. data/lib/arrow/decimal128.rb +14 -0
  21. data/lib/arrow/decimal256-array-builder.rb +16 -6
  22. data/lib/arrow/decimal256.rb +14 -0
  23. data/{test/test-float-scalar.rb → lib/arrow/dense-union-array-builder.rb} +27 -24
  24. data/{test/test-boolean-scalar.rb → lib/arrow/dense-union-array.rb} +7 -7
  25. data/lib/arrow/duration-array-builder.rb +27 -0
  26. data/lib/arrow/duration-array.rb +24 -0
  27. data/lib/arrow/duration-data-type.rb +32 -0
  28. data/lib/arrow/expression.rb +6 -2
  29. data/lib/arrow/field-containable.rb +1 -1
  30. data/lib/arrow/field.rb +44 -3
  31. data/lib/arrow/fixed-size-list-array-builder.rb +29 -0
  32. data/lib/arrow/fixed-size-list-data-type.rb +118 -0
  33. data/lib/arrow/function.rb +0 -1
  34. data/lib/arrow/half-float-array-builder.rb +32 -0
  35. data/lib/arrow/half-float-array.rb +24 -0
  36. data/lib/arrow/half-float.rb +118 -0
  37. data/{test/helper/fixture.rb → lib/arrow/input-referable.rb} +7 -6
  38. data/lib/arrow/jruby/array-builder.rb +114 -0
  39. data/lib/arrow/jruby/array.rb +109 -0
  40. data/lib/arrow/jruby/chunked-array.rb +36 -0
  41. data/lib/arrow/jruby/compression-type.rb +26 -0
  42. data/lib/arrow/jruby/csv-read-options.rb +32 -0
  43. data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
  44. data/lib/arrow/jruby/decimal128.rb +28 -0
  45. data/lib/arrow/jruby/decimal256.rb +28 -0
  46. data/{test/fixture/float-integer.csv → lib/arrow/jruby/error.rb} +7 -4
  47. data/lib/arrow/jruby/file-system.rb +24 -0
  48. data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
  49. data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
  50. data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/record-batch.rb} +8 -4
  51. data/{test/fixture/integer-float.csv → lib/arrow/jruby/sort-key.rb} +8 -4
  52. data/lib/arrow/jruby/sort-options.rb +24 -0
  53. data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
  54. data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
  55. data/lib/arrow/jruby/writable.rb +24 -0
  56. data/lib/arrow/jruby.rb +52 -0
  57. data/{test/test-date32-array.rb → lib/arrow/large-list-array-builder.rb} +10 -5
  58. data/lib/arrow/large-list-data-type.rb +83 -0
  59. data/lib/arrow/libraries.rb +140 -0
  60. data/lib/arrow/list-array-builder.rb +1 -68
  61. data/lib/arrow/list-data-type.rb +3 -38
  62. data/{test/test-dictionary-array.rb → lib/arrow/list-field-resolvable.rb} +26 -17
  63. data/lib/arrow/list-slice-options.rb +76 -0
  64. data/lib/arrow/list-values-appendable.rb +88 -0
  65. data/lib/arrow/loader.rb +15 -96
  66. data/{test/test-decimal128-array.rb → lib/arrow/make-struct-options.rb} +18 -18
  67. data/lib/arrow/raw-table-converter.rb +10 -3
  68. data/lib/arrow/raw-tensor-converter.rb +89 -0
  69. data/lib/arrow/record-batch-file-reader.rb +2 -0
  70. data/lib/arrow/record-batch-stream-reader.rb +2 -0
  71. data/lib/arrow/record-batch.rb +6 -2
  72. data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +5 -4
  73. data/lib/arrow/scalar.rb +67 -0
  74. data/lib/arrow/slicer.rb +61 -0
  75. data/lib/arrow/sort-key.rb +3 -3
  76. data/lib/arrow/sparse-union-array-builder.rb +56 -0
  77. data/lib/arrow/sparse-union-array.rb +26 -0
  78. data/lib/arrow/stream-decoder.rb +29 -0
  79. data/{test/test-decimal256-data-type.rb → lib/arrow/stream-listener.rb} +25 -9
  80. data/lib/arrow/string-array-builder.rb +30 -0
  81. data/lib/arrow/struct-array-builder.rb +0 -5
  82. data/lib/arrow/table-formatter.rb +38 -8
  83. data/lib/arrow/table-list-formatter.rb +3 -3
  84. data/lib/arrow/table-loader.rb +11 -5
  85. data/lib/arrow/table-saver.rb +4 -3
  86. data/lib/arrow/table-table-formatter.rb +7 -0
  87. data/lib/arrow/table.rb +180 -33
  88. data/lib/arrow/tensor.rb +144 -0
  89. data/lib/arrow/time-unit.rb +31 -0
  90. data/lib/arrow/time32-array-builder.rb +2 -14
  91. data/lib/arrow/time32-data-type.rb +9 -38
  92. data/lib/arrow/time64-array-builder.rb +2 -14
  93. data/lib/arrow/time64-data-type.rb +9 -38
  94. data/lib/arrow/timestamp-array-builder.rb +3 -15
  95. data/lib/arrow/timestamp-data-type.rb +9 -34
  96. data/{test/test-date64-array.rb → lib/arrow/timestamp-parser.rb} +14 -6
  97. data/lib/arrow/union-array-builder.rb +59 -0
  98. data/lib/arrow/union-array.rb +26 -0
  99. data/lib/arrow/version.rb +1 -1
  100. data/lib/arrow.rb +2 -7
  101. data/red-arrow.gemspec +74 -11
  102. metadata +85 -210
  103. data/test/fixture/TestOrcFile.test1.orc +0 -0
  104. data/test/fixture/with-header-float.csv +0 -20
  105. data/test/fixture/with-header.csv +0 -20
  106. data/test/fixture/without-header-float.csv +0 -19
  107. data/test/fixture/without-header.csv +0 -19
  108. data/test/helper/omittable.rb +0 -36
  109. data/test/helper.rb +0 -30
  110. data/test/raw-records/test-basic-arrays.rb +0 -395
  111. data/test/raw-records/test-dense-union-array.rb +0 -521
  112. data/test/raw-records/test-list-array.rb +0 -610
  113. data/test/raw-records/test-map-array.rb +0 -478
  114. data/test/raw-records/test-multiple-columns.rb +0 -65
  115. data/test/raw-records/test-sparse-union-array.rb +0 -511
  116. data/test/raw-records/test-struct-array.rb +0 -515
  117. data/test/raw-records/test-table.rb +0 -47
  118. data/test/run-test.rb +0 -71
  119. data/test/test-array-builder.rb +0 -136
  120. data/test/test-array.rb +0 -325
  121. data/test/test-bigdecimal.rb +0 -40
  122. data/test/test-binary-dictionary-array-builder.rb +0 -103
  123. data/test/test-chunked-array.rb +0 -183
  124. data/test/test-column.rb +0 -92
  125. data/test/test-csv-loader.rb +0 -250
  126. data/test/test-data-type.rb +0 -83
  127. data/test/test-decimal128-array-builder.rb +0 -112
  128. data/test/test-decimal128-data-type.rb +0 -31
  129. data/test/test-decimal128.rb +0 -102
  130. data/test/test-decimal256-array-builder.rb +0 -112
  131. data/test/test-decimal256-array.rb +0 -38
  132. data/test/test-decimal256.rb +0 -102
  133. data/test/test-dense-union-data-type.rb +0 -41
  134. data/test/test-dictionary-data-type.rb +0 -40
  135. data/test/test-expression.rb +0 -40
  136. data/test/test-feather.rb +0 -49
  137. data/test/test-field.rb +0 -91
  138. data/test/test-file-output-stream.rb +0 -54
  139. data/test/test-fixed-size-binary-array-builder.rb +0 -92
  140. data/test/test-fixed-size-binary-array.rb +0 -36
  141. data/test/test-function.rb +0 -210
  142. data/test/test-group.rb +0 -180
  143. data/test/test-list-array-builder.rb +0 -79
  144. data/test/test-list-array.rb +0 -32
  145. data/test/test-list-data-type.rb +0 -69
  146. data/test/test-map-array-builder.rb +0 -110
  147. data/test/test-map-array.rb +0 -33
  148. data/test/test-memory-view.rb +0 -434
  149. data/test/test-orc.rb +0 -173
  150. data/test/test-record-batch-builder.rb +0 -125
  151. data/test/test-record-batch-file-reader.rb +0 -115
  152. data/test/test-record-batch-iterator.rb +0 -37
  153. data/test/test-record-batch-reader.rb +0 -46
  154. data/test/test-record-batch.rb +0 -182
  155. data/test/test-schema.rb +0 -134
  156. data/test/test-slicer.rb +0 -487
  157. data/test/test-sort-indices.rb +0 -40
  158. data/test/test-sort-key.rb +0 -81
  159. data/test/test-sort-options.rb +0 -58
  160. data/test/test-sparse-union-data-type.rb +0 -41
  161. data/test/test-string-dictionary-array-builder.rb +0 -103
  162. data/test/test-struct-array-builder.rb +0 -184
  163. data/test/test-struct-array.rb +0 -94
  164. data/test/test-struct-data-type.rb +0 -112
  165. data/test/test-table.rb +0 -1123
  166. data/test/test-time.rb +0 -288
  167. data/test/test-time32-array.rb +0 -81
  168. data/test/test-time64-array.rb +0 -81
  169. data/test/test-time64-data-type.rb +0 -42
  170. data/test/test-timestamp-array.rb +0 -45
  171. data/test/test-timestamp-data-type.rb +0 -42
  172. data/test/values/test-basic-arrays.rb +0 -325
  173. data/test/values/test-dense-union-array.rb +0 -509
  174. data/test/values/test-dictionary-array.rb +0 -295
  175. data/test/values/test-list-array.rb +0 -571
  176. data/test/values/test-map-array.rb +0 -466
  177. data/test/values/test-sparse-union-array.rb +0 -500
  178. data/test/values/test-struct-array.rb +0 -512
@@ -1,103 +0,0 @@
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
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
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
16
- # under the License.
17
-
18
- class StringDictionaryArrayBuilderTest < Test::Unit::TestCase
19
- def setup
20
- @builder = Arrow::StringDictionaryArrayBuilder.new
21
- end
22
-
23
- sub_test_case("#append_values") do
24
- test("[nil]") do
25
- @builder.append_values([nil])
26
- array = @builder.finish
27
- assert_equal([
28
- [],
29
- [nil],
30
- ],
31
- [
32
- array.dictionary.to_a,
33
- array.indices.to_a,
34
- ])
35
- end
36
-
37
- test("[String]") do
38
- @builder.append_values(["hello"])
39
- array = @builder.finish
40
- assert_equal([
41
- ["hello"],
42
- [0],
43
- ],
44
- [
45
- array.dictionary.to_a,
46
- array.indices.to_a,
47
- ])
48
- end
49
-
50
- test("[Symbol]") do
51
- @builder.append_values([:hello])
52
- array = @builder.finish
53
- assert_equal([
54
- ["hello"],
55
- [0],
56
- ],
57
- [
58
- array.dictionary.to_a,
59
- array.indices.to_a,
60
- ])
61
- end
62
-
63
- test("[nil, String, Symbol]") do
64
- @builder.append_values([
65
- nil,
66
- "Hello",
67
- :world,
68
- "world",
69
- ])
70
- array = @builder.finish
71
- assert_equal([
72
- ["Hello", "world"],
73
- [nil, 0, 1, 1],
74
- ],
75
- [
76
- array.dictionary.to_a,
77
- array.indices.to_a,
78
- ])
79
- end
80
-
81
- test("is_valids") do
82
- @builder.append_values([
83
- "Hello",
84
- :world,
85
- :goodbye,
86
- ],
87
- [
88
- true,
89
- false,
90
- true,
91
- ])
92
- array = @builder.finish
93
- assert_equal([
94
- ["Hello", "goodbye"],
95
- [0, nil, 1],
96
- ],
97
- [
98
- array.dictionary.to_a,
99
- array.indices.to_a,
100
- ])
101
- end
102
- end
103
- end
@@ -1,184 +0,0 @@
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
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
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
16
- # under the License.
17
-
18
- class StructArrayBuilderTest < Test::Unit::TestCase
19
- def setup
20
- @data_type = Arrow::StructDataType.new(visible: {type: :boolean},
21
- count: {type: :uint64})
22
- @builder = Arrow::StructArrayBuilder.new(@data_type)
23
- end
24
-
25
- sub_test_case("#append_value") do
26
- test("nil") do
27
- @builder.append_value(nil)
28
- array = @builder.finish
29
- assert_equal([
30
- [false],
31
- [0],
32
- ],
33
- [
34
- array.find_field(0).to_a,
35
- array.find_field(1).to_a,
36
- ])
37
- end
38
-
39
- test("Array") do
40
- @builder.append_value([true, 1])
41
- @builder.append_value([])
42
- @builder.append_value([false])
43
- array = @builder.finish
44
- assert_equal([
45
- [true, nil, false],
46
- [1, nil, nil],
47
- ],
48
- [
49
- array.find_field(0).to_a,
50
- array.find_field(1).to_a,
51
- ])
52
- end
53
-
54
- test("Arrow::Struct") do
55
- source_array = Arrow::StructArray.new(@data_type, [[true, 1]])
56
- struct = source_array.get_value(0)
57
- @builder.append_value(struct)
58
- array = @builder.finish
59
- assert_equal([
60
- [true],
61
- [1],
62
- ],
63
- [
64
- array.find_field(0).to_a,
65
- array.find_field(1).to_a,
66
- ])
67
- end
68
-
69
- test("Hash") do
70
- @builder.append_value(count: 1, visible: true)
71
- @builder.append_value(visible: false)
72
- @builder.append_value(count: 2)
73
- array = @builder.finish
74
- assert_equal([
75
- [true, false, nil],
76
- [1, nil, 2],
77
- ],
78
- [
79
- array.find_field(0).to_a,
80
- array.find_field(1).to_a,
81
- ])
82
- end
83
- end
84
-
85
- sub_test_case("#append_values") do
86
- test("[nil]") do
87
- @builder.append_values([nil])
88
- array = @builder.finish
89
- assert_equal([
90
- [false],
91
- [0],
92
- ],
93
- [
94
- array.find_field(0).to_a,
95
- array.find_field(1).to_a,
96
- ])
97
- end
98
-
99
- test("[Array]") do
100
- @builder.append_values([[true, 1]])
101
- array = @builder.finish
102
- assert_equal([
103
- [true],
104
- [1],
105
- ],
106
- [
107
- array.find_field(0).to_a,
108
- array.find_field(1).to_a,
109
- ])
110
- end
111
-
112
- test("[Hash]") do
113
- @builder.append_values([{count: 1, visible: true}])
114
- array = @builder.finish
115
- assert_equal([
116
- [true],
117
- [1],
118
- ],
119
- [
120
- array.find_field(0).to_a,
121
- array.find_field(1).to_a,
122
- ])
123
- end
124
-
125
- test("[nil, Array, Hash]") do
126
- @builder.append_values([
127
- nil,
128
- [true, 1],
129
- {count: 2, visible: false},
130
- ])
131
- array = @builder.finish
132
- assert_equal([
133
- [false, true, false],
134
- [0, 1, 2],
135
- ],
136
- [
137
- array.find_field(0).to_a,
138
- array.find_field(1).to_a,
139
- ])
140
- end
141
-
142
- test("is_valids") do
143
- @builder.append_values([
144
- [true, 1],
145
- [false, 2],
146
- [true, 3],
147
- ],
148
- [
149
- true,
150
- false,
151
- true,
152
- ])
153
- array = @builder.finish
154
- assert_equal([
155
- [true, false, true],
156
- [1, 0, 3],
157
- ],
158
- [
159
- array.find_field(0).to_a,
160
- array.find_field(1).to_a,
161
- ])
162
- end
163
- end
164
-
165
- sub_test_case("#append") do
166
- test("backward compatibility") do
167
- @builder.append
168
- @builder.get_field_builder(0).append(true)
169
- @builder.get_field_builder(1).append(1)
170
- @builder.append
171
- @builder.get_field_builder(0).append(false)
172
- @builder.get_field_builder(1).append(2)
173
- array = @builder.finish
174
- assert_equal([
175
- {"visible" => true, "count" => 1},
176
- {"visible" => false, "count" => 2},
177
- ],
178
- [
179
- array.get_value(0),
180
- array.get_value(1),
181
- ])
182
- end
183
- end
184
- end
@@ -1,94 +0,0 @@
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
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
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
16
- # under the License.
17
-
18
- class StructArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("build") do
21
- data_type = Arrow::StructDataType.new(visible: :boolean,
22
- count: :uint64)
23
- values = [
24
- [true, 1],
25
- nil,
26
- [false, 2],
27
- ]
28
- array = Arrow::StructArray.new(data_type, values)
29
- assert_equal([
30
- [true, false, false],
31
- [1, 0, 2],
32
- ],
33
- [
34
- array.find_field(0).to_a,
35
- array.find_field(1).to_a,
36
- ])
37
- end
38
- end
39
-
40
- sub_test_case("instance methods") do
41
- def setup
42
- @data_type = Arrow::StructDataType.new(visible: {type: :boolean},
43
- count: {type: :uint64})
44
- @values = [
45
- [true, 1],
46
- [false, 2],
47
- ]
48
- @array = Arrow::StructArray.new(@data_type, @values)
49
- end
50
-
51
- test("#[]") do
52
- assert_equal([
53
- {"visible" => true, "count" => 1},
54
- {"visible" => false, "count" => 2},
55
- ],
56
- @array.to_a)
57
- end
58
-
59
- test("#get_value") do
60
- assert_equal([
61
- {"visible" => true, "count" => 1},
62
- {"visible" => false, "count" => 2},
63
- ],
64
- [
65
- @array.get_value(0),
66
- @array.get_value(1),
67
- ])
68
- end
69
-
70
- sub_test_case("#find_field") do
71
- test("Integer") do
72
- assert_equal([
73
- [true, false],
74
- [1, 2],
75
- ],
76
- [
77
- @array.find_field(0).to_a,
78
- @array.find_field(1).to_a,
79
- ])
80
- end
81
-
82
- test("String, Symbol") do
83
- assert_equal([
84
- [true, false],
85
- [1, 2],
86
- ],
87
- [
88
- @array.find_field("visible").to_a,
89
- @array.find_field(:count).to_a,
90
- ])
91
- end
92
- end
93
- end
94
- end
@@ -1,112 +0,0 @@
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
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
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
16
- # under the License.
17
-
18
- class StructDataTypeTest < Test::Unit::TestCase
19
- def setup
20
- @count_field = Arrow::Field.new("count", :uint32)
21
- @visible_field = Arrow::Field.new("visible", :boolean)
22
- end
23
-
24
- sub_test_case(".new") do
25
- test("[Arrow::Field]") do
26
- fields = [
27
- @count_field,
28
- @visible_field,
29
- ]
30
- assert_equal("struct<count: uint32, visible: bool>",
31
- Arrow::StructDataType.new(fields).to_s)
32
- end
33
-
34
- test("[Hash]") do
35
- fields = [
36
- {name: "count", data_type: :uint32},
37
- {name: "visible", data_type: :boolean},
38
- ]
39
- assert_equal("struct<count: uint32, visible: bool>",
40
- Arrow::StructDataType.new(fields).to_s)
41
- end
42
-
43
- test("[Arrow::Field, Hash]") do
44
- fields = [
45
- @count_field,
46
- {name: "visible", data_type: :boolean},
47
- ]
48
- assert_equal("struct<count: uint32, visible: bool>",
49
- Arrow::StructDataType.new(fields).to_s)
50
- end
51
-
52
- test("{Arrow::DataType}") do
53
- fields = {
54
- "count" => Arrow::UInt32DataType.new,
55
- "visible" => Arrow::BooleanDataType.new,
56
- }
57
- assert_equal("struct<count: uint32, visible: bool>",
58
- Arrow::StructDataType.new(fields).to_s)
59
- end
60
-
61
- test("{Hash}") do
62
- fields = {
63
- "count" => {type: :uint32},
64
- "visible" => {type: :boolean},
65
- }
66
- assert_equal("struct<count: uint32, visible: bool>",
67
- Arrow::StructDataType.new(fields).to_s)
68
- end
69
-
70
- test("{String, Symbol}") do
71
- fields = {
72
- "count" => "uint32",
73
- "visible" => :boolean,
74
- }
75
- assert_equal("struct<count: uint32, visible: bool>",
76
- Arrow::StructDataType.new(fields).to_s)
77
- end
78
- end
79
-
80
- sub_test_case("instance methods") do
81
- def setup
82
- super
83
- @data_type = Arrow::StructDataType.new([@count_field, @visible_field])
84
- end
85
-
86
- sub_test_case("#[]") do
87
- test("[String]") do
88
- assert_equal([@count_field, @visible_field],
89
- [@data_type["count"], @data_type["visible"]])
90
- end
91
-
92
- test("[Symbol]") do
93
- assert_equal([@count_field, @visible_field],
94
- [@data_type[:count], @data_type[:visible]])
95
- end
96
-
97
- test("[Integer]") do
98
- assert_equal([@count_field, @visible_field],
99
- [@data_type[0], @data_type[1]])
100
- end
101
-
102
- test("[invalid]") do
103
- invalid = []
104
- message = "field name or index must be String, Symbol or Integer"
105
- message << ": <#{invalid.inspect}>"
106
- assert_raise(ArgumentError.new(message)) do
107
- @data_type[invalid]
108
- end
109
- end
110
- end
111
- end
112
- end