red-arrow 18.1.0 → 19.0.1

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 (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,126 +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 Decimal256Test < Test::Unit::TestCase
19
- sub_test_case("instance methods") do
20
- def setup
21
- @decimal256 = Arrow::Decimal256.new("10.1")
22
- end
23
-
24
- sub_test_case("#==") do
25
- test("Arrow::Decimal256") do
26
- assert do
27
- @decimal256 == @decimal256
28
- end
29
- end
30
-
31
- test("String") do
32
- assert do
33
- @decimal256 == "10.1"
34
- end
35
- end
36
-
37
- test("Float") do
38
- assert do
39
- @decimal256 == 10.1
40
- end
41
- end
42
-
43
- test("not Arrow::Decimal256") do
44
- assert do
45
- not (@decimal256 == :"10.1")
46
- end
47
- end
48
- end
49
-
50
- sub_test_case("#!=") do
51
- test("Arrow::Decimal256") do
52
- assert do
53
- not (@decimal256 != @decimal256)
54
- end
55
- end
56
-
57
- test("String") do
58
- assert do
59
- not (@decimal256 != "10.1")
60
- end
61
- end
62
-
63
- test("Float") do
64
- assert do
65
- not (@decimal256 != 10.1)
66
- end
67
- end
68
-
69
- test("not Arrow::Decimal256") do
70
- assert do
71
- @decimal256 != :"10.1"
72
- end
73
- end
74
- end
75
-
76
- sub_test_case("#to_s") do
77
- test("default") do
78
- assert_equal("101",
79
- @decimal256.to_s)
80
- end
81
-
82
- test("scale") do
83
- assert_equal("10.1",
84
- @decimal256.to_s(1))
85
- end
86
- end
87
-
88
- test("#abs") do
89
- decimal256 = Arrow::Decimal256.new("-10.1")
90
- assert_equal([
91
- Arrow::Decimal256.new("-10.1"),
92
- Arrow::Decimal256.new("10.1"),
93
- ],
94
- [
95
- decimal256,
96
- decimal256.abs,
97
- ])
98
- end
99
-
100
- test("#abs!") do
101
- decimal256 = Arrow::Decimal256.new("-10.1")
102
- decimal256.abs!
103
- assert_equal(Arrow::Decimal256.new("10.1"),
104
- decimal256)
105
- end
106
-
107
- test("#negate") do
108
- decimal256 = Arrow::Decimal256.new("-10.1")
109
- assert_equal([
110
- Arrow::Decimal256.new("-10.1"),
111
- Arrow::Decimal256.new("10.1"),
112
- ],
113
- [
114
- decimal256,
115
- decimal256.negate,
116
- ])
117
- end
118
-
119
- test("#negate!") do
120
- decimal256 = Arrow::Decimal256.new("-10.1")
121
- decimal256.negate!
122
- assert_equal(Arrow::Decimal256.new("10.1"),
123
- decimal256)
124
- end
125
- end
126
- 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 DenseUnionArrayTest < Test::Unit::TestCase
19
- def setup
20
- data_type_fields = [
21
- Arrow::Field.new("number", :int16),
22
- Arrow::Field.new("text", :string),
23
- ]
24
- type_codes = [11, 13]
25
- @data_type = Arrow::DenseUnionDataType.new(data_type_fields, type_codes)
26
- type_ids = Arrow::Int8Array.new([11, 13, 11, 13, 13])
27
- value_offsets = Arrow::Int32Array.new([0, 0, 1, 1, 2])
28
- fields = [
29
- Arrow::Int16Array.new([1, nil]),
30
- Arrow::StringArray.new(["a", "b", "c"])
31
- ]
32
- @array = Arrow::DenseUnionArray.new(@data_type,
33
- type_ids,
34
- value_offsets,
35
- fields)
36
- end
37
-
38
- def test_get_value
39
- assert_equal([1, "a", nil, "b", "c"],
40
- @array.length.times.collect {|i| @array[i]})
41
- end
42
- 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 DenseUnionDataTypeTest < 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("dense_union<visible: bool=2, count: int32=9>",
32
- Arrow::DenseUnionDataType.new(@fields, [2, 9]).to_s)
33
- end
34
-
35
- test("description") do
36
- assert_equal("dense_union<visible: bool=2, count: int32=9>",
37
- Arrow::DenseUnionDataType.new(fields: @fields,
38
- type_codes: [2, 9]).to_s)
39
- end
40
- end
41
- 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 DictionaryArrayTest < Test::Unit::TestCase
19
- sub_test_case("instance methods") do
20
- def setup
21
- @values = ["a", "b", "c", "b", "a"]
22
- @string_array = Arrow::StringArray.new(@values)
23
- @array = @string_array.dictionary_encode
24
- end
25
-
26
- test("#[]") do
27
- assert_equal(@values, @array.to_a)
28
- end
29
-
30
- test("#get_value") do
31
- assert_equal([
32
- @values[0],
33
- @values[3],
34
- ],
35
- [
36
- @array.get_value(0),
37
- @array.get_value(3),
38
- ])
39
- end
40
- end
41
- 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 DictionaryDataTypeTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- def setup
21
- @index_data_type = :int8
22
- @value_data_type = :string
23
- @ordered = true
24
- end
25
-
26
- test("ordered arguments") do
27
- assert_equal("dictionary<values=string, indices=int8, ordered=1>",
28
- Arrow::DictionaryDataType.new(@index_data_type,
29
- @value_data_type,
30
- @ordered).to_s)
31
- end
32
-
33
- test("description") do
34
- assert_equal("dictionary<values=string, indices=int8, ordered=1>",
35
- Arrow::DictionaryDataType.new(index_data_type: @index_data_type,
36
- value_data_type: @value_data_type,
37
- ordered: @ordered).to_s)
38
- end
39
- end
40
- end
@@ -1,51 +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 TestExpression < Test::Unit::TestCase
19
- sub_test_case(".try_convert") do
20
- test("Symbol") do
21
- assert_equal(Arrow::FieldExpression.new("visible"),
22
- Arrow::Expression.try_convert(:visible))
23
- end
24
-
25
- test("[String]") do
26
- assert_equal(Arrow::CallExpression.new("func", []),
27
- Arrow::Expression.try_convert(["func"]))
28
- end
29
-
30
- test("[Symbol]") do
31
- assert_equal(Arrow::CallExpression.new("func", []),
32
- Arrow::Expression.try_convert([:func]))
33
- end
34
-
35
- test("[String, String]") do
36
- assert_equal(Arrow::CallExpression.new("func", ["argument1"]),
37
- Arrow::Expression.try_convert(["func", "argument1"]))
38
- end
39
-
40
- test("[Symbol, String, Hash]") do
41
- options = Arrow::MatchSubstringOptions.new
42
- options.pattern = "hello"
43
- assert_equal(Arrow::CallExpression.new("match_substring",
44
- ["content"],
45
- options),
46
- Arrow::Expression.try_convert([:match_substring,
47
- "content",
48
- {pattern: "hello"}]))
49
- end
50
- end
51
- end
data/test/test-feather.rb DELETED
@@ -1,49 +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 FeatherTest < Test::Unit::TestCase
19
- include Helper::Fixture
20
-
21
- def setup
22
- columns = {
23
- "message" => Arrow::StringArray.new(["Start", "Crash", "Shutdown"]),
24
- "is_critical" => Arrow::BooleanArray.new([false, true, false]),
25
- }
26
- @table = Arrow::Table.new(columns)
27
-
28
- @output = Tempfile.new(["red-arrow", ".feather"])
29
- begin
30
- yield(@output)
31
- ensure
32
- @output.close!
33
- end
34
- end
35
-
36
- def test_default
37
- @table.save(@output.path)
38
- @output.close
39
-
40
- assert_equal(@table, Arrow::Table.load(@output.path))
41
- end
42
-
43
- def test_compression
44
- @table.save(@output.path, compression: :zstd)
45
- @output.close
46
-
47
- assert_equal(@table, Arrow::Table.load(@output.path))
48
- end
49
- end
data/test/test-field.rb DELETED
@@ -1,117 +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 FieldTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("String, Arrow::DataType") do
21
- assert_equal("visible: bool",
22
- Arrow::Field.new("visible", Arrow::BooleanDataType.new).to_s)
23
- end
24
-
25
- test("String, Arrow::DataType, Boolean") do
26
- assert_equal("visible: bool not null",
27
- Arrow::Field.new("visible",
28
- Arrow::BooleanDataType.new,
29
- false).to_s)
30
- end
31
-
32
- test("Symbol, Arrow::DataType") do
33
- assert_equal("visible: bool",
34
- Arrow::Field.new(:visible, Arrow::BooleanDataType.new).to_s)
35
- end
36
-
37
- test("String, Symbol") do
38
- assert_equal("visible: bool",
39
- Arrow::Field.new(:visible, :boolean).to_s)
40
- end
41
-
42
- test("String, Hash") do
43
- assert_equal("visible: bool",
44
- Arrow::Field.new(:visible, type: :boolean).to_s)
45
- end
46
-
47
- test("String, Hash (:nullable)") do
48
- assert_equal("visible: bool not null",
49
- Arrow::Field.new(:visible,
50
- type: :boolean,
51
- nullable: false).to_s)
52
- end
53
-
54
- test("String, Hash, Boolean)") do
55
- assert_equal("visible: bool not null",
56
- Arrow::Field.new(:visible, {type: :boolean}, false).to_s)
57
- end
58
-
59
- test("description: String") do
60
- assert_equal("visible: bool",
61
- Arrow::Field.new(name: "visible",
62
- data_type: :boolean).to_s)
63
- end
64
-
65
- test("description: Symbol") do
66
- assert_equal("visible: bool",
67
- Arrow::Field.new(name: :visible,
68
- data_type: :boolean).to_s)
69
- end
70
-
71
- test("description: shortcut") do
72
- assert_equal("visible: bool",
73
- Arrow::Field.new(name: :visible,
74
- type: :boolean).to_s)
75
- end
76
-
77
- test("description: nullable") do
78
- assert_equal("visible: bool not null",
79
- Arrow::Field.new(name: :visible,
80
- data_type: :boolean,
81
- nullable: false).to_s)
82
- end
83
-
84
- test("Hash: shortcut: additional") do
85
- description = {
86
- name: :tags,
87
- type: :list,
88
- field: {
89
- name: "tag",
90
- type: :string,
91
- },
92
- }
93
- assert_equal("tags: list<tag: string>",
94
- Arrow::Field.new(description).to_s)
95
- end
96
- end
97
-
98
- sub_test_case("instance methods") do
99
- def setup
100
- @field = Arrow::Field.new("count", :uint32)
101
- end
102
-
103
- sub_test_case("#==") do
104
- test("Arrow::Field") do
105
- assert do
106
- @field == @field
107
- end
108
- end
109
-
110
- test("not Arrow::Field") do
111
- assert do
112
- not (@field == 29)
113
- end
114
- end
115
- end
116
- end
117
- end
@@ -1,54 +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 TestFileOutputStream < Test::Unit::TestCase
19
- sub_test_case(".open") do
20
- def setup
21
- @file = Tempfile.open("arrow-file-output-stream")
22
- @file.write("Hello")
23
- @file.close
24
- end
25
-
26
- def test_default
27
- Arrow::FileOutputStream.open(@file.path) do |file|
28
- file.write(" World")
29
- end
30
- assert_equal(" World", File.read(@file.path))
31
- end
32
-
33
- def test_options_append
34
- Arrow::FileOutputStream.open(@file.path, append: true) do |file|
35
- file.write(" World")
36
- end
37
- assert_equal("Hello World", File.read(@file.path))
38
- end
39
-
40
- def test_append_true
41
- Arrow::FileOutputStream.open(@file.path, true) do |file|
42
- file.write(" World")
43
- end
44
- assert_equal("Hello World", File.read(@file.path))
45
- end
46
-
47
- def test_append_false
48
- Arrow::FileOutputStream.open(@file.path, false) do |file|
49
- file.write(" World")
50
- end
51
- assert_equal(" World", File.read(@file.path))
52
- end
53
- end
54
- end
@@ -1,92 +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 FixedSizeBinaryArrayBuilderTest < Test::Unit::TestCase
19
- def setup
20
- @data_type = Arrow::FixedSizeBinaryDataType.new(4)
21
- @builder = Arrow::FixedSizeBinaryArrayBuilder.new(@data_type)
22
- end
23
-
24
- sub_test_case("#append_value") do
25
- test("nil") do
26
- @builder.append_value(nil)
27
- array = @builder.finish
28
- assert_equal(nil, array[0])
29
- end
30
-
31
- test("String") do
32
- @builder.append_value("0123")
33
- array = @builder.finish
34
- assert_equal("0123", array[0])
35
- end
36
-
37
- test("GLib::Bytes") do
38
- @builder.append_value(GLib::Bytes.new("0123"))
39
- array = @builder.finish
40
- assert_equal("0123", array[0])
41
- end
42
- end
43
-
44
- sub_test_case("#append_values") do
45
- test("mixed") do
46
- @builder.append_values([
47
- "0123",
48
- nil,
49
- GLib::Bytes.new("abcd"),
50
- ])
51
- array = @builder.finish
52
- assert_equal([
53
- "0123",
54
- nil,
55
- "abcd",
56
- ],
57
- array.to_a)
58
- end
59
-
60
- test("is_valids") do
61
- @builder.append_values([
62
- "0123",
63
- "0123",
64
- "0123",
65
- ],
66
- [
67
- true,
68
- false,
69
- true,
70
- ])
71
- array = @builder.finish
72
- assert_equal([
73
- "0123",
74
- nil,
75
- "0123",
76
- ],
77
- array.to_a)
78
- end
79
-
80
- test("packed") do
81
- @builder.append_values("0123" * 3,
82
- [true, false, true])
83
- array = @builder.finish
84
- assert_equal([
85
- "0123",
86
- nil,
87
- "0123",
88
- ],
89
- array.to_a)
90
- end
91
- end
92
- end
@@ -1,36 +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 FixedSizeBinaryArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("build") do
21
- data_type = Arrow::FixedSizeBinaryDataType.new(4)
22
- values = [
23
- "0123",
24
- nil,
25
- GLib::Bytes.new("abcd"),
26
- ]
27
- array = Arrow::FixedSizeBinaryArray.new(data_type, values)
28
- assert_equal([
29
- "0123",
30
- nil,
31
- "abcd",
32
- ],
33
- array.to_a)
34
- end
35
- end
36
- end