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.
- checksums.yaml +4 -4
- data/lib/arrow/array.rb +7 -4
- data/lib/arrow/column.rb +4 -4
- data/lib/arrow/jruby/array-builder.rb +114 -0
- data/lib/arrow/jruby/array.rb +109 -0
- data/{test/helper/fixture.rb → lib/arrow/jruby/chunked-array.rb} +14 -6
- data/lib/arrow/jruby/compression-type.rb +26 -0
- data/{test/test-boolean-scalar.rb → lib/arrow/jruby/csv-read-options.rb} +12 -6
- data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
- data/lib/arrow/jruby/decimal128.rb +28 -0
- data/lib/arrow/jruby/decimal256.rb +28 -0
- data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/error.rb} +7 -4
- data/lib/arrow/jruby/file-system.rb +24 -0
- data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
- data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
- data/{test/fixture/integer-float.csv → lib/arrow/jruby/record-batch.rb} +8 -4
- data/{test/fixture/float-integer.csv → lib/arrow/jruby/sort-key.rb} +8 -4
- data/lib/arrow/jruby/sort-options.rb +24 -0
- data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
- data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
- data/lib/arrow/jruby/writable.rb +24 -0
- data/lib/arrow/jruby.rb +52 -0
- data/lib/arrow/libraries.rb +126 -0
- data/lib/arrow/list-array-builder.rb +1 -0
- data/lib/arrow/loader.rb +3 -111
- data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +6 -4
- data/lib/arrow/version.rb +1 -1
- data/lib/arrow.rb +2 -7
- data/red-arrow.gemspec +15 -6
- metadata +26 -229
- data/test/each-raw-record/test-basic-arrays.rb +0 -411
- data/test/each-raw-record/test-dense-union-array.rb +0 -566
- data/test/each-raw-record/test-dictionary-array.rb +0 -341
- data/test/each-raw-record/test-list-array.rb +0 -628
- data/test/each-raw-record/test-map-array.rb +0 -507
- data/test/each-raw-record/test-multiple-columns.rb +0 -72
- data/test/each-raw-record/test-sparse-union-array.rb +0 -528
- data/test/each-raw-record/test-struct-array.rb +0 -529
- data/test/each-raw-record/test-table.rb +0 -47
- data/test/fixture/TestOrcFile.test1.orc +0 -0
- data/test/fixture/with-header-float.csv +0 -20
- data/test/fixture/with-header.csv +0 -20
- data/test/fixture/without-header-float.csv +0 -19
- data/test/fixture/without-header.csv +0 -19
- data/test/helper/omittable.rb +0 -49
- data/test/helper.rb +0 -31
- data/test/raw-records/test-basic-arrays.rb +0 -405
- data/test/raw-records/test-dense-union-array.rb +0 -566
- data/test/raw-records/test-dictionary-array.rb +0 -341
- data/test/raw-records/test-list-array.rb +0 -628
- data/test/raw-records/test-map-array.rb +0 -507
- data/test/raw-records/test-multiple-columns.rb +0 -65
- data/test/raw-records/test-sparse-union-array.rb +0 -556
- data/test/raw-records/test-struct-array.rb +0 -529
- data/test/raw-records/test-table.rb +0 -47
- data/test/run-test.rb +0 -71
- data/test/test-array-builder.rb +0 -198
- data/test/test-array.rb +0 -332
- data/test/test-bigdecimal.rb +0 -40
- data/test/test-binary-dictionary-array-builder.rb +0 -103
- data/test/test-buffer.rb +0 -49
- data/test/test-chunked-array.rb +0 -198
- data/test/test-column.rb +0 -123
- data/test/test-csv-loader.rb +0 -297
- data/test/test-data-type.rb +0 -84
- data/test/test-date32-array.rb +0 -24
- data/test/test-date64-array.rb +0 -25
- data/test/test-decimal128-array-builder.rb +0 -126
- data/test/test-decimal128-array.rb +0 -47
- data/test/test-decimal128-data-type.rb +0 -31
- data/test/test-decimal128.rb +0 -126
- data/test/test-decimal256-array-builder.rb +0 -126
- data/test/test-decimal256-array.rb +0 -47
- data/test/test-decimal256-data-type.rb +0 -31
- data/test/test-decimal256.rb +0 -126
- data/test/test-dense-union-array.rb +0 -42
- data/test/test-dense-union-data-type.rb +0 -41
- data/test/test-dictionary-array.rb +0 -41
- data/test/test-dictionary-data-type.rb +0 -40
- data/test/test-expression.rb +0 -51
- data/test/test-feather.rb +0 -49
- data/test/test-field.rb +0 -117
- data/test/test-file-output-stream.rb +0 -54
- data/test/test-fixed-size-binary-array-builder.rb +0 -92
- data/test/test-fixed-size-binary-array.rb +0 -36
- data/test/test-float-scalar.rb +0 -46
- data/test/test-function.rb +0 -210
- data/test/test-group.rb +0 -193
- data/test/test-half-float-array.rb +0 -43
- data/test/test-half-float.rb +0 -130
- data/test/test-list-array-builder.rb +0 -79
- data/test/test-list-array.rb +0 -32
- data/test/test-list-data-type.rb +0 -69
- data/test/test-map-array-builder.rb +0 -110
- data/test/test-map-array.rb +0 -33
- data/test/test-memory-view.rb +0 -434
- data/test/test-orc.rb +0 -173
- data/test/test-ractor.rb +0 -34
- data/test/test-record-batch-builder.rb +0 -125
- data/test/test-record-batch-file-reader.rb +0 -136
- data/test/test-record-batch-iterator.rb +0 -37
- data/test/test-record-batch-reader.rb +0 -46
- data/test/test-record-batch-stream-reader.rb +0 -129
- data/test/test-record-batch.rb +0 -182
- data/test/test-scalar.rb +0 -65
- data/test/test-schema.rb +0 -134
- data/test/test-slicer.rb +0 -589
- data/test/test-sort-indices.rb +0 -40
- data/test/test-sort-key.rb +0 -81
- data/test/test-sort-options.rb +0 -58
- data/test/test-sparse-union-array.rb +0 -38
- data/test/test-sparse-union-data-type.rb +0 -41
- data/test/test-stream-listener.rb +0 -60
- data/test/test-string-dictionary-array-builder.rb +0 -103
- data/test/test-struct-array-builder.rb +0 -184
- data/test/test-struct-array.rb +0 -94
- data/test/test-struct-data-type.rb +0 -112
- data/test/test-table.rb +0 -1530
- data/test/test-tensor.rb +0 -297
- data/test/test-time.rb +0 -288
- data/test/test-time32-array.rb +0 -81
- data/test/test-time32-data-type.rb +0 -42
- data/test/test-time64-array.rb +0 -81
- data/test/test-time64-data-type.rb +0 -42
- data/test/test-timestamp-array.rb +0 -45
- data/test/test-timestamp-data-type.rb +0 -42
- data/test/values/test-basic-arrays.rb +0 -335
- data/test/values/test-dense-union-array.rb +0 -552
- data/test/values/test-dictionary-array.rb +0 -325
- data/test/values/test-list-array.rb +0 -587
- data/test/values/test-map-array.rb +0 -489
- data/test/values/test-sparse-union-array.rb +0 -543
- data/test/values/test-struct-array.rb +0 -524
data/test/test-array-builder.rb
DELETED
@@ -1,198 +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 ArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".build") do
|
20
|
-
def assert_build(builder_class, raw_array)
|
21
|
-
array = builder_class.build(raw_array)
|
22
|
-
assert_equal(raw_array, array.to_a)
|
23
|
-
end
|
24
|
-
|
25
|
-
sub_test_case("generic builder") do
|
26
|
-
test("strings") do
|
27
|
-
assert_build(Arrow::ArrayBuilder,
|
28
|
-
["Hello", nil, "World"])
|
29
|
-
end
|
30
|
-
|
31
|
-
test("symbols") do
|
32
|
-
array = Arrow::ArrayBuilder.build([:hello, nil, :world])
|
33
|
-
expected_builder = Arrow::StringDictionaryArrayBuilder.new
|
34
|
-
assert_equal(expected_builder.build(["hello", nil, "world"]),
|
35
|
-
array)
|
36
|
-
end
|
37
|
-
|
38
|
-
test("boolean") do
|
39
|
-
assert_build(Arrow::ArrayBuilder,
|
40
|
-
[true, nil, false])
|
41
|
-
end
|
42
|
-
|
43
|
-
test("positive integers") do
|
44
|
-
assert_build(Arrow::ArrayBuilder,
|
45
|
-
[1, nil, 2, nil, 3])
|
46
|
-
end
|
47
|
-
|
48
|
-
test("negative integers") do
|
49
|
-
assert_build(Arrow::ArrayBuilder,
|
50
|
-
[nil, -1, nil, -2, nil, -3])
|
51
|
-
end
|
52
|
-
|
53
|
-
test("times") do
|
54
|
-
assert_build(Arrow::ArrayBuilder,
|
55
|
-
[Time.at(0), Time.at(1), Time.at(2)])
|
56
|
-
end
|
57
|
-
|
58
|
-
test("dates") do
|
59
|
-
assert_build(Arrow::ArrayBuilder,
|
60
|
-
[Date.new(2018, 1, 4), Date.new(2018, 1, 5)])
|
61
|
-
end
|
62
|
-
|
63
|
-
test("datetimes") do
|
64
|
-
assert_build(Arrow::ArrayBuilder,
|
65
|
-
[
|
66
|
-
DateTime.new(2018, 1, 4, 23, 18, 23),
|
67
|
-
DateTime.new(2018, 1, 5, 0, 23, 21),
|
68
|
-
])
|
69
|
-
end
|
70
|
-
|
71
|
-
test("decimal + string") do
|
72
|
-
raw_array = [BigDecimal("10.1"), "10.1"]
|
73
|
-
array = Arrow::ArrayBuilder.build(raw_array)
|
74
|
-
assert_equal(raw_array.collect(&:to_s), array.to_a)
|
75
|
-
end
|
76
|
-
|
77
|
-
test("NaN") do
|
78
|
-
raw_array = [BigDecimal("10.1"), BigDecimal::NAN]
|
79
|
-
array = Arrow::ArrayBuilder.build(raw_array)
|
80
|
-
assert_equal(raw_array.collect(&:to_s), array.to_a)
|
81
|
-
end
|
82
|
-
|
83
|
-
test("Infinity") do
|
84
|
-
raw_array = [BigDecimal("10.1"), BigDecimal::INFINITY]
|
85
|
-
array = Arrow::ArrayBuilder.build(raw_array)
|
86
|
-
assert_equal(raw_array.collect(&:to_s), array.to_a)
|
87
|
-
end
|
88
|
-
|
89
|
-
test("decimal128") do
|
90
|
-
values = [
|
91
|
-
BigDecimal("10.1"),
|
92
|
-
BigDecimal("1.11"),
|
93
|
-
BigDecimal("1"),
|
94
|
-
]
|
95
|
-
array = Arrow::Array.new(values)
|
96
|
-
data_type = Arrow::Decimal128DataType.new(3, 2)
|
97
|
-
assert_equal({
|
98
|
-
data_type: data_type,
|
99
|
-
values: [
|
100
|
-
BigDecimal("10.1"),
|
101
|
-
BigDecimal("1.11"),
|
102
|
-
BigDecimal("1"),
|
103
|
-
],
|
104
|
-
},
|
105
|
-
{
|
106
|
-
data_type: array.value_data_type,
|
107
|
-
values: array.to_a,
|
108
|
-
})
|
109
|
-
end
|
110
|
-
|
111
|
-
test("decimal256") do
|
112
|
-
values = [
|
113
|
-
BigDecimal("1" * 40 + ".1"),
|
114
|
-
BigDecimal("1" * 38 + ".11"),
|
115
|
-
BigDecimal("1" * 37),
|
116
|
-
]
|
117
|
-
array = Arrow::Array.new(values)
|
118
|
-
data_type = Arrow::Decimal256DataType.new(41, 2)
|
119
|
-
assert_equal({
|
120
|
-
data_type: data_type,
|
121
|
-
values: [
|
122
|
-
BigDecimal("1" * 40 + ".1"),
|
123
|
-
BigDecimal("1" * 38 + ".11"),
|
124
|
-
BigDecimal("1" * 37),
|
125
|
-
],
|
126
|
-
},
|
127
|
-
{
|
128
|
-
data_type: array.value_data_type,
|
129
|
-
values: array.to_a,
|
130
|
-
})
|
131
|
-
end
|
132
|
-
|
133
|
-
test("list<boolean>s") do
|
134
|
-
assert_build(Arrow::ArrayBuilder,
|
135
|
-
[
|
136
|
-
[nil, true, false],
|
137
|
-
nil,
|
138
|
-
[false],
|
139
|
-
])
|
140
|
-
end
|
141
|
-
|
142
|
-
test("list<string>s") do
|
143
|
-
assert_build(Arrow::ArrayBuilder,
|
144
|
-
[
|
145
|
-
["Hello", "World"],
|
146
|
-
["Apache Arrow"],
|
147
|
-
])
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
sub_test_case("specific builder") do
|
152
|
-
test("empty") do
|
153
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
154
|
-
[])
|
155
|
-
end
|
156
|
-
|
157
|
-
test("values") do
|
158
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
159
|
-
[1, -2])
|
160
|
-
end
|
161
|
-
|
162
|
-
test("values, nils") do
|
163
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
164
|
-
[1, -2, nil, nil])
|
165
|
-
end
|
166
|
-
|
167
|
-
test("values, nils, values") do
|
168
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
169
|
-
[1, -2, nil, nil, 3, -4])
|
170
|
-
end
|
171
|
-
|
172
|
-
test("values, nils, values, nils") do
|
173
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
174
|
-
[1, -2, nil, nil, 3, -4, nil, nil])
|
175
|
-
end
|
176
|
-
|
177
|
-
test("nils") do
|
178
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
179
|
-
[nil, nil])
|
180
|
-
end
|
181
|
-
|
182
|
-
test("nils, values") do
|
183
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
184
|
-
[nil, nil, 3, -4])
|
185
|
-
end
|
186
|
-
|
187
|
-
test("nils, values, nil") do
|
188
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
189
|
-
[nil, nil, 3, -4, nil, nil])
|
190
|
-
end
|
191
|
-
|
192
|
-
test("nils, values, nil, values") do
|
193
|
-
assert_build(Arrow::Int32ArrayBuilder,
|
194
|
-
[nil, nil, 3, -4, nil, nil, 5, -6])
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
data/test/test-array.rb
DELETED
@@ -1,332 +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 ArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("Boolean") do
|
21
|
-
array = Arrow::BooleanArray.new([true, false, true])
|
22
|
-
assert_equal([true, false, true],
|
23
|
-
array.to_a)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
sub_test_case("instance methods") do
|
28
|
-
def setup
|
29
|
-
@values = [true, false, nil, true]
|
30
|
-
@array = Arrow::BooleanArray.new(@values)
|
31
|
-
end
|
32
|
-
|
33
|
-
test("#each") do
|
34
|
-
assert_equal(@values, @array.to_a)
|
35
|
-
end
|
36
|
-
|
37
|
-
sub_test_case("#[]") do
|
38
|
-
test("valid range") do
|
39
|
-
assert_equal(@values,
|
40
|
-
@array.length.times.collect {|i| @array[i]})
|
41
|
-
end
|
42
|
-
|
43
|
-
test("out of range") do
|
44
|
-
assert_nil(@array[@array.length])
|
45
|
-
end
|
46
|
-
|
47
|
-
test("negative index") do
|
48
|
-
assert_equal(@values.last,
|
49
|
-
@array[-1])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
sub_test_case("#==") do
|
54
|
-
test("Arrow::Array") do
|
55
|
-
assert do
|
56
|
-
@array == @array
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
test("not Arrow::Array") do
|
61
|
-
assert do
|
62
|
-
not (@array == 29)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
sub_test_case("#equal_array?") do
|
68
|
-
test("no options") do
|
69
|
-
array1 = Arrow::FloatArray.new([1.1, Float::NAN])
|
70
|
-
array2 = Arrow::FloatArray.new([1.1, Float::NAN])
|
71
|
-
assert do
|
72
|
-
not array1.equal_array?(array2)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
test("approx") do
|
77
|
-
array1 = Arrow::FloatArray.new([1.1])
|
78
|
-
array2 = Arrow::FloatArray.new([1.100001])
|
79
|
-
assert do
|
80
|
-
array1.equal_array?(array2, approx: true)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
test("nans-equal") do
|
85
|
-
array1 = Arrow::FloatArray.new([1.1, Float::NAN])
|
86
|
-
array2 = Arrow::FloatArray.new([1.1, Float::NAN])
|
87
|
-
assert do
|
88
|
-
array1.equal_array?(array2, nans_equal: true)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
test("absolute-tolerance") do
|
93
|
-
array1 = Arrow::FloatArray.new([1.1])
|
94
|
-
array2 = Arrow::FloatArray.new([1.101])
|
95
|
-
assert do
|
96
|
-
array1.equal_array?(array2, approx: true, absolute_tolerance: 0.01)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
sub_test_case("#cast") do
|
102
|
-
test("Symbol") do
|
103
|
-
assert_equal(Arrow::Int32Array.new([1, 2, 3]),
|
104
|
-
Arrow::StringArray.new(["1", "2", "3"]).cast(:int32))
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
sub_test_case("#filter") do
|
110
|
-
def setup
|
111
|
-
values = [true, false, false, true]
|
112
|
-
@array = Arrow::BooleanArray.new(values)
|
113
|
-
@options = Arrow::FilterOptions.new
|
114
|
-
@options.null_selection_behavior = :emit_null
|
115
|
-
end
|
116
|
-
|
117
|
-
test("Array: boolean") do
|
118
|
-
filter = [nil, true, true, false]
|
119
|
-
filtered_array = Arrow::BooleanArray.new([nil, false, false])
|
120
|
-
assert_equal(filtered_array,
|
121
|
-
@array.filter(filter, @options))
|
122
|
-
end
|
123
|
-
|
124
|
-
test("Arrow::BooleanArray") do
|
125
|
-
filter = Arrow::BooleanArray.new([nil, true, true, false])
|
126
|
-
filtered_array = Arrow::BooleanArray.new([nil, false, false])
|
127
|
-
assert_equal(filtered_array,
|
128
|
-
@array.filter(filter, @options))
|
129
|
-
end
|
130
|
-
|
131
|
-
test("Arrow::ChunkedArray") do
|
132
|
-
chunks = [
|
133
|
-
Arrow::BooleanArray.new([nil, true]),
|
134
|
-
Arrow::BooleanArray.new([true, false]),
|
135
|
-
]
|
136
|
-
filter = Arrow::ChunkedArray.new(chunks)
|
137
|
-
filtered_array = Arrow::BooleanArray.new([nil, false, false])
|
138
|
-
assert_equal(filtered_array,
|
139
|
-
@array.filter(filter, @options))
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
sub_test_case("#take") do
|
144
|
-
def setup
|
145
|
-
values = [1, 0 ,2]
|
146
|
-
@array = Arrow::Int16Array.new(values)
|
147
|
-
end
|
148
|
-
|
149
|
-
test("Arrow: boolean") do
|
150
|
-
indices = [1, 0, 2]
|
151
|
-
assert_equal(Arrow::Int16Array.new([0, 1, 2]),
|
152
|
-
@array.take(indices))
|
153
|
-
end
|
154
|
-
|
155
|
-
test("Arrow::Array") do
|
156
|
-
indices = Arrow::Int16Array.new([1, 0, 2])
|
157
|
-
assert_equal(Arrow::Int16Array.new([0, 1, 2]),
|
158
|
-
@array.take(indices))
|
159
|
-
end
|
160
|
-
|
161
|
-
test("Arrow::ChunkedArray") do
|
162
|
-
taken_chunks = [
|
163
|
-
Arrow::Int16Array.new([0, 1]),
|
164
|
-
Arrow::Int16Array.new([2])
|
165
|
-
]
|
166
|
-
taken_chunked_array = Arrow::ChunkedArray.new(taken_chunks)
|
167
|
-
indices_chunks = [
|
168
|
-
Arrow::Int16Array.new([1, 0]),
|
169
|
-
Arrow::Int16Array.new([2])
|
170
|
-
]
|
171
|
-
indices = Arrow::ChunkedArray.new(indices_chunks)
|
172
|
-
assert_equal(taken_chunked_array,
|
173
|
-
@array.take(indices))
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
sub_test_case("#is_in") do
|
178
|
-
def setup
|
179
|
-
values = [1, 0, 1, 2]
|
180
|
-
@array = Arrow::Int16Array.new(values)
|
181
|
-
end
|
182
|
-
|
183
|
-
test("Arrow: Array") do
|
184
|
-
right = [2, 0]
|
185
|
-
assert_equal(Arrow::BooleanArray.new([false, true, false, true]),
|
186
|
-
@array.is_in(right))
|
187
|
-
end
|
188
|
-
|
189
|
-
test("Arrow::Array") do
|
190
|
-
right = Arrow::Int16Array.new([2, 0])
|
191
|
-
assert_equal(Arrow::BooleanArray.new([false, true, false, true]),
|
192
|
-
@array.is_in(right))
|
193
|
-
end
|
194
|
-
|
195
|
-
test("Arrow::ChunkedArray") do
|
196
|
-
chunks = [
|
197
|
-
Arrow::Int16Array.new([1, 4]),
|
198
|
-
Arrow::Int16Array.new([0, 3])
|
199
|
-
]
|
200
|
-
right = Arrow::ChunkedArray.new(chunks)
|
201
|
-
assert_equal(Arrow::BooleanArray.new([true, true, true, false]),
|
202
|
-
@array.is_in(right))
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
sub_test_case("#concatenate") do
|
207
|
-
test("Arrow::Array: same") do
|
208
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
209
|
-
Arrow::Int32Array.new([1, 2, nil]).
|
210
|
-
concatenate(Arrow::Int32Array.new([4, 5]),
|
211
|
-
Arrow::Int32Array.new([6])))
|
212
|
-
end
|
213
|
-
|
214
|
-
test("Arrow::Array: castable") do
|
215
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
216
|
-
Arrow::Int32Array.new([1, 2, nil]).
|
217
|
-
concatenate(Arrow::Int8Array.new([4, 5]),
|
218
|
-
Arrow::UInt32Array.new([6])))
|
219
|
-
end
|
220
|
-
|
221
|
-
test("Arrow::Array: non-castable") do
|
222
|
-
assert_raise(Arrow::Error::Invalid) do
|
223
|
-
Arrow::Int32Array.new([1, 2, nil]).
|
224
|
-
concatenate(Arrow::StringArray.new(["X"]))
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
test("Array") do
|
229
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,nil, 6]),
|
230
|
-
Arrow::Int32Array.new([1, 2, nil]).
|
231
|
-
concatenate([4, nil],
|
232
|
-
[6]))
|
233
|
-
end
|
234
|
-
|
235
|
-
test("invalid") do
|
236
|
-
message = "[array][resolve] can't build int32 array: 4"
|
237
|
-
assert_raise(ArgumentError.new(message)) do
|
238
|
-
Arrow::Int32Array.new([1, 2, nil]).
|
239
|
-
concatenate(4)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
sub_test_case("#+") do
|
245
|
-
test("Arrow::Array: same") do
|
246
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
247
|
-
Arrow::Int32Array.new([1, 2, nil]) +
|
248
|
-
Arrow::Int32Array.new([4, 5, 6]))
|
249
|
-
end
|
250
|
-
|
251
|
-
test("Arrow::Array: castable") do
|
252
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
253
|
-
Arrow::Int32Array.new([1, 2, nil]) +
|
254
|
-
Arrow::Int8Array.new([4, 5, 6]))
|
255
|
-
end
|
256
|
-
|
257
|
-
test("Arrow::Array: non-castable") do
|
258
|
-
assert_raise(Arrow::Error::Invalid) do
|
259
|
-
Arrow::Int32Array.new([1, 2, nil]) +
|
260
|
-
Arrow::StringArray.new(["X"])
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
test("Array") do
|
265
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,nil, 6]),
|
266
|
-
Arrow::Int32Array.new([1, 2, nil]) +
|
267
|
-
[4, nil, 6])
|
268
|
-
end
|
269
|
-
|
270
|
-
test("invalid") do
|
271
|
-
message = "[array][resolve] can't build int32 array: 4"
|
272
|
-
assert_raise(ArgumentError.new(message)) do
|
273
|
-
Arrow::Int32Array.new([1, 2, nil]) + 4
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
sub_test_case("#resolve") do
|
279
|
-
test("Arrow::Array: same") do
|
280
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil]),
|
281
|
-
Arrow::Int32Array.new([]).
|
282
|
-
resolve(Arrow::Int32Array.new([1, 2, nil])))
|
283
|
-
end
|
284
|
-
|
285
|
-
test("Arrow::Array: castable") do
|
286
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil]),
|
287
|
-
Arrow::Int32Array.new([]).
|
288
|
-
resolve(Arrow::Int8Array.new([1, 2, nil])))
|
289
|
-
end
|
290
|
-
|
291
|
-
test("Arrow::Array: non-castable") do
|
292
|
-
assert_raise(Arrow::Error::Invalid) do
|
293
|
-
Arrow::Int32Array.new([]) +
|
294
|
-
Arrow::StringArray.new(["X"])
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
test("Array: non-parametric") do
|
299
|
-
assert_equal(Arrow::Int32Array.new([1, 2, nil]),
|
300
|
-
Arrow::Int32Array.new([]).
|
301
|
-
resolve([1, 2, nil]))
|
302
|
-
end
|
303
|
-
|
304
|
-
test("Array: parametric") do
|
305
|
-
list_data_type = Arrow::ListDataType.new(name: "visible", type: :boolean)
|
306
|
-
list_array = Arrow::ListArray.new(list_data_type, [])
|
307
|
-
assert_equal(Arrow::ListArray.new(list_data_type,
|
308
|
-
[
|
309
|
-
[true, false],
|
310
|
-
nil,
|
311
|
-
]),
|
312
|
-
list_array.resolve([
|
313
|
-
[true, false],
|
314
|
-
nil,
|
315
|
-
]))
|
316
|
-
end
|
317
|
-
|
318
|
-
test("invalid") do
|
319
|
-
message = "[array][resolve] can't build int32 array: 4"
|
320
|
-
assert_raise(ArgumentError.new(message)) do
|
321
|
-
Arrow::Int32Array.new([]).resolve(4)
|
322
|
-
end
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
sub_test_case("#index") do
|
327
|
-
test("Integer") do
|
328
|
-
assert_equal(2,
|
329
|
-
Arrow::Int32Array.new([1, 2, 3, 4, 5]).index(3))
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
data/test/test-bigdecimal.rb
DELETED
@@ -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 BigDecimalTest < Test::Unit::TestCase
|
19
|
-
sub_test_case("#to_arrow") do
|
20
|
-
def test_128_positive
|
21
|
-
assert_equal(Arrow::Decimal128.new("0.1e38"),
|
22
|
-
BigDecimal("0.1e38").to_arrow)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_128_negative
|
26
|
-
assert_equal(Arrow::Decimal128.new("-0.1e38"),
|
27
|
-
BigDecimal("-0.1e38").to_arrow)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_256_positive
|
31
|
-
assert_equal(Arrow::Decimal256.new("0.1e39"),
|
32
|
-
BigDecimal("0.1e39").to_arrow)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_256_negative
|
36
|
-
assert_equal(Arrow::Decimal256.new("-0.1e39"),
|
37
|
-
BigDecimal("-0.1e39").to_arrow)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,103 +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 BinaryDictionaryArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@builder = Arrow::BinaryDictionaryArrayBuilder.new
|
21
|
-
end
|
22
|
-
|
23
|
-
sub_test_case("#append_values") do
|
24
|
-
test("[nil]") do
|
25
|
-
@builder.append_values([nil])
|
26
|
-
array = @builder.finish
|
27
|
-
assert_equal([
|
28
|
-
[],
|
29
|
-
[nil],
|
30
|
-
],
|
31
|
-
[
|
32
|
-
array.dictionary.to_a,
|
33
|
-
array.indices.to_a,
|
34
|
-
])
|
35
|
-
end
|
36
|
-
|
37
|
-
test("[String]") do
|
38
|
-
@builder.append_values(["he\xffllo"])
|
39
|
-
array = @builder.finish
|
40
|
-
assert_equal([
|
41
|
-
["he\xffllo".b],
|
42
|
-
[0],
|
43
|
-
],
|
44
|
-
[
|
45
|
-
array.dictionary.to_a,
|
46
|
-
array.indices.to_a,
|
47
|
-
])
|
48
|
-
end
|
49
|
-
|
50
|
-
test("[Symbol]") do
|
51
|
-
@builder.append_values([:hello])
|
52
|
-
array = @builder.finish
|
53
|
-
assert_equal([
|
54
|
-
["hello"],
|
55
|
-
[0],
|
56
|
-
],
|
57
|
-
[
|
58
|
-
array.dictionary.to_a,
|
59
|
-
array.indices.to_a,
|
60
|
-
])
|
61
|
-
end
|
62
|
-
|
63
|
-
test("[nil, String, Symbol]") do
|
64
|
-
@builder.append_values([
|
65
|
-
nil,
|
66
|
-
"He\xffllo",
|
67
|
-
:world,
|
68
|
-
"world",
|
69
|
-
])
|
70
|
-
array = @builder.finish
|
71
|
-
assert_equal([
|
72
|
-
["He\xffllo".b, "world"],
|
73
|
-
[nil, 0, 1, 1],
|
74
|
-
],
|
75
|
-
[
|
76
|
-
array.dictionary.to_a,
|
77
|
-
array.indices.to_a,
|
78
|
-
])
|
79
|
-
end
|
80
|
-
|
81
|
-
test("is_valids") do
|
82
|
-
@builder.append_values([
|
83
|
-
"He\xffllo",
|
84
|
-
:world,
|
85
|
-
:goodbye,
|
86
|
-
],
|
87
|
-
[
|
88
|
-
true,
|
89
|
-
false,
|
90
|
-
true,
|
91
|
-
])
|
92
|
-
array = @builder.finish
|
93
|
-
assert_equal([
|
94
|
-
["He\xffllo".b, "goodbye"],
|
95
|
-
[0, nil, 1],
|
96
|
-
],
|
97
|
-
[
|
98
|
-
array.dictionary.to_a,
|
99
|
-
array.indices.to_a,
|
100
|
-
])
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|