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
data/test/test-time.rb DELETED
@@ -1,288 +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 TimeTest < Test::Unit::TestCase
19
- sub_test_case("#==") do
20
- test("same unit") do
21
- assert do
22
- Arrow::Time.new(:second, 10) == Arrow::Time.new(:second, 10)
23
- end
24
- end
25
-
26
- test("different unit") do
27
- assert do
28
- Arrow::Time.new(:second, 10) == Arrow::Time.new(:milli, 10 * 1000)
29
- end
30
- end
31
-
32
- test("false") do
33
- assert do
34
- not(Arrow::Time.new(:second, 10) == Arrow::Time.new(:second, 11))
35
- end
36
- end
37
- end
38
-
39
- sub_test_case("#cast") do
40
- test("same unit") do
41
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
42
- casted_time = time.cast(Arrow::TimeUnit::SECOND)
43
- assert_equal([time.unit, time.value],
44
- [casted_time.unit, casted_time.value])
45
- end
46
-
47
- test("second -> milli") do
48
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
49
- casted_time = time.cast(Arrow::TimeUnit::MILLI)
50
- assert_equal([
51
- Arrow::TimeUnit::MILLI,
52
- time.value * 1000,
53
- ],
54
- [
55
- casted_time.unit,
56
- casted_time.value,
57
- ])
58
- end
59
-
60
- test("second -> micro") do
61
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
62
- casted_time = time.cast(Arrow::TimeUnit::MICRO)
63
- assert_equal([
64
- Arrow::TimeUnit::MICRO,
65
- time.value * 1000 * 1000,
66
- ],
67
- [
68
- casted_time.unit,
69
- casted_time.value,
70
- ])
71
- end
72
-
73
- test("second -> nano") do
74
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
75
- casted_time = time.cast(Arrow::TimeUnit::NANO)
76
- assert_equal([
77
- Arrow::TimeUnit::NANO,
78
- time.value * 1000 * 1000 * 1000,
79
- ],
80
- [
81
- casted_time.unit,
82
- casted_time.value,
83
- ])
84
- end
85
-
86
- test("milli -> second") do
87
- time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
88
- casted_time = time.cast(Arrow::TimeUnit::SECOND)
89
- assert_equal([
90
- Arrow::TimeUnit::SECOND,
91
- 10,
92
- ],
93
- [
94
- casted_time.unit,
95
- casted_time.value,
96
- ])
97
- end
98
-
99
- test("milli -> micro") do
100
- time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
101
- casted_time = time.cast(Arrow::TimeUnit::MICRO)
102
- assert_equal([
103
- Arrow::TimeUnit::MICRO,
104
- time.value * 1000,
105
- ],
106
- [
107
- casted_time.unit,
108
- casted_time.value,
109
- ])
110
- end
111
-
112
- test("milli -> nano") do
113
- time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
114
- casted_time = time.cast(Arrow::TimeUnit::NANO)
115
- assert_equal([
116
- Arrow::TimeUnit::NANO,
117
- time.value * 1000 * 1000,
118
- ],
119
- [
120
- casted_time.unit,
121
- casted_time.value,
122
- ])
123
- end
124
-
125
- test("micro -> second") do
126
- time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
127
- casted_time = time.cast(Arrow::TimeUnit::SECOND)
128
- assert_equal([
129
- Arrow::TimeUnit::SECOND,
130
- 10,
131
- ],
132
- [
133
- casted_time.unit,
134
- casted_time.value,
135
- ])
136
- end
137
-
138
- test("micro -> milli") do
139
- time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
140
- casted_time = time.cast(Arrow::TimeUnit::MILLI)
141
- assert_equal([
142
- Arrow::TimeUnit::MILLI,
143
- 10_200,
144
- ],
145
- [
146
- casted_time.unit,
147
- casted_time.value,
148
- ])
149
- end
150
-
151
- test("micro -> nano") do
152
- time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
153
- casted_time = time.cast(Arrow::TimeUnit::NANO)
154
- assert_equal([
155
- Arrow::TimeUnit::NANO,
156
- time.value * 1000,
157
- ],
158
- [
159
- casted_time.unit,
160
- casted_time.value,
161
- ])
162
- end
163
-
164
- test("nano -> second") do
165
- time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
166
- casted_time = time.cast(Arrow::TimeUnit::SECOND)
167
- assert_equal([
168
- Arrow::TimeUnit::SECOND,
169
- 10,
170
- ],
171
- [
172
- casted_time.unit,
173
- casted_time.value,
174
- ])
175
- end
176
-
177
- test("nano -> milli") do
178
- time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
179
- casted_time = time.cast(Arrow::TimeUnit::MILLI)
180
- assert_equal([
181
- Arrow::TimeUnit::MILLI,
182
- 10_200,
183
- ],
184
- [
185
- casted_time.unit,
186
- casted_time.value,
187
- ])
188
- end
189
-
190
- test("nano -> micro") do
191
- time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
192
- casted_time = time.cast(Arrow::TimeUnit::MICRO)
193
- assert_equal([
194
- Arrow::TimeUnit::MICRO,
195
- 10_200_300,
196
- ],
197
- [
198
- casted_time.unit,
199
- casted_time.value,
200
- ])
201
- end
202
- end
203
-
204
- sub_test_case("#to_f") do
205
- test("second") do
206
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
207
- assert_in_delta(10.0, time.to_f)
208
- end
209
-
210
- test("milli") do
211
- time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
212
- assert_in_delta(10.2, time.to_f)
213
- end
214
-
215
- test("micro") do
216
- time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
217
- assert_in_delta(10.2003, time.to_f)
218
- end
219
-
220
- test("nano") do
221
- time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
222
- assert_in_delta(10.2003004, time.to_f)
223
- end
224
- end
225
-
226
- sub_test_case("#positive?") do
227
- test("true") do
228
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
229
- assert do
230
- time.positive?
231
- end
232
- end
233
-
234
- test("false") do
235
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, -10)
236
- assert do
237
- not time.positive?
238
- end
239
- end
240
- end
241
-
242
- sub_test_case("#negative?") do
243
- test("true") do
244
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, -10)
245
- assert do
246
- time.negative?
247
- end
248
- end
249
-
250
- test("false") do
251
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
252
- assert do
253
- not time.negative?
254
- end
255
- end
256
- end
257
-
258
- test("#hour") do
259
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
260
- (5 * 60 * 60) + (12 * 60) + 10)
261
- assert_equal(5, time.hour)
262
- end
263
-
264
- test("#minute") do
265
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
266
- (5 * 60 * 60) + (12 * 60) + 10)
267
- assert_equal(12, time.minute)
268
- end
269
-
270
- test("#second") do
271
- time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
272
- (5 * 60 * 60) + (12 * 60) + 10)
273
- assert_equal(10, time.second)
274
- end
275
-
276
- test("#nano_second") do
277
- time = Arrow::Time.new(Arrow::TimeUnit::NANO, 1234)
278
- assert_equal(1234, time.nano_second)
279
- end
280
-
281
- test("#to_s") do
282
- time = Arrow::Time.new(Arrow::TimeUnit::NANO,
283
- -(((5 * 60 * 60) + (12 * 60) + 10) * 1_000_000_000 +
284
- 1234))
285
- assert_equal("-05:12:10.000001234",
286
- time.to_s)
287
- end
288
- end
@@ -1,81 +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 Time32ArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- sub_test_case("unit") do
21
- test("Arrow::TimeUnit") do
22
- values = [1000 * 10, nil]
23
- array = Arrow::Time32Array.new(Arrow::TimeUnit::MILLI, values)
24
- assert_equal([
25
- "time32[ms]",
26
- [
27
- Arrow::Time.new(Arrow::TimeUnit::MILLI,
28
- 1000 * 10),
29
- nil,
30
- ],
31
- ],
32
- [
33
- array.value_data_type.to_s,
34
- array.to_a,
35
- ])
36
- end
37
-
38
- test("Symbol") do
39
- values = [60 * 10, nil]
40
- array = Arrow::Time32Array.new(:second, values)
41
- assert_equal([
42
- "time32[s]",
43
- [
44
- Arrow::Time.new(Arrow::TimeUnit::SECOND,
45
- 60 * 10),
46
- nil,
47
- ],
48
- ],
49
- [
50
- array.value_data_type.to_s,
51
- array.to_a,
52
- ])
53
- end
54
- end
55
-
56
- sub_test_case("values") do
57
- test("Arrow::Time") do
58
- data_type = Arrow::Time32DataType.new(:second)
59
- values = [
60
- Arrow::Time.new(Arrow::TimeUnit::SECOND,
61
- 60 * 10),
62
- nil,
63
- ]
64
- array = Arrow::Time32Array.new(data_type, values)
65
- assert_equal(values, array.to_a)
66
- end
67
-
68
- test("Integer") do
69
- data_type = Arrow::Time32DataType.new(:second)
70
- values = [60 * 10, nil]
71
- array = Arrow::Time32Array.new(data_type, values)
72
- assert_equal([
73
- Arrow::Time.new(Arrow::TimeUnit::SECOND,
74
- 60 * 10),
75
- nil,
76
- ],
77
- array.to_a)
78
- end
79
- end
80
- end
81
- end
@@ -1,81 +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 Time64ArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- sub_test_case("unit") do
21
- test("Arrow::TimeUnit") do
22
- values = [1000 * 10, nil]
23
- array = Arrow::Time64Array.new(Arrow::TimeUnit::NANO, values)
24
- assert_equal([
25
- "time64[ns]",
26
- [
27
- Arrow::Time.new(Arrow::TimeUnit::NANO,
28
- 1000 * 10),
29
- nil,
30
- ],
31
- ],
32
- [
33
- array.value_data_type.to_s,
34
- array.to_a,
35
- ])
36
- end
37
-
38
- test("Symbol") do
39
- values = [1000 * 10, nil]
40
- array = Arrow::Time64Array.new(:micro, values)
41
- assert_equal([
42
- "time64[us]",
43
- [
44
- Arrow::Time.new(Arrow::TimeUnit::MICRO,
45
- 1000 * 10),
46
- nil,
47
- ],
48
- ],
49
- [
50
- array.value_data_type.to_s,
51
- array.to_a,
52
- ])
53
- end
54
- end
55
-
56
- sub_test_case("values") do
57
- test("Arrow::Time") do
58
- data_type = Arrow::Time64DataType.new(:nano)
59
- values = [
60
- Arrow::Time.new(Arrow::TimeUnit::NANO,
61
- 1000 * 10),
62
- nil,
63
- ]
64
- array = Arrow::Time64Array.new(data_type, values)
65
- assert_equal(values, array.to_a)
66
- end
67
-
68
- test("Integer") do
69
- data_type = Arrow::Time64DataType.new(:nano)
70
- values = [1000 * 10, nil]
71
- array = Arrow::Time64Array.new(data_type, values)
72
- assert_equal([
73
- Arrow::Time.new(Arrow::TimeUnit::NANO,
74
- 1000 * 10),
75
- nil,
76
- ],
77
- array.to_a)
78
- end
79
- end
80
- end
81
- end
@@ -1,42 +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 Time64DataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("Arrow::TimeUnit") do
21
- assert_equal("time64[ns]",
22
- Arrow::Time64DataType.new(Arrow::TimeUnit::NANO).to_s)
23
- end
24
-
25
- test("Symbol") do
26
- assert_equal("time64[ns]",
27
- Arrow::Time64DataType.new(:nano).to_s)
28
- end
29
-
30
- test("unit: Arrow::TimeUnit") do
31
- data_type = Arrow::Time64DataType.new(unit: Arrow::TimeUnit::NANO)
32
- assert_equal("time64[ns]",
33
- data_type.to_s)
34
- end
35
-
36
- test("unit: Symbol") do
37
- data_type = Arrow::Time64DataType.new(unit: :nano)
38
- assert_equal("time64[ns]",
39
- data_type.to_s)
40
- end
41
- end
42
- end
@@ -1,45 +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 TimestampArrayTest < Test::Unit::TestCase
19
- test("#[]") do
20
- sec = 1513267750
21
- usec = 914509
22
- array = Arrow::TimestampArray.new(:micro, [sec * (10 ** 6) + usec])
23
- time = Time.at(sec, usec)
24
- assert_equal(time, array[0])
25
- end
26
-
27
- sub_test_case("#is_in") do
28
- def setup
29
- values = [
30
- Time.parse("2019-11-18T00:09:11"),
31
- Time.parse("2019-11-18T00:09:12"),
32
- Time.parse("2019-11-18T00:09:13"),
33
- ]
34
- @array = Arrow::TimestampArray.new(:micro, values)
35
- end
36
-
37
- test("Arrow: Array") do
38
- right = [
39
- Time.parse("2019-11-18T00:09:12"),
40
- ]
41
- assert_equal(Arrow::BooleanArray.new([false, true, false]),
42
- @array.is_in(right))
43
- end
44
- end
45
- end
@@ -1,42 +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 TimestampDataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("Arrow::TimeUnit") do
21
- assert_equal("timestamp[ms]",
22
- Arrow::TimestampDataType.new(Arrow::TimeUnit::MILLI).to_s)
23
- end
24
-
25
- test("Symbol") do
26
- assert_equal("timestamp[ms]",
27
- Arrow::TimestampDataType.new(:milli).to_s)
28
- end
29
-
30
- test("unit: Arrow::TimeUnit") do
31
- data_type = Arrow::TimestampDataType.new(unit: Arrow::TimeUnit::MILLI)
32
- assert_equal("timestamp[ms]",
33
- data_type.to_s)
34
- end
35
-
36
- test("unit: Symbol") do
37
- data_type = Arrow::TimestampDataType.new(unit: :milli)
38
- assert_equal("timestamp[ms]",
39
- data_type.to_s)
40
- end
41
- end
42
- end