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-slicer.rb DELETED
@@ -1,487 +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 SlicerTest < Test::Unit::TestCase
19
- def setup
20
- @count_field = Arrow::Field.new("count", :uint32)
21
- @visible_field = Arrow::Field.new("visible", :boolean)
22
- schema = Arrow::Schema.new([@count_field, @visible_field])
23
- count_arrays = [
24
- Arrow::UInt32Array.new([0, 1, 2]),
25
- Arrow::UInt32Array.new([4, 8, 16]),
26
- Arrow::UInt32Array.new([32, 64, nil]),
27
- Arrow::UInt32Array.new([256]),
28
- ]
29
- visible_arrays = [
30
- Arrow::BooleanArray.new([nil, true, false, nil]),
31
- Arrow::BooleanArray.new([true]),
32
- Arrow::BooleanArray.new([true, false]),
33
- Arrow::BooleanArray.new([nil]),
34
- Arrow::BooleanArray.new([nil]),
35
- Arrow::BooleanArray.new([true]),
36
- ]
37
- @count_array = Arrow::ChunkedArray.new(count_arrays)
38
- @visible_array = Arrow::ChunkedArray.new(visible_arrays)
39
- @table = Arrow::Table.new(schema, [@count_array, @visible_array])
40
- end
41
-
42
- sub_test_case("column") do
43
- test("BooleanArray") do
44
- sliced_table = @table.slice do |slicer|
45
- slicer.visible
46
- end
47
- assert_equal(<<-TABLE, sliced_table.to_s)
48
- count visible
49
- 0 (null) (null)
50
- 1 1 true
51
- 2 (null) (null)
52
- 3 8 true
53
- 4 16 true
54
- 5 (null) (null)
55
- 6 (null) (null)
56
- 7 256 true
57
- TABLE
58
- end
59
-
60
- test("not BooleanArray") do
61
- sliced_table = @table.slice do |slicer|
62
- slicer.count
63
- end
64
- assert_equal(<<-TABLE, sliced_table.to_s)
65
- count visible
66
- 0 1 true
67
- 1 2 false
68
- 2 4 (null)
69
- 3 8 true
70
- 4 16 true
71
- 5 32 false
72
- 6 64 (null)
73
- 7 (null) (null)
74
- 8 256 true
75
- TABLE
76
- end
77
- end
78
-
79
- sub_test_case("!column") do
80
- test("BooleanArray") do
81
- sliced_table = @table.slice do |slicer|
82
- !slicer.visible
83
- end
84
- assert_equal(<<-TABLE, sliced_table.to_s)
85
- count visible
86
- 0 (null) (null)
87
- 1 2 false
88
- 2 (null) (null)
89
- 3 32 false
90
- 4 (null) (null)
91
- 5 (null) (null)
92
- TABLE
93
- end
94
-
95
- test("not BooleanArray") do
96
- sliced_table = @table.slice do |slicer|
97
- !slicer.count
98
- end
99
- assert_equal(<<-TABLE, sliced_table.to_s)
100
- count visible
101
- 0 0 (null)
102
- 1 (null) (null)
103
- TABLE
104
- end
105
- end
106
-
107
- test("column.null?") do
108
- sliced_table = @table.slice do |slicer|
109
- slicer.visible.null?
110
- end
111
- assert_equal(<<-TABLE, sliced_table.to_s)
112
- count visible
113
- 0 0 (null)
114
- 1 4 (null)
115
- 2 64 (null)
116
- 3 (null) (null)
117
- TABLE
118
- end
119
-
120
- test("column.valid?") do
121
- sliced_table = @table.slice do |slicer|
122
- slicer.visible.valid?
123
- end
124
- assert_equal(<<-TABLE, sliced_table.to_s)
125
- count visible
126
- 0 1 true
127
- 1 2 false
128
- 2 8 true
129
- 3 16 true
130
- 4 32 false
131
- 5 256 true
132
- TABLE
133
- end
134
-
135
- sub_test_case("column ==") do
136
- test("nil") do
137
- sliced_table = @table.slice do |slicer|
138
- slicer.visible == nil
139
- end
140
- assert_equal(<<-TABLE, sliced_table.to_s)
141
- count visible
142
- 0 0 (null)
143
- 1 4 (null)
144
- 2 64 (null)
145
- 3 (null) (null)
146
- TABLE
147
- end
148
-
149
- test("value") do
150
- sliced_table = @table.slice do |slicer|
151
- slicer.visible == true
152
- end
153
- assert_equal(<<-TABLE, sliced_table.to_s)
154
- count visible
155
- 0 (null) (null)
156
- 1 1 true
157
- 2 (null) (null)
158
- 3 8 true
159
- 4 16 true
160
- 5 (null) (null)
161
- 6 (null) (null)
162
- 7 256 true
163
- TABLE
164
- end
165
- end
166
-
167
- sub_test_case("!(column ==)") do
168
- test("nil") do
169
- sliced_table = @table.slice do |slicer|
170
- !(slicer.visible == nil)
171
- end
172
- assert_equal(<<-TABLE, sliced_table.to_s)
173
- count visible
174
- 0 1 true
175
- 1 2 false
176
- 2 8 true
177
- 3 16 true
178
- 4 32 false
179
- 5 256 true
180
- TABLE
181
- end
182
-
183
- test("value") do
184
- sliced_table = @table.slice do |slicer|
185
- !(slicer.visible == true)
186
- end
187
- assert_equal(<<-TABLE, sliced_table.to_s)
188
- count visible
189
- 0 (null) (null)
190
- 1 2 false
191
- 2 (null) (null)
192
- 3 32 false
193
- 4 (null) (null)
194
- 5 (null) (null)
195
- TABLE
196
- end
197
- end
198
-
199
- sub_test_case("column !=") do
200
- test("nil") do
201
- sliced_table = @table.slice do |slicer|
202
- slicer.visible != nil
203
- end
204
- assert_equal(<<-TABLE, sliced_table.to_s)
205
- count visible
206
- 0 1 true
207
- 1 2 false
208
- 2 8 true
209
- 3 16 true
210
- 4 32 false
211
- 5 256 true
212
- TABLE
213
- end
214
-
215
- test("value") do
216
- sliced_table = @table.slice do |slicer|
217
- slicer.visible != true
218
- end
219
- assert_equal(<<-TABLE, sliced_table.to_s)
220
- count visible
221
- 0 (null) (null)
222
- 1 2 false
223
- 2 (null) (null)
224
- 3 32 false
225
- 4 (null) (null)
226
- 5 (null) (null)
227
- TABLE
228
- end
229
- end
230
-
231
- test("column < value") do
232
- sliced_table = @table.slice do |slicer|
233
- slicer.count < 16
234
- end
235
- assert_equal(<<-TABLE, sliced_table.to_s)
236
- count visible
237
- 0 0 (null)
238
- 1 1 true
239
- 2 2 false
240
- 3 4 (null)
241
- 4 8 true
242
- 5 (null) (null)
243
- TABLE
244
- end
245
-
246
- test("!(column < value)") do
247
- sliced_table = @table.slice do |slicer|
248
- !(slicer.count < 16)
249
- end
250
- assert_equal(<<-TABLE, sliced_table.to_s)
251
- count visible
252
- 0 16 true
253
- 1 32 false
254
- 2 64 (null)
255
- 3 (null) (null)
256
- 4 256 true
257
- TABLE
258
- end
259
-
260
- test("column <= value") do
261
- sliced_table = @table.slice do |slicer|
262
- slicer.count <= 16
263
- end
264
- assert_equal(<<-TABLE, sliced_table.to_s)
265
- count visible
266
- 0 0 (null)
267
- 1 1 true
268
- 2 2 false
269
- 3 4 (null)
270
- 4 8 true
271
- 5 16 true
272
- 6 (null) (null)
273
- TABLE
274
- end
275
-
276
- test("!(column <= value)") do
277
- sliced_table = @table.slice do |slicer|
278
- !(slicer.count <= 16)
279
- end
280
- assert_equal(<<-TABLE, sliced_table.to_s)
281
- count visible
282
- 0 32 false
283
- 1 64 (null)
284
- 2 (null) (null)
285
- 3 256 true
286
- TABLE
287
- end
288
-
289
- test("column > value") do
290
- sliced_table = @table.slice do |slicer|
291
- slicer.count > 16
292
- end
293
- assert_equal(<<-TABLE, sliced_table.to_s)
294
- count visible
295
- 0 32 false
296
- 1 64 (null)
297
- 2 (null) (null)
298
- 3 256 true
299
- TABLE
300
- end
301
-
302
- test("!(column > value)") do
303
- sliced_table = @table.slice do |slicer|
304
- !(slicer.count > 16)
305
- end
306
- assert_equal(<<-TABLE, sliced_table.to_s)
307
- count visible
308
- 0 0 (null)
309
- 1 1 true
310
- 2 2 false
311
- 3 4 (null)
312
- 4 8 true
313
- 5 16 true
314
- 6 (null) (null)
315
- TABLE
316
- end
317
-
318
- test("column >= value") do
319
- sliced_table = @table.slice do |slicer|
320
- slicer.count >= 16
321
- end
322
- assert_equal(<<-TABLE, sliced_table.to_s)
323
- count visible
324
- 0 16 true
325
- 1 32 false
326
- 2 64 (null)
327
- 3 (null) (null)
328
- 4 256 true
329
- TABLE
330
- end
331
-
332
- test("!(column >= value)") do
333
- sliced_table = @table.slice do |slicer|
334
- !(slicer.count >= 16)
335
- end
336
- assert_equal(<<-TABLE, sliced_table.to_s)
337
- count visible
338
- 0 0 (null)
339
- 1 1 true
340
- 2 2 false
341
- 3 4 (null)
342
- 4 8 true
343
- 5 (null) (null)
344
- TABLE
345
- end
346
-
347
- test("column.in") do
348
- sliced_table = @table.slice do |slicer|
349
- slicer.count.in?([1, 4, 16, 64])
350
- end
351
- assert_equal(<<-TABLE, sliced_table.to_s)
352
- count visible
353
- 0 1 true
354
- 1 4 (null)
355
- 2 16 true
356
- 3 64 (null)
357
- TABLE
358
- end
359
-
360
- test("!column.in") do
361
- sliced_table = @table.slice do |slicer|
362
- !slicer.count.in?([1, 4, 16, 64])
363
- end
364
- assert_equal(<<-TABLE, sliced_table.to_s)
365
- count visible
366
- 0 0 (null)
367
- 1 2 false
368
- 2 8 true
369
- 3 32 false
370
- 4 (null) (null)
371
- 5 256 true
372
- TABLE
373
- end
374
-
375
- test("condition & condition") do
376
- sliced_table = @table.slice do |slicer|
377
- slicer.visible & (slicer.count >= 16)
378
- end
379
- assert_equal(<<-TABLE, sliced_table.to_s)
380
- count visible
381
- 0 (null) (null)
382
- 1 (null) (null)
383
- 2 16 true
384
- 3 (null) (null)
385
- 4 (null) (null)
386
- 5 256 true
387
- TABLE
388
- end
389
-
390
- test("condition | condition") do
391
- sliced_table = @table.slice do |slicer|
392
- slicer.visible | (slicer.count >= 16)
393
- end
394
- assert_equal(<<-TABLE, sliced_table.to_s)
395
- count visible
396
- 0 (null) (null)
397
- 1 1 true
398
- 2 (null) (null)
399
- 3 8 true
400
- 4 16 true
401
- 5 32 false
402
- 6 (null) (null)
403
- 7 (null) (null)
404
- 8 256 true
405
- TABLE
406
- end
407
-
408
- test("condition ^ condition") do
409
- sliced_table = @table.slice do |slicer|
410
- slicer.visible ^ (slicer.count >= 16)
411
- end
412
- assert_equal(<<-TABLE, sliced_table.to_s)
413
- count visible
414
- 0 (null) (null)
415
- 1 1 true
416
- 2 (null) (null)
417
- 3 8 true
418
- 4 32 false
419
- 5 (null) (null)
420
- 6 (null) (null)
421
- TABLE
422
- end
423
-
424
- test("select") do
425
- sliced_table = @table.slice do |slicer|
426
- slicer.visible.select do |value|
427
- value.nil? or value
428
- end
429
- end
430
- assert_equal(<<-TABLE, sliced_table.to_s)
431
- count visible
432
- 0 0 (null)
433
- 1 1 true
434
- 2 4 (null)
435
- 3 8 true
436
- 4 16 true
437
- 5 64 (null)
438
- 6 (null) (null)
439
- 7 256 true
440
- TABLE
441
- end
442
-
443
- test("!select") do
444
- sliced_table = @table.slice do |slicer|
445
- !slicer.visible.select do |value|
446
- value.nil? or value
447
- end
448
- end
449
- assert_equal(<<-TABLE, sliced_table.to_s)
450
- count visible
451
- 0 2 false
452
- 1 32 false
453
- TABLE
454
- end
455
-
456
- test("reject") do
457
- sliced_table = @table.slice do |slicer|
458
- slicer.visible.reject do |value|
459
- value.nil? or value
460
- end
461
- end
462
- assert_equal(<<-TABLE, sliced_table.to_s)
463
- count visible
464
- 0 2 false
465
- 1 32 false
466
- TABLE
467
- end
468
-
469
- test("!reject") do
470
- sliced_table = @table.slice do |slicer|
471
- !slicer.visible.reject do |value|
472
- value.nil? or value
473
- end
474
- end
475
- assert_equal(<<-TABLE, sliced_table.to_s)
476
- count visible
477
- 0 0 (null)
478
- 1 1 true
479
- 2 4 (null)
480
- 3 8 true
481
- 4 16 true
482
- 5 64 (null)
483
- 6 (null) (null)
484
- 7 256 true
485
- TABLE
486
- end
487
- end
@@ -1,40 +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 SortIndicesTest < Test::Unit::TestCase
19
- def setup
20
- @table = Arrow::Table.new(number1: [16, -1, 2, 32, -4, -4, -8],
21
- number2: [32, 2, -16, 8, 1, 4, 1])
22
- end
23
-
24
- sub_test_case("Table") do
25
- test("Symbol") do
26
- assert_equal(Arrow::UInt64Array.new([6, 4, 5, 1, 2, 0, 3]),
27
- @table.sort_indices(:number1))
28
- end
29
-
30
- test("-String") do
31
- assert_equal(Arrow::UInt64Array.new([3, 0, 2, 1, 4, 5, 6]),
32
- @table.sort_indices("-number1"))
33
- end
34
-
35
- test("Symbol, -String") do
36
- assert_equal(Arrow::UInt64Array.new([6, 5, 4, 1, 2, 0, 3]),
37
- @table.sort_indices([:number1, "-number2"]))
38
- end
39
- end
40
- 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 SortKeyTest < Test::Unit::TestCase
19
- sub_test_case(".resolve") do
20
- test("SortKey") do
21
- assert_equal(Arrow::SortKey.new("-count"),
22
- Arrow::SortKey.resolve(Arrow::SortKey.new("-count")))
23
- end
24
-
25
- test("-String") do
26
- assert_equal(Arrow::SortKey.new("-count"),
27
- Arrow::SortKey.resolve("-count"))
28
- end
29
-
30
- test("Symbol, Symbol") do
31
- assert_equal(Arrow::SortKey.new("-count"),
32
- Arrow::SortKey.resolve(:count, :desc))
33
- end
34
- end
35
-
36
- sub_test_case("#initialize") do
37
- test("String") do
38
- assert_equal("+count",
39
- Arrow::SortKey.new("count").to_s)
40
- end
41
-
42
- test("+String") do
43
- assert_equal("+count",
44
- Arrow::SortKey.new("+count").to_s)
45
- end
46
-
47
- test("-String") do
48
- assert_equal("-count",
49
- Arrow::SortKey.new("-count").to_s)
50
- end
51
-
52
- test("Symbol") do
53
- assert_equal("+-count",
54
- Arrow::SortKey.new(:"-count").to_s)
55
- end
56
-
57
- test("String, Symbol") do
58
- assert_equal("--count",
59
- Arrow::SortKey.new("-count", :desc).to_s)
60
- end
61
-
62
- test("String, String") do
63
- assert_equal("--count",
64
- Arrow::SortKey.new("-count", "desc").to_s)
65
- end
66
-
67
- test("String, SortOrder") do
68
- assert_equal("--count",
69
- Arrow::SortKey.new("-count",
70
- Arrow::SortOrder::DESCENDING).to_s)
71
- end
72
- end
73
-
74
- sub_test_case("#to_s") do
75
- test("recreatable") do
76
- key = Arrow::SortKey.new("-count", :desc)
77
- assert_equal(key,
78
- Arrow::SortKey.new(key.to_s))
79
- end
80
- end
81
- end
@@ -1,58 +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 SortOptionsTest < Test::Unit::TestCase
19
- sub_test_case("#initialize") do
20
- test("none") do
21
- options = Arrow::SortOptions.new
22
- assert_equal([],
23
- options.sort_keys.collect(&:to_s))
24
- end
25
-
26
- test("-String, Symbol") do
27
- options = Arrow::SortOptions.new("-count", :age)
28
- assert_equal(["-count", "+age"],
29
- options.sort_keys.collect(&:to_s))
30
- end
31
- end
32
-
33
- sub_test_case("instance methods") do
34
- setup do
35
- @options = Arrow::SortOptions.new
36
- end
37
-
38
- sub_test_case("#add_sort_key") do
39
- test("-String") do
40
- @options.add_sort_key("-count")
41
- assert_equal(["-count"],
42
- @options.sort_keys.collect(&:to_s))
43
- end
44
-
45
- test("-String, Symbol") do
46
- @options.add_sort_key("-count", :desc)
47
- assert_equal(["--count"],
48
- @options.sort_keys.collect(&:to_s))
49
- end
50
-
51
- test("SortKey") do
52
- @options.add_sort_key(Arrow::SortKey.new("-count"))
53
- assert_equal(["-count"],
54
- @options.sort_keys.collect(&:to_s))
55
- end
56
- end
57
- end
58
- end
@@ -1,41 +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 SparseUnionDataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- def setup
21
- @fields = [
22
- Arrow::Field.new("visible", :boolean),
23
- {
24
- name: "count",
25
- type: :int32,
26
- },
27
- ]
28
- end
29
-
30
- test("ordered arguments") do
31
- assert_equal("sparse_union<visible: bool=2, count: int32=9>",
32
- Arrow::SparseUnionDataType.new(@fields, [2, 9]).to_s)
33
- end
34
-
35
- test("description") do
36
- assert_equal("sparse_union<visible: bool=2, count: int32=9>",
37
- Arrow::SparseUnionDataType.new(fields: @fields,
38
- type_codes: [2, 9]).to_s)
39
- end
40
- end
41
- end