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-sort-options.rb
DELETED
@@ -1,58 +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 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
|
@@ -1,38 +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 SparseUnionArrayTest < 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::SparseUnionDataType.new(data_type_fields, type_codes)
|
26
|
-
type_ids = Arrow::Int8Array.new([11, 13, 11, 13, 11])
|
27
|
-
fields = [
|
28
|
-
Arrow::Int16Array.new([1, nil, nil, nil, 5]),
|
29
|
-
Arrow::StringArray.new([nil, "b", nil, "d", nil]),
|
30
|
-
]
|
31
|
-
@array = Arrow::SparseUnionArray.new(@data_type, type_ids, fields)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_get_value
|
35
|
-
assert_equal([1, "b", nil, "d", 5],
|
36
|
-
@array.length.times.collect {|i| @array[i]})
|
37
|
-
end
|
38
|
-
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 SparseUnionDataTypeTest < 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("sparse_union<visible: bool=2, count: int32=9>",
|
32
|
-
Arrow::SparseUnionDataType.new(@fields, [2, 9]).to_s)
|
33
|
-
end
|
34
|
-
|
35
|
-
test("description") do
|
36
|
-
assert_equal("sparse_union<visible: bool=2, count: int32=9>",
|
37
|
-
Arrow::SparseUnionDataType.new(fields: @fields,
|
38
|
-
type_codes: [2, 9]).to_s)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,60 +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 TestStreamListener < Test::Unit::TestCase
|
19
|
-
class Listener < Arrow::StreamListener
|
20
|
-
attr_reader :events
|
21
|
-
def initialize
|
22
|
-
super
|
23
|
-
@events = []
|
24
|
-
end
|
25
|
-
|
26
|
-
def on_eos
|
27
|
-
@events << [:eos]
|
28
|
-
end
|
29
|
-
|
30
|
-
def on_record_batch_decoded(record_batch, metadata)
|
31
|
-
@events << [:record_batch_decoded, record_batch, metadata]
|
32
|
-
end
|
33
|
-
|
34
|
-
def on_schema_decoded(schema, filtered_schema)
|
35
|
-
@events << [:schema_decoded, schema, filtered_schema]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def setup
|
40
|
-
@record_batch = Arrow::RecordBatch.new(enabled: [true, false, nil, true])
|
41
|
-
@schema = @record_batch.schema
|
42
|
-
|
43
|
-
@buffer = Arrow::ResizableBuffer.new(0)
|
44
|
-
table = Arrow::Table.new(@schema, [@record_batch])
|
45
|
-
table.save(@buffer, format: :stream)
|
46
|
-
|
47
|
-
@listener = Listener.new
|
48
|
-
@decoder = Arrow::StreamDecoder.new(@listener)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_consume
|
52
|
-
@decoder.consume(@buffer)
|
53
|
-
assert_equal([
|
54
|
-
[:schema_decoded, @schema, @schema],
|
55
|
-
[:record_batch_decoded, @record_batch, nil],
|
56
|
-
[:eos],
|
57
|
-
],
|
58
|
-
@listener.events)
|
59
|
-
end
|
60
|
-
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 StringDictionaryArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@builder = Arrow::StringDictionaryArrayBuilder.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(["hello"])
|
39
|
-
array = @builder.finish
|
40
|
-
assert_equal([
|
41
|
-
["hello"],
|
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
|
-
"Hello",
|
67
|
-
:world,
|
68
|
-
"world",
|
69
|
-
])
|
70
|
-
array = @builder.finish
|
71
|
-
assert_equal([
|
72
|
-
["Hello", "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
|
-
"Hello",
|
84
|
-
:world,
|
85
|
-
:goodbye,
|
86
|
-
],
|
87
|
-
[
|
88
|
-
true,
|
89
|
-
false,
|
90
|
-
true,
|
91
|
-
])
|
92
|
-
array = @builder.finish
|
93
|
-
assert_equal([
|
94
|
-
["Hello", "goodbye"],
|
95
|
-
[0, nil, 1],
|
96
|
-
],
|
97
|
-
[
|
98
|
-
array.dictionary.to_a,
|
99
|
-
array.indices.to_a,
|
100
|
-
])
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,184 +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 StructArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@data_type = Arrow::StructDataType.new(visible: {type: :boolean},
|
21
|
-
count: {type: :uint64})
|
22
|
-
@builder = Arrow::StructArrayBuilder.new(@data_type)
|
23
|
-
end
|
24
|
-
|
25
|
-
sub_test_case("#append_value") do
|
26
|
-
test("nil") do
|
27
|
-
@builder.append_value(nil)
|
28
|
-
array = @builder.finish
|
29
|
-
assert_equal([
|
30
|
-
[false],
|
31
|
-
[0],
|
32
|
-
],
|
33
|
-
[
|
34
|
-
array.find_field(0).to_a,
|
35
|
-
array.find_field(1).to_a,
|
36
|
-
])
|
37
|
-
end
|
38
|
-
|
39
|
-
test("Array") do
|
40
|
-
@builder.append_value([true, 1])
|
41
|
-
@builder.append_value([])
|
42
|
-
@builder.append_value([false])
|
43
|
-
array = @builder.finish
|
44
|
-
assert_equal([
|
45
|
-
[true, nil, false],
|
46
|
-
[1, nil, nil],
|
47
|
-
],
|
48
|
-
[
|
49
|
-
array.find_field(0).to_a,
|
50
|
-
array.find_field(1).to_a,
|
51
|
-
])
|
52
|
-
end
|
53
|
-
|
54
|
-
test("Arrow::Struct") do
|
55
|
-
source_array = Arrow::StructArray.new(@data_type, [[true, 1]])
|
56
|
-
struct = source_array.get_value(0)
|
57
|
-
@builder.append_value(struct)
|
58
|
-
array = @builder.finish
|
59
|
-
assert_equal([
|
60
|
-
[true],
|
61
|
-
[1],
|
62
|
-
],
|
63
|
-
[
|
64
|
-
array.find_field(0).to_a,
|
65
|
-
array.find_field(1).to_a,
|
66
|
-
])
|
67
|
-
end
|
68
|
-
|
69
|
-
test("Hash") do
|
70
|
-
@builder.append_value(count: 1, visible: true)
|
71
|
-
@builder.append_value(visible: false)
|
72
|
-
@builder.append_value(count: 2)
|
73
|
-
array = @builder.finish
|
74
|
-
assert_equal([
|
75
|
-
[true, false, nil],
|
76
|
-
[1, nil, 2],
|
77
|
-
],
|
78
|
-
[
|
79
|
-
array.find_field(0).to_a,
|
80
|
-
array.find_field(1).to_a,
|
81
|
-
])
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
sub_test_case("#append_values") do
|
86
|
-
test("[nil]") do
|
87
|
-
@builder.append_values([nil])
|
88
|
-
array = @builder.finish
|
89
|
-
assert_equal([
|
90
|
-
[false],
|
91
|
-
[0],
|
92
|
-
],
|
93
|
-
[
|
94
|
-
array.find_field(0).to_a,
|
95
|
-
array.find_field(1).to_a,
|
96
|
-
])
|
97
|
-
end
|
98
|
-
|
99
|
-
test("[Array]") do
|
100
|
-
@builder.append_values([[true, 1]])
|
101
|
-
array = @builder.finish
|
102
|
-
assert_equal([
|
103
|
-
[true],
|
104
|
-
[1],
|
105
|
-
],
|
106
|
-
[
|
107
|
-
array.find_field(0).to_a,
|
108
|
-
array.find_field(1).to_a,
|
109
|
-
])
|
110
|
-
end
|
111
|
-
|
112
|
-
test("[Hash]") do
|
113
|
-
@builder.append_values([{count: 1, visible: true}])
|
114
|
-
array = @builder.finish
|
115
|
-
assert_equal([
|
116
|
-
[true],
|
117
|
-
[1],
|
118
|
-
],
|
119
|
-
[
|
120
|
-
array.find_field(0).to_a,
|
121
|
-
array.find_field(1).to_a,
|
122
|
-
])
|
123
|
-
end
|
124
|
-
|
125
|
-
test("[nil, Array, Hash]") do
|
126
|
-
@builder.append_values([
|
127
|
-
nil,
|
128
|
-
[true, 1],
|
129
|
-
{count: 2, visible: false},
|
130
|
-
])
|
131
|
-
array = @builder.finish
|
132
|
-
assert_equal([
|
133
|
-
[false, true, false],
|
134
|
-
[0, 1, 2],
|
135
|
-
],
|
136
|
-
[
|
137
|
-
array.find_field(0).to_a,
|
138
|
-
array.find_field(1).to_a,
|
139
|
-
])
|
140
|
-
end
|
141
|
-
|
142
|
-
test("is_valids") do
|
143
|
-
@builder.append_values([
|
144
|
-
[true, 1],
|
145
|
-
[false, 2],
|
146
|
-
[true, 3],
|
147
|
-
],
|
148
|
-
[
|
149
|
-
true,
|
150
|
-
false,
|
151
|
-
true,
|
152
|
-
])
|
153
|
-
array = @builder.finish
|
154
|
-
assert_equal([
|
155
|
-
[true, false, true],
|
156
|
-
[1, 0, 3],
|
157
|
-
],
|
158
|
-
[
|
159
|
-
array.find_field(0).to_a,
|
160
|
-
array.find_field(1).to_a,
|
161
|
-
])
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
sub_test_case("#append") do
|
166
|
-
test("backward compatibility") do
|
167
|
-
@builder.append
|
168
|
-
@builder.get_field_builder(0).append(true)
|
169
|
-
@builder.get_field_builder(1).append(1)
|
170
|
-
@builder.append
|
171
|
-
@builder.get_field_builder(0).append(false)
|
172
|
-
@builder.get_field_builder(1).append(2)
|
173
|
-
array = @builder.finish
|
174
|
-
assert_equal([
|
175
|
-
{"visible" => true, "count" => 1},
|
176
|
-
{"visible" => false, "count" => 2},
|
177
|
-
],
|
178
|
-
[
|
179
|
-
array.get_value(0),
|
180
|
-
array.get_value(1),
|
181
|
-
])
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
data/test/test-struct-array.rb
DELETED
@@ -1,94 +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 StructArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("build") do
|
21
|
-
data_type = Arrow::StructDataType.new(visible: :boolean,
|
22
|
-
count: :uint64)
|
23
|
-
values = [
|
24
|
-
[true, 1],
|
25
|
-
nil,
|
26
|
-
[false, 2],
|
27
|
-
]
|
28
|
-
array = Arrow::StructArray.new(data_type, values)
|
29
|
-
assert_equal([
|
30
|
-
[true, false, false],
|
31
|
-
[1, 0, 2],
|
32
|
-
],
|
33
|
-
[
|
34
|
-
array.find_field(0).to_a,
|
35
|
-
array.find_field(1).to_a,
|
36
|
-
])
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
sub_test_case("instance methods") do
|
41
|
-
def setup
|
42
|
-
@data_type = Arrow::StructDataType.new(visible: {type: :boolean},
|
43
|
-
count: {type: :uint64})
|
44
|
-
@values = [
|
45
|
-
[true, 1],
|
46
|
-
[false, 2],
|
47
|
-
]
|
48
|
-
@array = Arrow::StructArray.new(@data_type, @values)
|
49
|
-
end
|
50
|
-
|
51
|
-
test("#[]") do
|
52
|
-
assert_equal([
|
53
|
-
{"visible" => true, "count" => 1},
|
54
|
-
{"visible" => false, "count" => 2},
|
55
|
-
],
|
56
|
-
@array.to_a)
|
57
|
-
end
|
58
|
-
|
59
|
-
test("#get_value") do
|
60
|
-
assert_equal([
|
61
|
-
{"visible" => true, "count" => 1},
|
62
|
-
{"visible" => false, "count" => 2},
|
63
|
-
],
|
64
|
-
[
|
65
|
-
@array.get_value(0),
|
66
|
-
@array.get_value(1),
|
67
|
-
])
|
68
|
-
end
|
69
|
-
|
70
|
-
sub_test_case("#find_field") do
|
71
|
-
test("Integer") do
|
72
|
-
assert_equal([
|
73
|
-
[true, false],
|
74
|
-
[1, 2],
|
75
|
-
],
|
76
|
-
[
|
77
|
-
@array.find_field(0).to_a,
|
78
|
-
@array.find_field(1).to_a,
|
79
|
-
])
|
80
|
-
end
|
81
|
-
|
82
|
-
test("String, Symbol") do
|
83
|
-
assert_equal([
|
84
|
-
[true, false],
|
85
|
-
[1, 2],
|
86
|
-
],
|
87
|
-
[
|
88
|
-
@array.find_field("visible").to_a,
|
89
|
-
@array.find_field(:count).to_a,
|
90
|
-
])
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,112 +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 StructDataTypeTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@count_field = Arrow::Field.new("count", :uint32)
|
21
|
-
@visible_field = Arrow::Field.new("visible", :boolean)
|
22
|
-
end
|
23
|
-
|
24
|
-
sub_test_case(".new") do
|
25
|
-
test("[Arrow::Field]") do
|
26
|
-
fields = [
|
27
|
-
@count_field,
|
28
|
-
@visible_field,
|
29
|
-
]
|
30
|
-
assert_equal("struct<count: uint32, visible: bool>",
|
31
|
-
Arrow::StructDataType.new(fields).to_s)
|
32
|
-
end
|
33
|
-
|
34
|
-
test("[Hash]") do
|
35
|
-
fields = [
|
36
|
-
{name: "count", data_type: :uint32},
|
37
|
-
{name: "visible", data_type: :boolean},
|
38
|
-
]
|
39
|
-
assert_equal("struct<count: uint32, visible: bool>",
|
40
|
-
Arrow::StructDataType.new(fields).to_s)
|
41
|
-
end
|
42
|
-
|
43
|
-
test("[Arrow::Field, Hash]") do
|
44
|
-
fields = [
|
45
|
-
@count_field,
|
46
|
-
{name: "visible", data_type: :boolean},
|
47
|
-
]
|
48
|
-
assert_equal("struct<count: uint32, visible: bool>",
|
49
|
-
Arrow::StructDataType.new(fields).to_s)
|
50
|
-
end
|
51
|
-
|
52
|
-
test("{Arrow::DataType}") do
|
53
|
-
fields = {
|
54
|
-
"count" => Arrow::UInt32DataType.new,
|
55
|
-
"visible" => Arrow::BooleanDataType.new,
|
56
|
-
}
|
57
|
-
assert_equal("struct<count: uint32, visible: bool>",
|
58
|
-
Arrow::StructDataType.new(fields).to_s)
|
59
|
-
end
|
60
|
-
|
61
|
-
test("{Hash}") do
|
62
|
-
fields = {
|
63
|
-
"count" => {type: :uint32},
|
64
|
-
"visible" => {type: :boolean},
|
65
|
-
}
|
66
|
-
assert_equal("struct<count: uint32, visible: bool>",
|
67
|
-
Arrow::StructDataType.new(fields).to_s)
|
68
|
-
end
|
69
|
-
|
70
|
-
test("{String, Symbol}") do
|
71
|
-
fields = {
|
72
|
-
"count" => "uint32",
|
73
|
-
"visible" => :boolean,
|
74
|
-
}
|
75
|
-
assert_equal("struct<count: uint32, visible: bool>",
|
76
|
-
Arrow::StructDataType.new(fields).to_s)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
sub_test_case("instance methods") do
|
81
|
-
def setup
|
82
|
-
super
|
83
|
-
@data_type = Arrow::StructDataType.new([@count_field, @visible_field])
|
84
|
-
end
|
85
|
-
|
86
|
-
sub_test_case("#[]") do
|
87
|
-
test("[String]") do
|
88
|
-
assert_equal([@count_field, @visible_field],
|
89
|
-
[@data_type["count"], @data_type["visible"]])
|
90
|
-
end
|
91
|
-
|
92
|
-
test("[Symbol]") do
|
93
|
-
assert_equal([@count_field, @visible_field],
|
94
|
-
[@data_type[:count], @data_type[:visible]])
|
95
|
-
end
|
96
|
-
|
97
|
-
test("[Integer]") do
|
98
|
-
assert_equal([@count_field, @visible_field],
|
99
|
-
[@data_type[0], @data_type[1]])
|
100
|
-
end
|
101
|
-
|
102
|
-
test("[invalid]") do
|
103
|
-
invalid = []
|
104
|
-
message = +"field name or index must be String, Symbol or Integer"
|
105
|
-
message << ": <#{invalid.inspect}>"
|
106
|
-
assert_raise(ArgumentError.new(message)) do
|
107
|
-
@data_type[invalid]
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|