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
@@ -1,587 +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
- module ValuesListArrayTests
19
- def build_data_type(type)
20
- field_description = {
21
- name: :element,
22
- }
23
- if type.is_a?(Hash)
24
- field_description = field_description.merge(type)
25
- else
26
- field_description[:type] = type
27
- end
28
- Arrow::ListDataType.new(field: field_description)
29
- end
30
-
31
- def build_array(type, values)
32
- Arrow::ListArray.new(build_data_type(type), values)
33
- end
34
-
35
- def test_null
36
- values = [
37
- [nil, nil, nil],
38
- nil,
39
- ]
40
- target = build(:null, values)
41
- assert_equal(values, target.values)
42
- end
43
-
44
- def test_boolean
45
- values = [
46
- [true, nil, false],
47
- nil,
48
- ]
49
- target = build(:boolean, values)
50
- assert_equal(values, target.values)
51
- end
52
-
53
- def test_int8
54
- values = [
55
- [-(2 ** 7), nil, (2 ** 7) - 1],
56
- nil,
57
- ]
58
- target = build(:int8, values)
59
- assert_equal(values, target.values)
60
- end
61
-
62
- def test_uint8
63
- values = [
64
- [0, nil, (2 ** 8) - 1],
65
- nil,
66
- ]
67
- target = build(:uint8, values)
68
- assert_equal(values, target.values)
69
- end
70
-
71
- def test_int16
72
- values = [
73
- [-(2 ** 15), nil, (2 ** 15) - 1],
74
- nil,
75
- ]
76
- target = build(:int16, values)
77
- assert_equal(values, target.values)
78
- end
79
-
80
- def test_uint16
81
- values = [
82
- [0, nil, (2 ** 16) - 1],
83
- nil,
84
- ]
85
- target = build(:uint16, values)
86
- assert_equal(values, target.values)
87
- end
88
-
89
- def test_int32
90
- values = [
91
- [-(2 ** 31), nil, (2 ** 31) - 1],
92
- nil,
93
- ]
94
- target = build(:int32, values)
95
- assert_equal(values, target.values)
96
- end
97
-
98
- def test_uint32
99
- values = [
100
- [0, nil, (2 ** 32) - 1],
101
- nil,
102
- ]
103
- target = build(:uint32, values)
104
- assert_equal(values, target.values)
105
- end
106
-
107
- def test_int64
108
- values = [
109
- [-(2 ** 63), nil, (2 ** 63) - 1],
110
- nil,
111
- ]
112
- target = build(:int64, values)
113
- assert_equal(values, target.values)
114
- end
115
-
116
- def test_uint64
117
- values = [
118
- [0, nil, (2 ** 64) - 1],
119
- nil,
120
- ]
121
- target = build(:uint64, values)
122
- assert_equal(values, target.values)
123
- end
124
-
125
- def test_float
126
- values = [
127
- [-1.0, nil, 1.0],
128
- nil,
129
- ]
130
- target = build(:float, values)
131
- assert_equal(values, target.values)
132
- end
133
-
134
- def test_double
135
- values = [
136
- [-1.0, nil, 1.0],
137
- nil,
138
- ]
139
- target = build(:double, values)
140
- assert_equal(values, target.values)
141
- end
142
-
143
- def test_binary
144
- values = [
145
- ["\x00".b, nil, "\xff".b],
146
- nil,
147
- ]
148
- target = build(:binary, values)
149
- assert_equal(values, target.values)
150
- end
151
-
152
- def test_string
153
- values = [
154
- [
155
- "Ruby",
156
- nil,
157
- "\u3042", # U+3042 HIRAGANA LETTER A
158
- ],
159
- nil,
160
- ]
161
- target = build(:string, values)
162
- assert_equal(values, target.values)
163
- end
164
-
165
- def test_date32
166
- values = [
167
- [
168
- Date.new(1960, 1, 1),
169
- nil,
170
- Date.new(2017, 8, 23),
171
- ],
172
- nil,
173
- ]
174
- target = build(:date32, values)
175
- assert_equal(values, target.values)
176
- end
177
-
178
- def test_date64
179
- values = [
180
- [
181
- DateTime.new(1960, 1, 1, 2, 9, 30),
182
- nil,
183
- DateTime.new(2017, 8, 23, 14, 57, 2),
184
- ],
185
- nil,
186
- ]
187
- target = build(:date64, values)
188
- assert_equal(values, target.values)
189
- end
190
-
191
- def test_timestamp_second
192
- values = [
193
- [
194
- Time.parse("1960-01-01T02:09:30Z"),
195
- nil,
196
- Time.parse("2017-08-23T14:57:02Z"),
197
- ],
198
- nil,
199
- ]
200
- target = build({
201
- type: :timestamp,
202
- unit: :second,
203
- },
204
- values)
205
- assert_equal(values, target.values)
206
- end
207
-
208
- def test_timestamp_milli
209
- values = [
210
- [
211
- Time.parse("1960-01-01T02:09:30.123Z"),
212
- nil,
213
- Time.parse("2017-08-23T14:57:02.987Z"),
214
- ],
215
- nil,
216
- ]
217
- target = build({
218
- type: :timestamp,
219
- unit: :milli,
220
- },
221
- values)
222
- assert_equal(values, target.values)
223
- end
224
-
225
- def test_timestamp_micro
226
- values = [
227
- [
228
- Time.parse("1960-01-01T02:09:30.123456Z"),
229
- nil,
230
- Time.parse("2017-08-23T14:57:02.987654Z"),
231
- ],
232
- nil,
233
- ]
234
- target = build({
235
- type: :timestamp,
236
- unit: :micro,
237
- },
238
- values)
239
- assert_equal(values, target.values)
240
- end
241
-
242
- def test_timestamp_nano
243
- values = [
244
- [
245
- Time.parse("1960-01-01T02:09:30.123456789Z"),
246
- nil,
247
- Time.parse("2017-08-23T14:57:02.987654321Z"),
248
- ],
249
- nil,
250
- ]
251
- target = build({
252
- type: :timestamp,
253
- unit: :nano,
254
- },
255
- values)
256
- assert_equal(values, target.values)
257
- end
258
-
259
- def test_time32_second
260
- unit = Arrow::TimeUnit::SECOND
261
- values = [
262
- [
263
- # 00:10:00
264
- Arrow::Time.new(unit, 60 * 10),
265
- nil,
266
- # 02:00:09
267
- Arrow::Time.new(unit, 60 * 60 * 2 + 9),
268
- ],
269
- nil,
270
- ]
271
- target = build({
272
- type: :time32,
273
- unit: :second,
274
- },
275
- values)
276
- assert_equal(values, target.values)
277
- end
278
-
279
- def test_time32_milli
280
- unit = Arrow::TimeUnit::MILLI
281
- values = [
282
- [
283
- # 00:10:00.123
284
- Arrow::Time.new(unit, (60 * 10) * 1000 + 123),
285
- nil,
286
- # 02:00:09.987
287
- Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1000 + 987),
288
- ],
289
- nil,
290
- ]
291
- target = build({
292
- type: :time32,
293
- unit: :milli,
294
- },
295
- values)
296
- assert_equal(values, target.values)
297
- end
298
-
299
- def test_time64_micro
300
- unit = Arrow::TimeUnit::MICRO
301
- values = [
302
- [
303
- # 00:10:00.123456
304
- Arrow::Time.new(unit, (60 * 10) * 1_000_000 + 123_456),
305
- nil,
306
- # 02:00:09.987654
307
- Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1_000_000 + 987_654),
308
- ],
309
- nil,
310
- ]
311
- target = build({
312
- type: :time64,
313
- unit: :micro,
314
- },
315
- values)
316
- assert_equal(values, target.values)
317
- end
318
-
319
- def test_time64_nano
320
- unit = Arrow::TimeUnit::NANO
321
- values = [
322
- [
323
- # 00:10:00.123456789
324
- Arrow::Time.new(unit, (60 * 10) * 1_000_000_000 + 123_456_789),
325
- nil,
326
- # 02:00:09.987654321
327
- Arrow::Time.new(unit, (60 * 60 * 2 + 9) * 1_000_000_000 + 987_654_321),
328
- ],
329
- nil,
330
- ]
331
- target = build({
332
- type: :time64,
333
- unit: :nano,
334
- },
335
- values)
336
- assert_equal(values, target.values)
337
- end
338
-
339
- def test_decimal128
340
- values = [
341
- [
342
- BigDecimal("92.92"),
343
- nil,
344
- BigDecimal("29.29"),
345
- ],
346
- nil,
347
- ]
348
- target = build({
349
- type: :decimal128,
350
- precision: 8,
351
- scale: 2,
352
- },
353
- values)
354
- assert_equal(values, target.values)
355
- end
356
-
357
- def test_decimal256
358
- values = [
359
- [
360
- BigDecimal("92.92"),
361
- nil,
362
- BigDecimal("29.29"),
363
- ],
364
- nil,
365
- ]
366
- target = build({
367
- type: :decimal256,
368
- precision: 38,
369
- scale: 2,
370
- },
371
- values)
372
- assert_equal(values, target.values)
373
- end
374
-
375
- def test_month_interval
376
- values = [
377
- [
378
- 1,
379
- nil,
380
- 12,
381
- ],
382
- nil,
383
- ]
384
- target = build(:month_interval, values)
385
- assert_equal(values, target.values)
386
- end
387
-
388
- def test_day_time_interval
389
- values = [
390
- [
391
- {day: 1, millisecond: 100},
392
- nil,
393
- {day: 2, millisecond: 300},
394
- ],
395
- nil,
396
- ]
397
- target = build(:day_time_interval, values)
398
- assert_equal(values, target.values)
399
- end
400
-
401
- def test_month_day_nano_interval
402
- values = [
403
- [
404
- {month: 1, day: 1, nanosecond: 100},
405
- nil,
406
- {month: 2, day: 3, nanosecond: 400},
407
- ],
408
- nil,
409
- ]
410
- target = build(:month_day_nano_interval, values)
411
- assert_equal(values, target.values)
412
- end
413
-
414
- def test_list
415
- values = [
416
- [
417
- [
418
- true,
419
- nil,
420
- ],
421
- nil,
422
- [
423
- nil,
424
- false,
425
- ],
426
- ],
427
- nil,
428
- ]
429
- target = build({
430
- type: :list,
431
- field: {
432
- name: :sub_element,
433
- type: :boolean,
434
- },
435
- },
436
- values)
437
- assert_equal(values, target.values)
438
- end
439
-
440
- def test_struct
441
- values = [
442
- [
443
- {"field" => true},
444
- nil,
445
- {"field" => nil},
446
- ],
447
- nil,
448
- ]
449
- target = build({
450
- type: :struct,
451
- fields: [
452
- {
453
- name: :field,
454
- type: :boolean,
455
- },
456
- ],
457
- },
458
- values)
459
- assert_equal(values, target.values)
460
- end
461
-
462
- def test_map
463
- values = [
464
- [
465
- {"key1" => true, "key2" => nil},
466
- nil,
467
- ],
468
- nil,
469
- ]
470
- target = build({
471
- type: :map,
472
- key: :string,
473
- item: :boolean,
474
- },
475
- values)
476
- assert_equal(values, target.values)
477
- end
478
-
479
- def remove_union_field_names(values)
480
- values.collect do |value|
481
- if value.nil?
482
- value
483
- else
484
- value.collect do |v|
485
- if v.nil?
486
- v
487
- else
488
- v.values[0]
489
- end
490
- end
491
- end
492
- end
493
- end
494
-
495
- def test_sparse_union
496
- values = [
497
- [
498
- {"field1" => true},
499
- nil,
500
- {"field2" => 29},
501
- {"field2" => nil},
502
- ],
503
- nil,
504
- ]
505
- target = build({
506
- type: :sparse_union,
507
- fields: [
508
- {
509
- name: :field1,
510
- type: :boolean,
511
- },
512
- {
513
- name: :field2,
514
- type: :uint8,
515
- },
516
- ],
517
- type_codes: [0, 1],
518
- },
519
- values)
520
- assert_equal(remove_union_field_names(values),
521
- target.values)
522
- end
523
-
524
- def test_dense_union
525
- values = [
526
- [
527
- {"field1" => true},
528
- nil,
529
- {"field2" => 29},
530
- {"field2" => nil},
531
- ],
532
- nil,
533
- ]
534
- target = build({
535
- type: :dense_union,
536
- fields: [
537
- {
538
- name: :field1,
539
- type: :boolean,
540
- },
541
- {
542
- name: :field2,
543
- type: :uint8,
544
- },
545
- ],
546
- type_codes: [0, 1],
547
- },
548
- values)
549
- assert_equal(remove_union_field_names(values),
550
- target.values)
551
- end
552
-
553
- def test_dictionary
554
- values = [
555
- [
556
- "Ruby",
557
- nil,
558
- "GLib",
559
- ],
560
- nil,
561
- ]
562
- target = build({
563
- type: :dictionary,
564
- index_data_type: :int8,
565
- value_data_type: :string,
566
- ordered: false,
567
- },
568
- values)
569
- assert_equal(values, target.values)
570
- end
571
- end
572
-
573
- class ValuesArrayListArrayTest < Test::Unit::TestCase
574
- include ValuesListArrayTests
575
-
576
- def build(type, values)
577
- build_array(type, values)
578
- end
579
- end
580
-
581
- class ValuesChunkedArrayListArrayTest < Test::Unit::TestCase
582
- include ValuesListArrayTests
583
-
584
- def build(type, values)
585
- Arrow::ChunkedArray.new([build_array(type, values)])
586
- end
587
- end