red-arrow 18.1.0 → 19.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arrow/array.rb +7 -4
  3. data/lib/arrow/column.rb +4 -4
  4. data/lib/arrow/jruby/array-builder.rb +114 -0
  5. data/lib/arrow/jruby/array.rb +109 -0
  6. data/{test/helper/fixture.rb → lib/arrow/jruby/chunked-array.rb} +14 -6
  7. data/lib/arrow/jruby/compression-type.rb +26 -0
  8. data/{test/test-boolean-scalar.rb → lib/arrow/jruby/csv-read-options.rb} +12 -6
  9. data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
  10. data/lib/arrow/jruby/decimal128.rb +28 -0
  11. data/lib/arrow/jruby/decimal256.rb +28 -0
  12. data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/error.rb} +7 -4
  13. data/lib/arrow/jruby/file-system.rb +24 -0
  14. data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
  15. data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
  16. data/{test/fixture/integer-float.csv → lib/arrow/jruby/record-batch.rb} +8 -4
  17. data/{test/fixture/float-integer.csv → lib/arrow/jruby/sort-key.rb} +8 -4
  18. data/lib/arrow/jruby/sort-options.rb +24 -0
  19. data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
  20. data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
  21. data/lib/arrow/jruby/writable.rb +24 -0
  22. data/lib/arrow/jruby.rb +52 -0
  23. data/lib/arrow/libraries.rb +126 -0
  24. data/lib/arrow/list-array-builder.rb +1 -0
  25. data/lib/arrow/loader.rb +3 -111
  26. data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +6 -4
  27. data/lib/arrow/version.rb +1 -1
  28. data/lib/arrow.rb +2 -7
  29. data/red-arrow.gemspec +15 -6
  30. metadata +26 -229
  31. data/test/each-raw-record/test-basic-arrays.rb +0 -411
  32. data/test/each-raw-record/test-dense-union-array.rb +0 -566
  33. data/test/each-raw-record/test-dictionary-array.rb +0 -341
  34. data/test/each-raw-record/test-list-array.rb +0 -628
  35. data/test/each-raw-record/test-map-array.rb +0 -507
  36. data/test/each-raw-record/test-multiple-columns.rb +0 -72
  37. data/test/each-raw-record/test-sparse-union-array.rb +0 -528
  38. data/test/each-raw-record/test-struct-array.rb +0 -529
  39. data/test/each-raw-record/test-table.rb +0 -47
  40. data/test/fixture/TestOrcFile.test1.orc +0 -0
  41. data/test/fixture/with-header-float.csv +0 -20
  42. data/test/fixture/with-header.csv +0 -20
  43. data/test/fixture/without-header-float.csv +0 -19
  44. data/test/fixture/without-header.csv +0 -19
  45. data/test/helper/omittable.rb +0 -49
  46. data/test/helper.rb +0 -31
  47. data/test/raw-records/test-basic-arrays.rb +0 -405
  48. data/test/raw-records/test-dense-union-array.rb +0 -566
  49. data/test/raw-records/test-dictionary-array.rb +0 -341
  50. data/test/raw-records/test-list-array.rb +0 -628
  51. data/test/raw-records/test-map-array.rb +0 -507
  52. data/test/raw-records/test-multiple-columns.rb +0 -65
  53. data/test/raw-records/test-sparse-union-array.rb +0 -556
  54. data/test/raw-records/test-struct-array.rb +0 -529
  55. data/test/raw-records/test-table.rb +0 -47
  56. data/test/run-test.rb +0 -71
  57. data/test/test-array-builder.rb +0 -198
  58. data/test/test-array.rb +0 -332
  59. data/test/test-bigdecimal.rb +0 -40
  60. data/test/test-binary-dictionary-array-builder.rb +0 -103
  61. data/test/test-buffer.rb +0 -49
  62. data/test/test-chunked-array.rb +0 -198
  63. data/test/test-column.rb +0 -123
  64. data/test/test-csv-loader.rb +0 -297
  65. data/test/test-data-type.rb +0 -84
  66. data/test/test-date32-array.rb +0 -24
  67. data/test/test-date64-array.rb +0 -25
  68. data/test/test-decimal128-array-builder.rb +0 -126
  69. data/test/test-decimal128-array.rb +0 -47
  70. data/test/test-decimal128-data-type.rb +0 -31
  71. data/test/test-decimal128.rb +0 -126
  72. data/test/test-decimal256-array-builder.rb +0 -126
  73. data/test/test-decimal256-array.rb +0 -47
  74. data/test/test-decimal256-data-type.rb +0 -31
  75. data/test/test-decimal256.rb +0 -126
  76. data/test/test-dense-union-array.rb +0 -42
  77. data/test/test-dense-union-data-type.rb +0 -41
  78. data/test/test-dictionary-array.rb +0 -41
  79. data/test/test-dictionary-data-type.rb +0 -40
  80. data/test/test-expression.rb +0 -51
  81. data/test/test-feather.rb +0 -49
  82. data/test/test-field.rb +0 -117
  83. data/test/test-file-output-stream.rb +0 -54
  84. data/test/test-fixed-size-binary-array-builder.rb +0 -92
  85. data/test/test-fixed-size-binary-array.rb +0 -36
  86. data/test/test-float-scalar.rb +0 -46
  87. data/test/test-function.rb +0 -210
  88. data/test/test-group.rb +0 -193
  89. data/test/test-half-float-array.rb +0 -43
  90. data/test/test-half-float.rb +0 -130
  91. data/test/test-list-array-builder.rb +0 -79
  92. data/test/test-list-array.rb +0 -32
  93. data/test/test-list-data-type.rb +0 -69
  94. data/test/test-map-array-builder.rb +0 -110
  95. data/test/test-map-array.rb +0 -33
  96. data/test/test-memory-view.rb +0 -434
  97. data/test/test-orc.rb +0 -173
  98. data/test/test-ractor.rb +0 -34
  99. data/test/test-record-batch-builder.rb +0 -125
  100. data/test/test-record-batch-file-reader.rb +0 -136
  101. data/test/test-record-batch-iterator.rb +0 -37
  102. data/test/test-record-batch-reader.rb +0 -46
  103. data/test/test-record-batch-stream-reader.rb +0 -129
  104. data/test/test-record-batch.rb +0 -182
  105. data/test/test-scalar.rb +0 -65
  106. data/test/test-schema.rb +0 -134
  107. data/test/test-slicer.rb +0 -589
  108. data/test/test-sort-indices.rb +0 -40
  109. data/test/test-sort-key.rb +0 -81
  110. data/test/test-sort-options.rb +0 -58
  111. data/test/test-sparse-union-array.rb +0 -38
  112. data/test/test-sparse-union-data-type.rb +0 -41
  113. data/test/test-stream-listener.rb +0 -60
  114. data/test/test-string-dictionary-array-builder.rb +0 -103
  115. data/test/test-struct-array-builder.rb +0 -184
  116. data/test/test-struct-array.rb +0 -94
  117. data/test/test-struct-data-type.rb +0 -112
  118. data/test/test-table.rb +0 -1530
  119. data/test/test-tensor.rb +0 -297
  120. data/test/test-time.rb +0 -288
  121. data/test/test-time32-array.rb +0 -81
  122. data/test/test-time32-data-type.rb +0 -42
  123. data/test/test-time64-array.rb +0 -81
  124. data/test/test-time64-data-type.rb +0 -42
  125. data/test/test-timestamp-array.rb +0 -45
  126. data/test/test-timestamp-data-type.rb +0 -42
  127. data/test/values/test-basic-arrays.rb +0 -335
  128. data/test/values/test-dense-union-array.rb +0 -552
  129. data/test/values/test-dictionary-array.rb +0 -325
  130. data/test/values/test-list-array.rb +0 -587
  131. data/test/values/test-map-array.rb +0 -489
  132. data/test/values/test-sparse-union-array.rb +0 -543
  133. data/test/values/test-struct-array.rb +0 -524
data/test/test-slicer.rb DELETED
@@ -1,589 +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
- (uint32) (bool)
50
- 0 1 true
51
- 1 8 true
52
- 2 16 true
53
- 3 256 true
54
- TABLE
55
- end
56
-
57
- test("not BooleanArray") do
58
- sliced_table = @table.slice do |slicer|
59
- slicer.count
60
- end
61
- assert_equal(<<-TABLE, sliced_table.to_s)
62
- count visible
63
- (uint32) (bool)
64
- 0 1 true
65
- 1 2 false
66
- 2 4 (null)
67
- 3 8 true
68
- 4 16 true
69
- 5 32 false
70
- 6 64 (null)
71
- 7 256 true
72
- TABLE
73
- end
74
- end
75
-
76
- sub_test_case("!column") do
77
- test("BooleanArray") do
78
- sliced_table = @table.slice do |slicer|
79
- !slicer.visible
80
- end
81
- assert_equal(<<-TABLE, sliced_table.to_s)
82
- count visible
83
- (uint32) (bool)
84
- 0 2 false
85
- 1 32 false
86
- TABLE
87
- end
88
-
89
- test("not BooleanArray") do
90
- sliced_table = @table.slice do |slicer|
91
- !slicer.count
92
- end
93
- assert_equal(<<-TABLE, sliced_table.to_s)
94
- count visible
95
- (uint32) (bool)
96
- 0 0 (null)
97
- TABLE
98
- end
99
- end
100
-
101
- test("column.null?") do
102
- sliced_table = @table.slice do |slicer|
103
- slicer.visible.null?
104
- end
105
- assert_equal(<<-TABLE, sliced_table.to_s)
106
- count visible
107
- (uint32) (bool)
108
- 0 0 (null)
109
- 1 4 (null)
110
- 2 64 (null)
111
- 3 (null) (null)
112
- TABLE
113
- end
114
-
115
- test("column.valid?") do
116
- sliced_table = @table.slice do |slicer|
117
- slicer.visible.valid?
118
- end
119
- assert_equal(<<-TABLE, sliced_table.to_s)
120
- count visible
121
- (uint32) (bool)
122
- 0 1 true
123
- 1 2 false
124
- 2 8 true
125
- 3 16 true
126
- 4 32 false
127
- 5 256 true
128
- TABLE
129
- end
130
-
131
- sub_test_case("column ==") do
132
- test("nil") do
133
- sliced_table = @table.slice do |slicer|
134
- slicer.visible == nil
135
- end
136
- assert_equal(<<-TABLE, sliced_table.to_s)
137
- count visible
138
- (uint32) (bool)
139
- 0 0 (null)
140
- 1 4 (null)
141
- 2 64 (null)
142
- 3 (null) (null)
143
- TABLE
144
- end
145
-
146
- test("value") do
147
- sliced_table = @table.slice do |slicer|
148
- slicer.visible == true
149
- end
150
- assert_equal(<<-TABLE, sliced_table.to_s)
151
- count visible
152
- (uint32) (bool)
153
- 0 1 true
154
- 1 8 true
155
- 2 16 true
156
- 3 256 true
157
- TABLE
158
- end
159
- end
160
-
161
- sub_test_case("!(column ==)") do
162
- test("nil") do
163
- sliced_table = @table.slice do |slicer|
164
- !(slicer.visible == nil)
165
- end
166
- assert_equal(<<-TABLE, sliced_table.to_s)
167
- count visible
168
- (uint32) (bool)
169
- 0 1 true
170
- 1 2 false
171
- 2 8 true
172
- 3 16 true
173
- 4 32 false
174
- 5 256 true
175
- TABLE
176
- end
177
-
178
- test("value") do
179
- sliced_table = @table.slice do |slicer|
180
- !(slicer.visible == true)
181
- end
182
- assert_equal(<<-TABLE, sliced_table.to_s)
183
- count visible
184
- (uint32) (bool)
185
- 0 2 false
186
- 1 32 false
187
- TABLE
188
- end
189
- end
190
-
191
- sub_test_case("column !=") do
192
- test("nil") do
193
- sliced_table = @table.slice do |slicer|
194
- slicer.visible != nil
195
- end
196
- assert_equal(<<-TABLE, sliced_table.to_s)
197
- count visible
198
- (uint32) (bool)
199
- 0 1 true
200
- 1 2 false
201
- 2 8 true
202
- 3 16 true
203
- 4 32 false
204
- 5 256 true
205
- TABLE
206
- end
207
-
208
- test("value") do
209
- sliced_table = @table.slice do |slicer|
210
- slicer.visible != true
211
- end
212
- assert_equal(<<-TABLE, sliced_table.to_s)
213
- count visible
214
- (uint32) (bool)
215
- 0 2 false
216
- 1 32 false
217
- TABLE
218
- end
219
- end
220
-
221
- test("column < value") do
222
- sliced_table = @table.slice do |slicer|
223
- slicer.count < 16
224
- end
225
- assert_equal(<<-TABLE, sliced_table.to_s)
226
- count visible
227
- (uint32) (bool)
228
- 0 0 (null)
229
- 1 1 true
230
- 2 2 false
231
- 3 4 (null)
232
- 4 8 true
233
- TABLE
234
- end
235
-
236
- test("!(column < value)") do
237
- sliced_table = @table.slice do |slicer|
238
- !(slicer.count < 16)
239
- end
240
- assert_equal(<<-TABLE, sliced_table.to_s)
241
- count visible
242
- (uint32) (bool)
243
- 0 16 true
244
- 1 32 false
245
- 2 64 (null)
246
- 3 256 true
247
- TABLE
248
- end
249
-
250
- test("column <= value") do
251
- sliced_table = @table.slice do |slicer|
252
- slicer.count <= 16
253
- end
254
- assert_equal(<<-TABLE, sliced_table.to_s)
255
- count visible
256
- (uint32) (bool)
257
- 0 0 (null)
258
- 1 1 true
259
- 2 2 false
260
- 3 4 (null)
261
- 4 8 true
262
- 5 16 true
263
- TABLE
264
- end
265
-
266
- test("!(column <= value)") do
267
- sliced_table = @table.slice do |slicer|
268
- !(slicer.count <= 16)
269
- end
270
- assert_equal(<<-TABLE, sliced_table.to_s)
271
- count visible
272
- (uint32) (bool)
273
- 0 32 false
274
- 1 64 (null)
275
- 2 256 true
276
- TABLE
277
- end
278
-
279
- test("column > value") do
280
- sliced_table = @table.slice do |slicer|
281
- slicer.count > 16
282
- end
283
- assert_equal(<<-TABLE, sliced_table.to_s)
284
- count visible
285
- (uint32) (bool)
286
- 0 32 false
287
- 1 64 (null)
288
- 2 256 true
289
- TABLE
290
- end
291
-
292
- test("!(column > value)") do
293
- sliced_table = @table.slice do |slicer|
294
- !(slicer.count > 16)
295
- end
296
- assert_equal(<<-TABLE, sliced_table.to_s)
297
- count visible
298
- (uint32) (bool)
299
- 0 0 (null)
300
- 1 1 true
301
- 2 2 false
302
- 3 4 (null)
303
- 4 8 true
304
- 5 16 true
305
- TABLE
306
- end
307
-
308
- test("column >= value") do
309
- sliced_table = @table.slice do |slicer|
310
- slicer.count >= 16
311
- end
312
- assert_equal(<<-TABLE, sliced_table.to_s)
313
- count visible
314
- (uint32) (bool)
315
- 0 16 true
316
- 1 32 false
317
- 2 64 (null)
318
- 3 256 true
319
- TABLE
320
- end
321
-
322
- test("!(column >= value)") do
323
- sliced_table = @table.slice do |slicer|
324
- !(slicer.count >= 16)
325
- end
326
- assert_equal(<<-TABLE, sliced_table.to_s)
327
- count visible
328
- (uint32) (bool)
329
- 0 0 (null)
330
- 1 1 true
331
- 2 2 false
332
- 3 4 (null)
333
- 4 8 true
334
- TABLE
335
- end
336
-
337
- test("column.in") do
338
- sliced_table = @table.slice do |slicer|
339
- slicer.count.in?([1, 4, 16, 64])
340
- end
341
- assert_equal(<<-TABLE, sliced_table.to_s)
342
- count visible
343
- (uint32) (bool)
344
- 0 1 true
345
- 1 4 (null)
346
- 2 16 true
347
- 3 64 (null)
348
- TABLE
349
- end
350
-
351
- test("!column.in") do
352
- sliced_table = @table.slice do |slicer|
353
- !slicer.count.in?([1, 4, 16, 64])
354
- end
355
- assert_equal(<<-TABLE, sliced_table.to_s)
356
- count visible
357
- (uint32) (bool)
358
- 0 0 (null)
359
- 1 2 false
360
- 2 8 true
361
- 3 32 false
362
- 4 (null) (null)
363
- 5 256 true
364
- TABLE
365
- end
366
-
367
- test("condition & condition") do
368
- sliced_table = @table.slice do |slicer|
369
- slicer.visible & (slicer.count >= 16)
370
- end
371
- assert_equal(<<-TABLE, sliced_table.to_s)
372
- count visible
373
- (uint32) (bool)
374
- 0 16 true
375
- 1 256 true
376
- TABLE
377
- end
378
-
379
- test("condition | condition") do
380
- sliced_table = @table.slice do |slicer|
381
- slicer.visible | (slicer.count >= 16)
382
- end
383
- assert_equal(<<-TABLE, sliced_table.to_s)
384
- count visible
385
- (uint32) (bool)
386
- 0 1 true
387
- 1 8 true
388
- 2 16 true
389
- 3 32 false
390
- 4 256 true
391
- TABLE
392
- end
393
-
394
- test("condition ^ condition") do
395
- sliced_table = @table.slice do |slicer|
396
- slicer.visible ^ (slicer.count >= 16)
397
- end
398
- assert_equal(<<-TABLE, sliced_table.to_s)
399
- count visible
400
- (uint32) (bool)
401
- 0 1 true
402
- 1 8 true
403
- 2 32 false
404
- TABLE
405
- end
406
-
407
- test("select") do
408
- sliced_table = @table.slice do |slicer|
409
- slicer.visible.select do |value|
410
- value.nil? or value
411
- end
412
- end
413
- assert_equal(<<-TABLE, sliced_table.to_s)
414
- count visible
415
- (uint32) (bool)
416
- 0 0 (null)
417
- 1 1 true
418
- 2 4 (null)
419
- 3 8 true
420
- 4 16 true
421
- 5 64 (null)
422
- 6 (null) (null)
423
- 7 256 true
424
- TABLE
425
- end
426
-
427
- test("!select") do
428
- sliced_table = @table.slice do |slicer|
429
- !slicer.visible.select do |value|
430
- value.nil? or value
431
- end
432
- end
433
- assert_equal(<<-TABLE, sliced_table.to_s)
434
- count visible
435
- (uint32) (bool)
436
- 0 2 false
437
- 1 32 false
438
- TABLE
439
- end
440
-
441
- test("reject") do
442
- sliced_table = @table.slice do |slicer|
443
- slicer.visible.reject do |value|
444
- value.nil? or value
445
- end
446
- end
447
- assert_equal(<<-TABLE, sliced_table.to_s)
448
- count visible
449
- (uint32) (bool)
450
- 0 2 false
451
- 1 32 false
452
- TABLE
453
- end
454
-
455
- test("!reject") do
456
- sliced_table = @table.slice do |slicer|
457
- !slicer.visible.reject do |value|
458
- value.nil? or value
459
- end
460
- end
461
- assert_equal(<<-TABLE, sliced_table.to_s)
462
- count visible
463
- (uint32) (bool)
464
- 0 0 (null)
465
- 1 1 true
466
- 2 4 (null)
467
- 3 8 true
468
- 4 16 true
469
- 5 64 (null)
470
- 6 (null) (null)
471
- 7 256 true
472
- TABLE
473
- end
474
-
475
- sub_test_case "MatchSubstringOptions family" do
476
- def setup
477
- @table = Arrow::Table.new(
478
- string: ["array", "Arrow", "carrot", nil, "window"]
479
- )
480
- end
481
-
482
- test("end_with?") do
483
- sliced_table = @table.slice do |slicer|
484
- slicer.string.end_with?("ow")
485
- end
486
- assert_equal(<<~TABLE, sliced_table.to_s)
487
- string
488
- (utf8)
489
- 0 Arrow
490
- 1 window
491
- TABLE
492
- end
493
-
494
- test("match_like?") do
495
- sliced_table = @table.slice do |slicer|
496
- slicer.string.match_like?("_rr%")
497
- end
498
- assert_equal(<<~TABLE, sliced_table.to_s)
499
- string
500
- (utf8)
501
- 0 array
502
- 1 Arrow
503
- TABLE
504
- end
505
-
506
- test("match_substring?") do
507
- sliced_table = @table.slice do |slicer|
508
- slicer.string.match_substring?("arr")
509
- end
510
- assert_equal(<<~TABLE, sliced_table.to_s)
511
- string
512
- (utf8)
513
- 0 array
514
- 1 carrot
515
- TABLE
516
- end
517
-
518
- test("match_substring?(ignore_case:)") do
519
- sliced_table = @table.slice do |slicer|
520
- slicer.string.match_substring?("arr", ignore_case: true)
521
- end
522
- assert_equal(<<~TABLE, sliced_table.to_s)
523
- string
524
- (utf8)
525
- 0 array
526
- 1 Arrow
527
- 2 carrot
528
- TABLE
529
- end
530
-
531
- test("!match_substring?") do
532
- sliced_table = @table.slice do |slicer|
533
- !slicer.string.match_substring?("arr")
534
- end
535
- assert_equal(<<~TABLE, sliced_table.to_s)
536
- string
537
- (utf8)
538
- 0 Arrow
539
- 1 window
540
- TABLE
541
- end
542
-
543
- test("match_substring?(Regexp)") do
544
- sliced_table = @table.slice do |slicer|
545
- slicer.string.match_substring?(/[dr]ow/)
546
- end
547
- assert_equal(<<~TABLE, sliced_table.to_s)
548
- string
549
- (utf8)
550
- 0 Arrow
551
- 1 window
552
- TABLE
553
- end
554
-
555
- test("match_substring?(/String/i)") do
556
- sliced_table = @table.slice do |slicer|
557
- slicer.string.match_substring?(/arr/i)
558
- end
559
- assert_equal(<<~TABLE, sliced_table.to_s)
560
- string
561
- (utf8)
562
- 0 array
563
- 1 Arrow
564
- 2 carrot
565
- TABLE
566
- end
567
-
568
- test("match_substring? - invalid") do
569
- message =
570
- 'pattern must be either String or Regexp: ["arr"]'
571
- assert_raise(ArgumentError.new(message)) do
572
- @table.slice do |slicer|
573
- slicer.string.match_substring?(["arr"])
574
- end
575
- end
576
- end
577
-
578
- test("start_with?") do
579
- sliced_table = @table.slice do |slicer|
580
- slicer.string.start_with?("ca")
581
- end
582
- assert_equal(<<~TABLE, sliced_table.to_s)
583
- string
584
- (utf8)
585
- 0 carrot
586
- TABLE
587
- end
588
- end
589
- 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