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.
- 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-data-type.rb
DELETED
@@ -1,84 +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 DataTypeTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".resolve") do
|
20
|
-
test("DataType") do
|
21
|
-
assert_equal(Arrow::BooleanDataType.new,
|
22
|
-
Arrow::DataType.resolve(Arrow::BooleanDataType.new))
|
23
|
-
end
|
24
|
-
|
25
|
-
test("String") do
|
26
|
-
assert_equal(Arrow::BooleanDataType.new,
|
27
|
-
Arrow::DataType.resolve("boolean"))
|
28
|
-
end
|
29
|
-
|
30
|
-
test("Symbol") do
|
31
|
-
assert_equal(Arrow::BooleanDataType.new,
|
32
|
-
Arrow::DataType.resolve(:boolean))
|
33
|
-
end
|
34
|
-
|
35
|
-
test("Array") do
|
36
|
-
field = Arrow::Field.new(:visible, :boolean)
|
37
|
-
assert_equal(Arrow::ListDataType.new(field),
|
38
|
-
Arrow::DataType.resolve([:list, field]))
|
39
|
-
end
|
40
|
-
|
41
|
-
test("Hash") do
|
42
|
-
field = Arrow::Field.new(:visible, :boolean)
|
43
|
-
assert_equal(Arrow::ListDataType.new(field),
|
44
|
-
Arrow::DataType.resolve(type: :list, field: field))
|
45
|
-
end
|
46
|
-
|
47
|
-
test("_") do
|
48
|
-
assert_equal(Arrow::FixedSizeBinaryDataType.new(10),
|
49
|
-
Arrow::DataType.resolve([:fixed_size_binary, 10]))
|
50
|
-
end
|
51
|
-
|
52
|
-
test("abstract") do
|
53
|
-
message =
|
54
|
-
"abstract type: <:floating_point>: " +
|
55
|
-
"use one of not abstract type: [" +
|
56
|
-
"Arrow::DoubleDataType, " +
|
57
|
-
"Arrow::FloatDataType, " +
|
58
|
-
"Arrow::HalfFloatDataType]"
|
59
|
-
assert_raise(ArgumentError.new(message)) do
|
60
|
-
Arrow::DataType.resolve(:floating_point)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
sub_test_case("instance methods") do
|
66
|
-
def setup
|
67
|
-
@data_type = Arrow::StringDataType.new
|
68
|
-
end
|
69
|
-
|
70
|
-
sub_test_case("#==") do
|
71
|
-
test("Arrow::DataType") do
|
72
|
-
assert do
|
73
|
-
@data_type == @data_type
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
test("not Arrow::DataType") do
|
78
|
-
assert do
|
79
|
-
not (@data_type == 29)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/test/test-date32-array.rb
DELETED
@@ -1,24 +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 Date32ArrayTest < Test::Unit::TestCase
|
19
|
-
test("#[]") do
|
20
|
-
n_days_since_epoch = 17406 # 2017-08-28
|
21
|
-
array = Arrow::Date32Array.new([n_days_since_epoch])
|
22
|
-
assert_equal(Date.new(2017, 8, 28), array[0])
|
23
|
-
end
|
24
|
-
end
|
data/test/test-date64-array.rb
DELETED
@@ -1,25 +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 Date64ArrayTest < Test::Unit::TestCase
|
19
|
-
test("#[]") do
|
20
|
-
n_msecs_since_epoch = 1503878400000 # 2017-08-28T00:00:00Z
|
21
|
-
array = Arrow::Date64Array.new([n_msecs_since_epoch])
|
22
|
-
assert_equal(DateTime.new(2017, 8, 28, 0, 0, 0),
|
23
|
-
array[0])
|
24
|
-
end
|
25
|
-
end
|
@@ -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 Decimal128ArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@data_type = Arrow::Decimal128DataType.new(3, 1)
|
21
|
-
@builder = Arrow::Decimal128ArrayBuilder.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("Arrow::Decimal128") do
|
32
|
-
@builder.append_value(Arrow::Decimal128.new("10.1"))
|
33
|
-
array = @builder.finish
|
34
|
-
assert_equal(BigDecimal("10.1"),
|
35
|
-
array[0])
|
36
|
-
end
|
37
|
-
|
38
|
-
test("String") do
|
39
|
-
@builder.append_value("10.1")
|
40
|
-
array = @builder.finish
|
41
|
-
assert_equal(BigDecimal("10.1"),
|
42
|
-
array[0])
|
43
|
-
end
|
44
|
-
|
45
|
-
test("Float") do
|
46
|
-
@builder.append_value(10.1)
|
47
|
-
array = @builder.finish
|
48
|
-
assert_equal(BigDecimal("10.1"),
|
49
|
-
array[0])
|
50
|
-
end
|
51
|
-
|
52
|
-
test("BigDecimal") do
|
53
|
-
@builder.append_value(BigDecimal("10.1"))
|
54
|
-
array = @builder.finish
|
55
|
-
assert_equal(BigDecimal("10.1"),
|
56
|
-
array[0])
|
57
|
-
end
|
58
|
-
|
59
|
-
test("BigDecimal::NAN") do
|
60
|
-
message = "can't use NaN as an Arrow::Decimal128Array value"
|
61
|
-
assert_raise(FloatDomainError.new(message)) do
|
62
|
-
@builder.append_value(BigDecimal::NAN)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
test("BigDecimal::INFINITY") do
|
67
|
-
message = "can't use Infinity as an Arrow::Decimal128Array value"
|
68
|
-
assert_raise(FloatDomainError.new(message)) do
|
69
|
-
@builder.append_value(BigDecimal::INFINITY)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
sub_test_case("#append_values") do
|
75
|
-
test("mixed") do
|
76
|
-
@builder.append_values([
|
77
|
-
Arrow::Decimal128.new("10.1"),
|
78
|
-
nil,
|
79
|
-
"10.1",
|
80
|
-
10.1,
|
81
|
-
BigDecimal("10.1"),
|
82
|
-
])
|
83
|
-
array = @builder.finish
|
84
|
-
assert_equal([
|
85
|
-
BigDecimal("10.1"),
|
86
|
-
nil,
|
87
|
-
BigDecimal("10.1"),
|
88
|
-
BigDecimal("10.1"),
|
89
|
-
BigDecimal("10.1"),
|
90
|
-
],
|
91
|
-
array.to_a)
|
92
|
-
end
|
93
|
-
|
94
|
-
test("is_valids") do
|
95
|
-
@builder.append_values([
|
96
|
-
Arrow::Decimal128.new("10.1"),
|
97
|
-
Arrow::Decimal128.new("10.1"),
|
98
|
-
Arrow::Decimal128.new("10.1"),
|
99
|
-
],
|
100
|
-
[
|
101
|
-
true,
|
102
|
-
false,
|
103
|
-
true,
|
104
|
-
])
|
105
|
-
array = @builder.finish
|
106
|
-
assert_equal([
|
107
|
-
BigDecimal("10.1"),
|
108
|
-
nil,
|
109
|
-
BigDecimal("10.1"),
|
110
|
-
],
|
111
|
-
array.to_a)
|
112
|
-
end
|
113
|
-
|
114
|
-
test("packed") do
|
115
|
-
@builder.append_values(Arrow::Decimal128.new("10.1").to_bytes.to_s * 3,
|
116
|
-
[true, false, true])
|
117
|
-
array = @builder.finish
|
118
|
-
assert_equal([
|
119
|
-
BigDecimal("10.1"),
|
120
|
-
nil,
|
121
|
-
BigDecimal("10.1"),
|
122
|
-
],
|
123
|
-
array.to_a)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,47 +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 Decimal128ArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("build") do
|
21
|
-
values = [
|
22
|
-
10.1,
|
23
|
-
nil,
|
24
|
-
"10.1",
|
25
|
-
BigDecimal("10.1"),
|
26
|
-
BigDecimal("1.11"),
|
27
|
-
BigDecimal("1"),
|
28
|
-
]
|
29
|
-
array = Arrow::Decimal128Array.new({precision: 3, scale: 1}, values)
|
30
|
-
assert_equal([
|
31
|
-
BigDecimal("10.1"),
|
32
|
-
nil,
|
33
|
-
BigDecimal("10.1"),
|
34
|
-
BigDecimal("10.1"),
|
35
|
-
BigDecimal("1.1"),
|
36
|
-
BigDecimal("1"),
|
37
|
-
],
|
38
|
-
array.to_a)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_zero
|
43
|
-
array = Arrow::Decimal128Array.new({precision: 38, scale: 9},
|
44
|
-
[BigDecimal("0")])
|
45
|
-
assert_equal(BigDecimal("0"), array[0])
|
46
|
-
end
|
47
|
-
end
|
@@ -1,31 +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 Decimal128DataTypeTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("ordered arguments") do
|
21
|
-
assert_equal("decimal128(8, 2)",
|
22
|
-
Arrow::Decimal128DataType.new(8, 2).to_s)
|
23
|
-
end
|
24
|
-
|
25
|
-
test("description") do
|
26
|
-
assert_equal("decimal128(8, 2)",
|
27
|
-
Arrow::Decimal128DataType.new(precision: 8,
|
28
|
-
scale: 2).to_s)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/test/test-decimal128.rb
DELETED
@@ -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 Decimal128Test < Test::Unit::TestCase
|
19
|
-
sub_test_case("instance methods") do
|
20
|
-
def setup
|
21
|
-
@decimal128 = Arrow::Decimal128.new("10.1")
|
22
|
-
end
|
23
|
-
|
24
|
-
sub_test_case("#==") do
|
25
|
-
test("Arrow::Decimal128") do
|
26
|
-
assert do
|
27
|
-
@decimal128 == @decimal128
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
test("String") do
|
32
|
-
assert do
|
33
|
-
@decimal128 == "10.1"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
test("Float") do
|
38
|
-
assert do
|
39
|
-
@decimal128 == 10.1
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
test("not Arrow::Decimal128") do
|
44
|
-
assert do
|
45
|
-
not (@decimal128 == :"10.1")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
sub_test_case("#!=") do
|
51
|
-
test("Arrow::Decimal128") do
|
52
|
-
assert do
|
53
|
-
not (@decimal128 != @decimal128)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
test("String") do
|
58
|
-
assert do
|
59
|
-
not (@decimal128 != "10.1")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
test("Float") do
|
64
|
-
assert do
|
65
|
-
not (@decimal128 != 10.1)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
test("not Arrow::Decimal128") do
|
70
|
-
assert do
|
71
|
-
@decimal128 != :"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
|
-
@decimal128.to_s)
|
80
|
-
end
|
81
|
-
|
82
|
-
test("scale") do
|
83
|
-
assert_equal("10.1",
|
84
|
-
@decimal128.to_s(1))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
test("#abs") do
|
89
|
-
decimal128 = Arrow::Decimal128.new("-10.1")
|
90
|
-
assert_equal([
|
91
|
-
Arrow::Decimal128.new("-10.1"),
|
92
|
-
Arrow::Decimal128.new("10.1"),
|
93
|
-
],
|
94
|
-
[
|
95
|
-
decimal128,
|
96
|
-
decimal128.abs,
|
97
|
-
])
|
98
|
-
end
|
99
|
-
|
100
|
-
test("#abs!") do
|
101
|
-
decimal128 = Arrow::Decimal128.new("-10.1")
|
102
|
-
decimal128.abs!
|
103
|
-
assert_equal(Arrow::Decimal128.new("10.1"),
|
104
|
-
decimal128)
|
105
|
-
end
|
106
|
-
|
107
|
-
test("#negate") do
|
108
|
-
decimal128 = Arrow::Decimal128.new("-10.1")
|
109
|
-
assert_equal([
|
110
|
-
Arrow::Decimal128.new("-10.1"),
|
111
|
-
Arrow::Decimal128.new("10.1"),
|
112
|
-
],
|
113
|
-
[
|
114
|
-
decimal128,
|
115
|
-
decimal128.negate,
|
116
|
-
])
|
117
|
-
end
|
118
|
-
|
119
|
-
test("#negate!") do
|
120
|
-
decimal128 = Arrow::Decimal128.new("-10.1")
|
121
|
-
decimal128.negate!
|
122
|
-
assert_equal(Arrow::Decimal128.new("10.1"),
|
123
|
-
decimal128)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -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 Decimal256ArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@data_type = Arrow::Decimal256DataType.new(3, 1)
|
21
|
-
@builder = Arrow::Decimal256ArrayBuilder.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("Arrow::Decimal256") do
|
32
|
-
@builder.append_value(Arrow::Decimal256.new("10.1"))
|
33
|
-
array = @builder.finish
|
34
|
-
assert_equal(BigDecimal("10.1"),
|
35
|
-
array[0])
|
36
|
-
end
|
37
|
-
|
38
|
-
test("String") do
|
39
|
-
@builder.append_value("10.1")
|
40
|
-
array = @builder.finish
|
41
|
-
assert_equal(BigDecimal("10.1"),
|
42
|
-
array[0])
|
43
|
-
end
|
44
|
-
|
45
|
-
test("Float") do
|
46
|
-
@builder.append_value(10.1)
|
47
|
-
array = @builder.finish
|
48
|
-
assert_equal(BigDecimal("10.1"),
|
49
|
-
array[0])
|
50
|
-
end
|
51
|
-
|
52
|
-
test("BigDecimal") do
|
53
|
-
@builder.append_value(BigDecimal("10.1"))
|
54
|
-
array = @builder.finish
|
55
|
-
assert_equal(BigDecimal("10.1"),
|
56
|
-
array[0])
|
57
|
-
end
|
58
|
-
|
59
|
-
test("BigDecimal::NAN") do
|
60
|
-
message = "can't use NaN as an Arrow::Decimal256Array value"
|
61
|
-
assert_raise(FloatDomainError.new(message)) do
|
62
|
-
@builder.append_value(BigDecimal::NAN)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
test("BigDecimal::INFINITY") do
|
67
|
-
message = "can't use Infinity as an Arrow::Decimal256Array value"
|
68
|
-
assert_raise(FloatDomainError.new(message)) do
|
69
|
-
@builder.append_value(BigDecimal::INFINITY)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
sub_test_case("#append_values") do
|
75
|
-
test("mixed") do
|
76
|
-
@builder.append_values([
|
77
|
-
Arrow::Decimal256.new("10.1"),
|
78
|
-
nil,
|
79
|
-
"10.1",
|
80
|
-
10.1,
|
81
|
-
BigDecimal("10.1"),
|
82
|
-
])
|
83
|
-
array = @builder.finish
|
84
|
-
assert_equal([
|
85
|
-
BigDecimal("10.1"),
|
86
|
-
nil,
|
87
|
-
BigDecimal("10.1"),
|
88
|
-
BigDecimal("10.1"),
|
89
|
-
BigDecimal("10.1"),
|
90
|
-
],
|
91
|
-
array.to_a)
|
92
|
-
end
|
93
|
-
|
94
|
-
test("is_valids") do
|
95
|
-
@builder.append_values([
|
96
|
-
Arrow::Decimal256.new("10.1"),
|
97
|
-
Arrow::Decimal256.new("10.1"),
|
98
|
-
Arrow::Decimal256.new("10.1"),
|
99
|
-
],
|
100
|
-
[
|
101
|
-
true,
|
102
|
-
false,
|
103
|
-
true,
|
104
|
-
])
|
105
|
-
array = @builder.finish
|
106
|
-
assert_equal([
|
107
|
-
BigDecimal("10.1"),
|
108
|
-
nil,
|
109
|
-
BigDecimal("10.1"),
|
110
|
-
],
|
111
|
-
array.to_a)
|
112
|
-
end
|
113
|
-
|
114
|
-
test("packed") do
|
115
|
-
@builder.append_values(Arrow::Decimal256.new("10.1").to_bytes.to_s * 3,
|
116
|
-
[true, false, true])
|
117
|
-
array = @builder.finish
|
118
|
-
assert_equal([
|
119
|
-
BigDecimal("10.1"),
|
120
|
-
nil,
|
121
|
-
BigDecimal("10.1"),
|
122
|
-
],
|
123
|
-
array.to_a)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,47 +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 Decimal256ArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("build") do
|
21
|
-
values = [
|
22
|
-
10.1,
|
23
|
-
nil,
|
24
|
-
"10.1",
|
25
|
-
BigDecimal("10.1"),
|
26
|
-
BigDecimal("1.11"),
|
27
|
-
BigDecimal("1"),
|
28
|
-
]
|
29
|
-
array = Arrow::Decimal256Array.new({precision: 3, scale: 1}, values)
|
30
|
-
assert_equal([
|
31
|
-
BigDecimal("10.1"),
|
32
|
-
nil,
|
33
|
-
BigDecimal("10.1"),
|
34
|
-
BigDecimal("10.1"),
|
35
|
-
BigDecimal("1.1"),
|
36
|
-
BigDecimal("1"),
|
37
|
-
],
|
38
|
-
array.to_a)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_zero
|
43
|
-
array = Arrow::Decimal256Array.new({precision: 38, scale: 9},
|
44
|
-
[BigDecimal("0")])
|
45
|
-
assert_equal(BigDecimal("0"), array[0])
|
46
|
-
end
|
47
|
-
end
|
@@ -1,31 +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 Decimal256DataTypeTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("ordered arguments") do
|
21
|
-
assert_equal("decimal256(8, 2)",
|
22
|
-
Arrow::Decimal256DataType.new(8, 2).to_s)
|
23
|
-
end
|
24
|
-
|
25
|
-
test("description") do
|
26
|
-
assert_equal("decimal256(8, 2)",
|
27
|
-
Arrow::Decimal256DataType.new(precision: 8,
|
28
|
-
scale: 2).to_s)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|