red-arrow 0.15.1 → 0.16.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.
data/test/test-table.rb CHANGED
@@ -54,11 +54,12 @@ class TableTest < Test::Unit::TestCase
54
54
  target_rows = Arrow::BooleanArray.new(target_rows_raw)
55
55
  assert_equal(<<-TABLE, @table.slice(target_rows).to_s)
56
56
  count visible
57
- 0 2 false
58
- 1 4
59
- 2 16 true
60
- 3 64
61
- 4 128
57
+ 0
58
+ 1 2 false
59
+ 2 4
60
+ 3 16 true
61
+ 4 64
62
+ 5 128
62
63
  TABLE
63
64
  end
64
65
 
@@ -66,11 +67,12 @@ class TableTest < Test::Unit::TestCase
66
67
  target_rows_raw = [nil, true, true, false, true, false, true, true]
67
68
  assert_equal(<<-TABLE, @table.slice(target_rows_raw).to_s)
68
69
  count visible
69
- 0 2 false
70
- 1 4
71
- 2 16 true
72
- 3 64
73
- 4 128
70
+ 0
71
+ 1 2 false
72
+ 2 4
73
+ 3 16 true
74
+ 4 64
75
+ 5 128
74
76
  TABLE
75
77
  end
76
78
 
@@ -436,12 +438,24 @@ class TableTest < Test::Unit::TestCase
436
438
  assert_equal(@table, Arrow::Table.load(output))
437
439
  end
438
440
 
441
+ def test_arrow_file
442
+ output = create_output(".arrow")
443
+ @table.save(output, format: :arrow_file)
444
+ assert_equal(@table, Arrow::Table.load(output, format: :arrow_file))
445
+ end
446
+
439
447
  def test_batch
440
448
  output = create_output(".arrow")
441
449
  @table.save(output, format: :batch)
442
450
  assert_equal(@table, Arrow::Table.load(output, format: :batch))
443
451
  end
444
452
 
453
+ def test_arrow_streaming
454
+ output = create_output(".arrow")
455
+ @table.save(output, format: :arrow_streaming)
456
+ assert_equal(@table, Arrow::Table.load(output, format: :arrow_streaming))
457
+ end
458
+
445
459
  def test_stream
446
460
  output = create_output(".arrow")
447
461
  @table.save(output, format: :stream)
@@ -468,6 +482,15 @@ class TableTest < Test::Unit::TestCase
468
482
  compression: :gzip,
469
483
  schema: @table.schema))
470
484
  end
485
+
486
+ def test_tsv
487
+ output = create_output(".tsv")
488
+ @table.save(output, format: :tsv)
489
+ assert_equal(@table,
490
+ Arrow::Table.load(output,
491
+ format: :tsv,
492
+ schema: @table.schema))
493
+ end
471
494
  end
472
495
 
473
496
  sub_test_case("path") do
@@ -498,18 +521,27 @@ class TableTest < Test::Unit::TestCase
498
521
  compression: :gzip,
499
522
  schema: @table.schema))
500
523
  end
524
+
525
+ test("tsv") do
526
+ output = create_output(".tsv")
527
+ @table.save(output)
528
+ assert_equal(@table,
529
+ Arrow::Table.load(output,
530
+ format: :tsv,
531
+ schema: @table.schema))
532
+ end
501
533
  end
502
534
 
503
535
  sub_test_case("load: auto detect") do
504
- test("batch") do
536
+ test("arrow: file") do
505
537
  output = create_output(".arrow")
506
- @table.save(output, format: :batch)
538
+ @table.save(output, format: :arrow_file)
507
539
  assert_equal(@table, Arrow::Table.load(output))
508
540
  end
509
541
 
510
- test("stream") do
542
+ test("arrow: streaming") do
511
543
  output = create_output(".arrow")
512
- @table.save(output, format: :stream)
544
+ @table.save(output, format: :arrow_streaming)
513
545
  assert_equal(@table, Arrow::Table.load(output))
514
546
  end
515
547
 
@@ -539,6 +571,24 @@ chris,-1
539
571
  name score
540
572
  0 alice 10
541
573
  1 bob 29
574
+ 2 chris -1
575
+ TABLE
576
+ end
577
+
578
+ test("tsv") do
579
+ file = Tempfile.new(["red-arrow", ".tsv"])
580
+ file.puts(<<-TSV)
581
+ name\tscore
582
+ alice\t10
583
+ bob\t29
584
+ chris\t-1
585
+ TSV
586
+ file.close
587
+ table = Arrow::Table.load(file.path)
588
+ assert_equal(<<-TABLE, table.to_s)
589
+ name score
590
+ 0 alice 10
591
+ 1 bob 29
542
592
  2 chris -1
543
593
  TABLE
544
594
  end
@@ -646,4 +696,87 @@ visible: false
646
696
  end
647
697
  end
648
698
  end
699
+
700
+ sub_test_case("#filter") do
701
+ test("Array: boolean") do
702
+ filter = [nil, true, true, false, true, false, true, true]
703
+ assert_equal(<<-TABLE, @table.filter(filter).to_s)
704
+ count visible
705
+ 0
706
+ 1 2 false
707
+ 2 4
708
+ 3 16 true
709
+ 4 64
710
+ 5 128
711
+ TABLE
712
+ end
713
+
714
+ test("Arrow::BooleanArray") do
715
+ array = [nil, true, true, false, true, false, true, true]
716
+ filter = Arrow::BooleanArray.new(array)
717
+ assert_equal(<<-TABLE, @table.filter(filter).to_s)
718
+ count visible
719
+ 0
720
+ 1 2 false
721
+ 2 4
722
+ 3 16 true
723
+ 4 64
724
+ 5 128
725
+ TABLE
726
+ end
727
+
728
+ test("Arrow::ChunkedArray") do
729
+ filter_chunks = [
730
+ Arrow::BooleanArray.new([nil, true, true]),
731
+ Arrow::BooleanArray.new([false, true, false]),
732
+ Arrow::BooleanArray.new([true, true]),
733
+ ]
734
+ filter = Arrow::ChunkedArray.new(filter_chunks)
735
+ assert_equal(<<-TABLE, @table.filter(filter).to_s)
736
+ count visible
737
+ 0
738
+ 1 2 false
739
+ 2 4
740
+ 3 16 true
741
+ 4 64
742
+ 5 128
743
+ TABLE
744
+ end
745
+ end
746
+
747
+ sub_test_case("#take") do
748
+ test("Arrow: boolean") do
749
+ indices = [1, 0, 2]
750
+ assert_equal(<<-TABLE, @table.take(indices).to_s)
751
+ count visible
752
+ 0 2 false
753
+ 1 1 true
754
+ 2 4
755
+ TABLE
756
+ end
757
+
758
+ test("Arrow::Array") do
759
+ indices = Arrow::Int16Array.new([1, 0, 2])
760
+ assert_equal(<<-TABLE, @table.take(indices).to_s)
761
+ count visible
762
+ 0 2 false
763
+ 1 1 true
764
+ 2 4
765
+ TABLE
766
+ end
767
+
768
+ test("Arrow::ChunkedArray") do
769
+ chunks = [
770
+ Arrow::Int16Array.new([1, 0]),
771
+ Arrow::Int16Array.new([2])
772
+ ]
773
+ indices = Arrow::ChunkedArray.new(chunks)
774
+ assert_equal(<<-TABLE, @table.take(indices).to_s)
775
+ count visible
776
+ 0 2 false
777
+ 1 1 true
778
+ 2 4
779
+ TABLE
780
+ end
781
+ end
649
782
  end
@@ -23,4 +23,23 @@ class TimestampArrayTest < Test::Unit::TestCase
23
23
  time = Time.at(sec, usec)
24
24
  assert_equal(time, array[0])
25
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
26
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-arrow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apache Arrow Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: extpp
@@ -191,7 +191,6 @@ files:
191
191
  - lib/arrow/array-builder.rb
192
192
  - lib/arrow/array.rb
193
193
  - lib/arrow/bigdecimal-extension.rb
194
- - lib/arrow/binary-array-builder.rb
195
194
  - lib/arrow/block-closable.rb
196
195
  - lib/arrow/chunked-array.rb
197
196
  - lib/arrow/column-containable.rb
@@ -213,11 +212,14 @@ files:
213
212
  - lib/arrow/field-containable.rb
214
213
  - lib/arrow/field.rb
215
214
  - lib/arrow/file-output-stream.rb
215
+ - lib/arrow/generic-filterable.rb
216
+ - lib/arrow/generic-takeable.rb
216
217
  - lib/arrow/group.rb
217
218
  - lib/arrow/list-array-builder.rb
218
219
  - lib/arrow/list-data-type.rb
219
220
  - lib/arrow/loader.rb
220
221
  - lib/arrow/null-array-builder.rb
222
+ - lib/arrow/null-array.rb
221
223
  - lib/arrow/path-extension.rb
222
224
  - lib/arrow/record-batch-builder.rb
223
225
  - lib/arrow/record-batch-file-reader.rb
@@ -294,6 +296,7 @@ files:
294
296
  - test/test-list-array-builder.rb
295
297
  - test/test-list-array.rb
296
298
  - test/test-list-data-type.rb
299
+ - test/test-null-array.rb
297
300
  - test/test-orc.rb
298
301
  - test/test-record-batch-builder.rb
299
302
  - test/test-record-batch-file-reader.rb
@@ -323,7 +326,7 @@ homepage: https://arrow.apache.org/
323
326
  licenses:
324
327
  - Apache-2.0
325
328
  metadata:
326
- msys2_mingw_dependencies: arrow
329
+ msys2_mingw_dependencies: arrow>=0.16.0
327
330
  post_install_message:
328
331
  rdoc_options: []
329
332
  require_paths:
@@ -339,75 +342,77 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
342
  - !ruby/object:Gem::Version
340
343
  version: '0'
341
344
  requirements: []
342
- rubygems_version: 3.0.6
345
+ rubyforge_project:
346
+ rubygems_version: 2.7.6.2
343
347
  signing_key:
344
348
  specification_version: 4
345
349
  summary: Red Arrow is the Ruby bindings of Apache Arrow
346
350
  test_files:
347
- - test/test-orc.rb
348
- - test/test-file-output-stream.rb
351
+ - test/test-time64-data-type.rb
352
+ - test/test-feather.rb
353
+ - test/test-decimal128.rb
354
+ - test/test-struct-array.rb
355
+ - test/test-data-type.rb
356
+ - test/test-list-data-type.rb
349
357
  - test/test-dense-union-data-type.rb
350
- - test/test-record-batch-builder.rb
358
+ - test/helper.rb
351
359
  - test/test-record-batch.rb
352
- - test/test-list-data-type.rb
353
- - test/test-decimal128.rb
354
- - test/test-chunked-array.rb
355
- - test/test-array.rb
356
- - test/test-struct-array-builder.rb
357
360
  - test/test-table.rb
361
+ - test/run-test.rb
362
+ - test/test-timestamp-array.rb
363
+ - test/test-date32-array.rb
364
+ - test/test-array-builder.rb
365
+ - test/test-date64-array.rb
366
+ - test/test-record-batch-file-reader.rb
358
367
  - test/test-decimal128-data-type.rb
359
- - test/fixture/TestOrcFile.test1.orc
368
+ - test/test-time.rb
369
+ - test/test-timestamp-data-type.rb
370
+ - test/test-column.rb
371
+ - test/test-field.rb
372
+ - test/test-decimal128-array.rb
373
+ - test/test-csv-loader.rb
374
+ - test/test-bigdecimal.rb
375
+ - test/test-list-array.rb
376
+ - test/test-time64-array.rb
377
+ - test/test-rolling-window.rb
378
+ - test/test-dictionary-data-type.rb
360
379
  - test/fixture/integer-float.csv
361
- - test/fixture/null-with-double-quote.csv
362
- - test/fixture/with-header.csv
363
- - test/fixture/without-header.csv
364
380
  - test/fixture/without-header-float.csv
381
+ - test/fixture/null-with-double-quote.csv
365
382
  - test/fixture/with-header-float.csv
383
+ - test/fixture/TestOrcFile.test1.orc
366
384
  - test/fixture/null-without-double-quote.csv
385
+ - test/fixture/without-header.csv
386
+ - test/fixture/with-header.csv
367
387
  - test/fixture/float-integer.csv
368
- - test/run-test.rb
388
+ - test/test-orc.rb
389
+ - test/test-null-array.rb
390
+ - test/test-time32-data-type.rb
391
+ - test/test-struct-data-type.rb
369
392
  - test/test-group.rb
370
- - test/helper.rb
371
- - test/test-time64-array.rb
372
- - test/test-csv-loader.rb
373
- - test/test-feather.rb
374
- - test/test-time64-data-type.rb
375
- - test/values/test-sparse-union-array.rb
393
+ - test/test-buffer.rb
394
+ - test/values/test-struct-array.rb
376
395
  - test/values/test-basic-arrays.rb
377
- - test/values/test-dense-union-array.rb
378
396
  - test/values/test-list-array.rb
379
- - test/values/test-struct-array.rb
380
- - test/test-struct-data-type.rb
381
- - test/test-date64-array.rb
382
- - test/raw-records/test-sparse-union-array.rb
383
- - test/raw-records/test-multiple-columns.rb
384
- - test/raw-records/test-basic-arrays.rb
397
+ - test/values/test-dense-union-array.rb
398
+ - test/values/test-sparse-union-array.rb
399
+ - test/test-slicer.rb
400
+ - test/test-list-array-builder.rb
401
+ - test/test-sparse-union-data-type.rb
402
+ - test/test-record-batch-builder.rb
403
+ - test/raw-records/test-struct-array.rb
385
404
  - test/raw-records/test-table.rb
386
- - test/raw-records/test-dense-union-array.rb
405
+ - test/raw-records/test-basic-arrays.rb
387
406
  - test/raw-records/test-list-array.rb
388
- - test/raw-records/test-struct-array.rb
389
- - test/test-list-array.rb
390
- - test/test-timestamp-data-type.rb
391
- - test/test-timestamp-array.rb
392
- - test/test-data-type.rb
393
- - test/test-array-builder.rb
394
- - test/test-time32-data-type.rb
395
- - test/test-record-batch-file-reader.rb
396
- - test/test-rolling-window.rb
397
- - test/test-list-array-builder.rb
398
- - test/test-slicer.rb
407
+ - test/raw-records/test-dense-union-array.rb
408
+ - test/raw-records/test-sparse-union-array.rb
409
+ - test/raw-records/test-multiple-columns.rb
410
+ - test/test-array.rb
411
+ - test/test-file-output-stream.rb
412
+ - test/test-tensor.rb
399
413
  - test/test-decimal128-array-builder.rb
414
+ - test/test-chunked-array.rb
400
415
  - test/test-schema.rb
401
- - test/test-time.rb
402
- - test/test-column.rb
403
- - test/test-bigdecimal.rb
404
- - test/test-sparse-union-data-type.rb
405
- - test/test-tensor.rb
406
- - test/test-time32-array.rb
407
- - test/test-buffer.rb
408
- - test/test-decimal128-array.rb
416
+ - test/test-struct-array-builder.rb
409
417
  - test/helper/fixture.rb
410
- - test/test-dictionary-data-type.rb
411
- - test/test-date32-array.rb
412
- - test/test-field.rb
413
- - test/test-struct-array.rb
418
+ - test/test-time32-array.rb