red-arrow 0.17.1 → 4.0.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.
- checksums.yaml +4 -4
- data/ext/arrow/converters.hpp +75 -32
- data/ext/arrow/extconf.rb +14 -3
- data/ext/arrow/raw-records.cpp +3 -1
- data/ext/arrow/values.cpp +3 -1
- data/lib/arrow/array-builder.rb +11 -6
- data/lib/arrow/array.rb +118 -0
- data/lib/arrow/bigdecimal-extension.rb +5 -1
- data/lib/arrow/buffer.rb +28 -0
- data/lib/arrow/data-type.rb +14 -5
- data/lib/arrow/decimal128-array-builder.rb +21 -25
- data/lib/arrow/decimal128-data-type.rb +2 -0
- data/lib/arrow/decimal128.rb +18 -0
- data/lib/arrow/decimal256-array-builder.rb +61 -0
- data/lib/arrow/decimal256-array.rb +25 -0
- data/lib/arrow/decimal256-data-type.rb +73 -0
- data/lib/arrow/decimal256.rb +60 -0
- data/lib/arrow/dense-union-data-type.rb +2 -2
- data/lib/arrow/dictionary-array.rb +24 -0
- data/lib/arrow/dictionary-data-type.rb +2 -2
- data/lib/arrow/fixed-size-binary-array-builder.rb +38 -0
- data/lib/arrow/fixed-size-binary-array.rb +26 -0
- data/lib/arrow/loader.rb +18 -0
- data/lib/arrow/raw-table-converter.rb +47 -0
- data/lib/arrow/record-batch-iterator.rb +22 -0
- data/lib/arrow/record-batch.rb +9 -1
- data/lib/arrow/sort-key.rb +193 -0
- data/lib/arrow/sort-options.rb +109 -0
- data/lib/arrow/sparse-union-data-type.rb +2 -2
- data/lib/arrow/struct-array-builder.rb +13 -7
- data/lib/arrow/table-saver.rb +6 -6
- data/lib/arrow/table.rb +5 -24
- data/lib/arrow/time32-data-type.rb +2 -2
- data/lib/arrow/time64-data-type.rb +2 -2
- data/lib/arrow/timestamp-data-type.rb +2 -2
- data/lib/arrow/version.rb +1 -1
- data/red-arrow.gemspec +1 -0
- data/test/raw-records/test-basic-arrays.rb +17 -0
- data/test/raw-records/test-dense-union-array.rb +15 -34
- data/test/raw-records/test-list-array.rb +20 -0
- data/test/raw-records/test-sparse-union-array.rb +15 -33
- data/test/raw-records/test-struct-array.rb +15 -0
- data/test/test-array.rb +122 -2
- data/test/test-bigdecimal.rb +20 -3
- data/test/test-buffer.rb +11 -0
- data/test/test-decimal128-array-builder.rb +18 -1
- data/test/test-decimal128-data-type.rb +2 -2
- data/test/test-decimal128.rb +38 -0
- data/test/test-decimal256-array-builder.rb +112 -0
- data/test/test-decimal256-array.rb +38 -0
- data/test/test-decimal256-data-type.rb +31 -0
- data/test/test-decimal256.rb +102 -0
- data/test/test-dense-union-data-type.rb +2 -2
- data/test/test-dictionary-array.rb +41 -0
- data/test/test-feather.rb +1 -1
- data/test/test-fixed-size-binary-array-builder.rb +92 -0
- data/test/test-fixed-size-binary-array.rb +36 -0
- data/test/test-orc.rb +19 -23
- data/test/test-record-batch-iterator.rb +37 -0
- data/test/test-record-batch.rb +14 -0
- data/test/test-sort-indices.rb +40 -0
- data/test/test-sort-key.rb +81 -0
- data/test/test-sort-options.rb +58 -0
- data/test/test-sparse-union-data-type.rb +2 -2
- data/test/test-struct-array-builder.rb +16 -12
- data/test/test-struct-array.rb +2 -2
- data/test/values/test-basic-arrays.rb +11 -0
- data/test/values/test-dense-union-array.rb +15 -34
- data/test/values/test-list-array.rb +18 -0
- data/test/values/test-sparse-union-array.rb +15 -33
- data/test/values/test-struct-array.rb +15 -0
- metadata +107 -59
data/test/test-feather.rb
CHANGED
@@ -0,0 +1,92 @@
|
|
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
|
@@ -0,0 +1,36 @@
|
|
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
|
data/test/test-orc.rb
CHANGED
@@ -118,39 +118,35 @@ class ORCTest < Test::Unit::TestCase
|
|
118
118
|
]
|
119
119
|
],
|
120
120
|
[
|
121
|
-
"map:
|
122
|
-
"struct<key: string, value: " +
|
123
|
-
"struct<int1: int32, string1: string>>>",
|
121
|
+
"map: map<string, struct<int1: int32, string1: string>>",
|
124
122
|
[
|
125
123
|
<<-MAP.chomp
|
126
124
|
[
|
125
|
+
keys:
|
126
|
+
[]
|
127
|
+
values:
|
127
128
|
-- is_valid: all not null
|
128
|
-
-- child 0 type:
|
129
|
+
-- child 0 type: int32
|
129
130
|
[]
|
130
|
-
-- child 1 type:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
-- child 1 type: string
|
132
|
+
[],
|
133
|
+
keys:
|
134
|
+
[
|
135
|
+
"chani",
|
136
|
+
"mauddib"
|
137
|
+
]
|
138
|
+
values:
|
136
139
|
-- is_valid: all not null
|
137
|
-
-- child 0 type:
|
140
|
+
-- child 0 type: int32
|
141
|
+
[
|
142
|
+
5,
|
143
|
+
1
|
144
|
+
]
|
145
|
+
-- child 1 type: string
|
138
146
|
[
|
139
147
|
"chani",
|
140
148
|
"mauddib"
|
141
149
|
]
|
142
|
-
-- child 1 type: struct<int1: int32, string1: string>
|
143
|
-
-- is_valid: all not null
|
144
|
-
-- child 0 type: int32
|
145
|
-
[
|
146
|
-
5,
|
147
|
-
1
|
148
|
-
]
|
149
|
-
-- child 1 type: string
|
150
|
-
[
|
151
|
-
"chani",
|
152
|
-
"mauddib"
|
153
|
-
]
|
154
150
|
]
|
155
151
|
MAP
|
156
152
|
],
|
@@ -0,0 +1,37 @@
|
|
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 RecordBatchIteratorTest < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@schema = Arrow::Schema.new(visible: :boolean,
|
21
|
+
count: :uint32)
|
22
|
+
@record_batches = [
|
23
|
+
Arrow::RecordBatch.new(@schema,
|
24
|
+
visible: [true],
|
25
|
+
count: [1]),
|
26
|
+
Arrow::RecordBatch.new(@schema,
|
27
|
+
visible: [false, nil],
|
28
|
+
count: [nil, 3]),
|
29
|
+
]
|
30
|
+
@iterator = Arrow::RecordBatchIterator.new(@record_batches)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_to_a
|
34
|
+
assert_equal(@record_batches,
|
35
|
+
@iterator.to_a)
|
36
|
+
end
|
37
|
+
end
|
data/test/test-record-batch.rb
CHANGED
@@ -22,6 +22,20 @@ class RecordBatchTest < Test::Unit::TestCase
|
|
22
22
|
count: :uint32)
|
23
23
|
end
|
24
24
|
|
25
|
+
test("[raw_table]") do
|
26
|
+
raw_table = {
|
27
|
+
visible: [true, nil, false],
|
28
|
+
count: [1, nil, 3],
|
29
|
+
}
|
30
|
+
record_batch = Arrow::RecordBatch.new(raw_table)
|
31
|
+
assert_equal([
|
32
|
+
{"visible" => true, "count" => 1},
|
33
|
+
{"visible" => nil, "count" => nil},
|
34
|
+
{"visible" => false, "count" => 3},
|
35
|
+
],
|
36
|
+
record_batch.each_record.collect(&:to_h))
|
37
|
+
end
|
38
|
+
|
25
39
|
test("[Schema, records]") do
|
26
40
|
records = [
|
27
41
|
{visible: true, count: 1},
|
@@ -0,0 +1,40 @@
|
|
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 SortIndicesTest < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@table = Arrow::Table.new(number1: [16, -1, 2, 32, -4, -4, -8],
|
21
|
+
number2: [32, 2, -16, 8, 1, 4, 1])
|
22
|
+
end
|
23
|
+
|
24
|
+
sub_test_case("Table") do
|
25
|
+
test("Symbol") do
|
26
|
+
assert_equal(Arrow::UInt64Array.new([6, 4, 5, 1, 2, 0, 3]),
|
27
|
+
@table.sort_indices(:number1))
|
28
|
+
end
|
29
|
+
|
30
|
+
test("-String") do
|
31
|
+
assert_equal(Arrow::UInt64Array.new([3, 0, 2, 1, 4, 5, 6]),
|
32
|
+
@table.sort_indices("-number1"))
|
33
|
+
end
|
34
|
+
|
35
|
+
test("Symbol, -String") do
|
36
|
+
assert_equal(Arrow::UInt64Array.new([6, 5, 4, 1, 2, 0, 3]),
|
37
|
+
@table.sort_indices([:number1, "-number2"]))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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 SortKeyTest < Test::Unit::TestCase
|
19
|
+
sub_test_case(".resolve") do
|
20
|
+
test("SortKey") do
|
21
|
+
assert_equal(Arrow::SortKey.new("-count"),
|
22
|
+
Arrow::SortKey.resolve(Arrow::SortKey.new("-count")))
|
23
|
+
end
|
24
|
+
|
25
|
+
test("-String") do
|
26
|
+
assert_equal(Arrow::SortKey.new("-count"),
|
27
|
+
Arrow::SortKey.resolve("-count"))
|
28
|
+
end
|
29
|
+
|
30
|
+
test("Symbol, Symbol") do
|
31
|
+
assert_equal(Arrow::SortKey.new("-count"),
|
32
|
+
Arrow::SortKey.resolve(:count, :desc))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
sub_test_case("#initialize") do
|
37
|
+
test("String") do
|
38
|
+
assert_equal("+count",
|
39
|
+
Arrow::SortKey.new("count").to_s)
|
40
|
+
end
|
41
|
+
|
42
|
+
test("+String") do
|
43
|
+
assert_equal("+count",
|
44
|
+
Arrow::SortKey.new("+count").to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
test("-String") do
|
48
|
+
assert_equal("-count",
|
49
|
+
Arrow::SortKey.new("-count").to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
test("Symbol") do
|
53
|
+
assert_equal("+-count",
|
54
|
+
Arrow::SortKey.new(:"-count").to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
test("String, Symbol") do
|
58
|
+
assert_equal("--count",
|
59
|
+
Arrow::SortKey.new("-count", :desc).to_s)
|
60
|
+
end
|
61
|
+
|
62
|
+
test("String, String") do
|
63
|
+
assert_equal("--count",
|
64
|
+
Arrow::SortKey.new("-count", "desc").to_s)
|
65
|
+
end
|
66
|
+
|
67
|
+
test("String, SortOrder") do
|
68
|
+
assert_equal("--count",
|
69
|
+
Arrow::SortKey.new("-count",
|
70
|
+
Arrow::SortOrder::DESCENDING).to_s)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
sub_test_case("#to_s") do
|
75
|
+
test("recreatable") do
|
76
|
+
key = Arrow::SortKey.new("-count", :desc)
|
77
|
+
assert_equal(key,
|
78
|
+
Arrow::SortKey.new(key.to_s))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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 SortOptionsTest < Test::Unit::TestCase
|
19
|
+
sub_test_case("#initialize") do
|
20
|
+
test("none") do
|
21
|
+
options = Arrow::SortOptions.new
|
22
|
+
assert_equal([],
|
23
|
+
options.sort_keys.collect(&:to_s))
|
24
|
+
end
|
25
|
+
|
26
|
+
test("-String, Symbol") do
|
27
|
+
options = Arrow::SortOptions.new("-count", :age)
|
28
|
+
assert_equal(["-count", "+age"],
|
29
|
+
options.sort_keys.collect(&:to_s))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
sub_test_case("instance methods") do
|
34
|
+
setup do
|
35
|
+
@options = Arrow::SortOptions.new
|
36
|
+
end
|
37
|
+
|
38
|
+
sub_test_case("#add_sort_key") do
|
39
|
+
test("-String") do
|
40
|
+
@options.add_sort_key("-count")
|
41
|
+
assert_equal(["-count"],
|
42
|
+
@options.sort_keys.collect(&:to_s))
|
43
|
+
end
|
44
|
+
|
45
|
+
test("-String, Symbol") do
|
46
|
+
@options.add_sort_key("-count", :desc)
|
47
|
+
assert_equal(["--count"],
|
48
|
+
@options.sort_keys.collect(&:to_s))
|
49
|
+
end
|
50
|
+
|
51
|
+
test("SortKey") do
|
52
|
+
@options.add_sort_key(Arrow::SortKey.new("-count"))
|
53
|
+
assert_equal(["-count"],
|
54
|
+
@options.sort_keys.collect(&:to_s))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -28,12 +28,12 @@ class SparseUnionDataTypeTest < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
test("ordered arguments") do
|
31
|
-
assert_equal("
|
31
|
+
assert_equal("sparse_union<visible: bool=2, count: int32=9>",
|
32
32
|
Arrow::SparseUnionDataType.new(@fields, [2, 9]).to_s)
|
33
33
|
end
|
34
34
|
|
35
35
|
test("description") do
|
36
|
-
assert_equal("
|
36
|
+
assert_equal("sparse_union<visible: bool=2, count: int32=9>",
|
37
37
|
Arrow::SparseUnionDataType.new(fields: @fields,
|
38
38
|
type_codes: [2, 9]).to_s)
|
39
39
|
end
|