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-list-array.rb
DELETED
@@ -1,32 +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 ListArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("build") do
|
21
|
-
data_type = Arrow::ListDataType.new(name: "visible", type: :boolean)
|
22
|
-
values = [
|
23
|
-
[true, false],
|
24
|
-
nil,
|
25
|
-
[false, true, false],
|
26
|
-
]
|
27
|
-
array = Arrow::ListArray.new(data_type, values)
|
28
|
-
assert_equal(values,
|
29
|
-
array.collect {|value| value ? value.to_a : nil})
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/test/test-list-data-type.rb
DELETED
@@ -1,69 +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 ListDataTypeTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("Arrow::Field") do
|
21
|
-
field = Arrow::Field.new(:tag, :string)
|
22
|
-
assert_equal("list<tag: string>",
|
23
|
-
Arrow::ListDataType.new(field).to_s)
|
24
|
-
end
|
25
|
-
|
26
|
-
test("name: String") do
|
27
|
-
assert_equal("list<tag: string>",
|
28
|
-
Arrow::ListDataType.new(name: "tag", type: :string).to_s)
|
29
|
-
end
|
30
|
-
|
31
|
-
test("field: Arrow::Field") do
|
32
|
-
field = Arrow::Field.new(:tag, :string)
|
33
|
-
assert_equal("list<tag: string>",
|
34
|
-
Arrow::ListDataType.new(field: field).to_s)
|
35
|
-
end
|
36
|
-
|
37
|
-
test("field: Hash") do
|
38
|
-
field_description = {name: "tag", type: :string}
|
39
|
-
assert_equal("list<tag: string>",
|
40
|
-
Arrow::ListDataType.new(field: field_description).to_s)
|
41
|
-
end
|
42
|
-
|
43
|
-
test("Arrow::DataType") do
|
44
|
-
data_type = Arrow::BooleanDataType.new
|
45
|
-
assert_equal("list<item: bool>",
|
46
|
-
Arrow::ListDataType.new(data_type).to_s)
|
47
|
-
end
|
48
|
-
|
49
|
-
test("String") do
|
50
|
-
assert_equal("list<item: bool>",
|
51
|
-
Arrow::ListDataType.new("boolean").to_s)
|
52
|
-
end
|
53
|
-
|
54
|
-
test("Symbol") do
|
55
|
-
assert_equal("list<item: bool>",
|
56
|
-
Arrow::ListDataType.new(:boolean).to_s)
|
57
|
-
end
|
58
|
-
|
59
|
-
test("[data type name, additional information]") do
|
60
|
-
assert_equal("list<item: time32[ms]>",
|
61
|
-
Arrow::ListDataType.new([:time32, :milli]).to_s)
|
62
|
-
end
|
63
|
-
|
64
|
-
test("type: Symbol") do
|
65
|
-
assert_equal("list<item: bool>",
|
66
|
-
Arrow::ListDataType.new(type: :boolean).to_s)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,110 +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 MapArrayBuilderTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
key_type = Arrow::StringDataType.new
|
21
|
-
item_type = Arrow::Int16DataType.new
|
22
|
-
data_type = Arrow::MapDataType.new(key_type, item_type)
|
23
|
-
@builder = Arrow::MapArrayBuilder.new(data_type)
|
24
|
-
end
|
25
|
-
|
26
|
-
sub_test_case("#append_value") do
|
27
|
-
test("nil") do
|
28
|
-
@builder.append_value(nil)
|
29
|
-
array = @builder.finish
|
30
|
-
assert_equal([nil], array.collect {|value| value})
|
31
|
-
end
|
32
|
-
|
33
|
-
test("Hash") do
|
34
|
-
@builder.append_value({"a" => 0, "b" => 1})
|
35
|
-
@builder.append_value({"c" => 0, "d" => 1})
|
36
|
-
array = @builder.finish
|
37
|
-
assert_equal([
|
38
|
-
{"a" => 0, "b" => 1},
|
39
|
-
{"c" => 0, "d" => 1}
|
40
|
-
],
|
41
|
-
array.collect {|value| value})
|
42
|
-
end
|
43
|
-
|
44
|
-
test("#each") do
|
45
|
-
@builder.append_value([["a", 0], ["b", 1]])
|
46
|
-
@builder.append_value([["c", 0], ["d", 1]])
|
47
|
-
array = @builder.finish
|
48
|
-
assert_equal([
|
49
|
-
{"a" => 0, "b" => 1},
|
50
|
-
{"c" => 0, "d" => 1}
|
51
|
-
],
|
52
|
-
array.collect {|value| value})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
sub_test_case("#append_values") do
|
57
|
-
test("[nil]") do
|
58
|
-
@builder.append_values([nil])
|
59
|
-
array = @builder.finish
|
60
|
-
assert_equal([nil], array.collect {|value| value})
|
61
|
-
end
|
62
|
-
|
63
|
-
test("[Hash]") do
|
64
|
-
@builder.append_values([{"a" => 0, "b" => 1}, {"c" => 0, "d" => 1}])
|
65
|
-
array = @builder.finish
|
66
|
-
assert_equal([
|
67
|
-
{"a" => 0, "b" => 1},
|
68
|
-
{"c" => 0, "d" => 1}
|
69
|
-
],
|
70
|
-
array.collect {|value| value})
|
71
|
-
end
|
72
|
-
|
73
|
-
test("[#each]") do
|
74
|
-
@builder.append_values([[["a", 0], ["b", 1]], [["c", 0], ["d", 1]]])
|
75
|
-
array = @builder.finish
|
76
|
-
assert_equal([
|
77
|
-
{"a" => 0, "b" => 1},
|
78
|
-
{"c" => 0, "d" => 1}
|
79
|
-
],
|
80
|
-
array.collect {|value| value})
|
81
|
-
end
|
82
|
-
|
83
|
-
test("[nil, Hash, #each]") do
|
84
|
-
@builder.append_values([nil, {"a" => 0, "b" => 1}, [["c", 0], ["d", 1]]])
|
85
|
-
array = @builder.finish
|
86
|
-
assert_equal([
|
87
|
-
nil,
|
88
|
-
{"a" => 0, "b" => 1},
|
89
|
-
{"c" => 0, "d" => 1}
|
90
|
-
],
|
91
|
-
array.collect {|value| value})
|
92
|
-
end
|
93
|
-
|
94
|
-
test("is_valids") do
|
95
|
-
@builder.append_values([
|
96
|
-
{"a" => 0, "b" => 1},
|
97
|
-
{"c" => 0, "d" => 1},
|
98
|
-
{"e" => 0, "f" => 1}
|
99
|
-
],
|
100
|
-
[true, false, true])
|
101
|
-
array = @builder.finish
|
102
|
-
assert_equal([
|
103
|
-
{"a" => 0, "b" => 1},
|
104
|
-
nil,
|
105
|
-
{"e" => 0, "f" => 1}
|
106
|
-
],
|
107
|
-
array.collect {|value| value})
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
data/test/test-map-array.rb
DELETED
@@ -1,33 +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 MapArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("build") do
|
21
|
-
key_type = Arrow::StringDataType.new
|
22
|
-
item_type = Arrow::Int16DataType.new
|
23
|
-
data_type = Arrow::MapDataType.new(key_type, item_type)
|
24
|
-
values = [
|
25
|
-
{"a" => 0, "b" => 1},
|
26
|
-
nil,
|
27
|
-
{"c" => 0, "d" => 1}
|
28
|
-
]
|
29
|
-
array = Arrow::MapArray.new(data_type, values)
|
30
|
-
assert_equal(values, array.collect {|value| value})
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/test/test-memory-view.rb
DELETED
@@ -1,434 +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 MemoryViewTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
unless Fiddle.const_defined?(:MemoryView)
|
21
|
-
omit("Fiddle::MemoryView is needed")
|
22
|
-
end
|
23
|
-
unless Fiddle::MemoryView.respond_to?(:export)
|
24
|
-
omit("Fiddle::MemoryView.export is needed")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def little_endian?
|
29
|
-
[1].pack("s") == [1].pack("s<")
|
30
|
-
end
|
31
|
-
|
32
|
-
test("BooleanArray") do
|
33
|
-
array = Arrow::BooleanArray.new([true] * 9)
|
34
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
35
|
-
if little_endian?
|
36
|
-
template = "b"
|
37
|
-
else
|
38
|
-
template = "B"
|
39
|
-
end
|
40
|
-
assert_equal([
|
41
|
-
"#{template}8",
|
42
|
-
1,
|
43
|
-
2,
|
44
|
-
[(("1" * 9) + ("0" * 7))].pack("#{template}*"),
|
45
|
-
],
|
46
|
-
[
|
47
|
-
memory_view.format,
|
48
|
-
memory_view.item_size,
|
49
|
-
memory_view.byte_size,
|
50
|
-
memory_view.to_s,
|
51
|
-
])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
test("Int8Array") do
|
56
|
-
values = [-(2 ** 7), 0, (2 ** 7) - 1]
|
57
|
-
array = Arrow::Int8Array.new(values)
|
58
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
59
|
-
assert_equal([
|
60
|
-
"c",
|
61
|
-
1,
|
62
|
-
values.size,
|
63
|
-
values.pack("c*"),
|
64
|
-
],
|
65
|
-
[
|
66
|
-
memory_view.format,
|
67
|
-
memory_view.item_size,
|
68
|
-
memory_view.byte_size,
|
69
|
-
memory_view.to_s,
|
70
|
-
])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
test("Int16Array") do
|
75
|
-
values = [-(2 ** 15), 0, (2 ** 15) - 1]
|
76
|
-
array = Arrow::Int16Array.new(values)
|
77
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
78
|
-
assert_equal([
|
79
|
-
"s",
|
80
|
-
2,
|
81
|
-
2 * values.size,
|
82
|
-
values.pack("s*"),
|
83
|
-
],
|
84
|
-
[
|
85
|
-
memory_view.format,
|
86
|
-
memory_view.item_size,
|
87
|
-
memory_view.byte_size,
|
88
|
-
memory_view.to_s,
|
89
|
-
])
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
test("Int32Array") do
|
94
|
-
values = [-(2 ** 31), 0, (2 ** 31) - 1]
|
95
|
-
array = Arrow::Int32Array.new(values)
|
96
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
97
|
-
assert_equal([
|
98
|
-
"l",
|
99
|
-
4,
|
100
|
-
4 * values.size,
|
101
|
-
values.pack("l*"),
|
102
|
-
],
|
103
|
-
[
|
104
|
-
memory_view.format,
|
105
|
-
memory_view.item_size,
|
106
|
-
memory_view.byte_size,
|
107
|
-
memory_view.to_s,
|
108
|
-
])
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
test("Int64Array") do
|
113
|
-
values = [-(2 ** 63), 0, (2 ** 63) - 1]
|
114
|
-
array = Arrow::Int64Array.new(values)
|
115
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
116
|
-
assert_equal([
|
117
|
-
"q",
|
118
|
-
8,
|
119
|
-
8 * values.size,
|
120
|
-
values.pack("q*"),
|
121
|
-
],
|
122
|
-
[
|
123
|
-
memory_view.format,
|
124
|
-
memory_view.item_size,
|
125
|
-
memory_view.byte_size,
|
126
|
-
memory_view.to_s,
|
127
|
-
])
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
test("UInt8Array") do
|
132
|
-
values = [0, (2 ** 8) - 1]
|
133
|
-
array = Arrow::UInt8Array.new(values)
|
134
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
135
|
-
assert_equal([
|
136
|
-
"C",
|
137
|
-
1,
|
138
|
-
values.size,
|
139
|
-
values.pack("C*"),
|
140
|
-
],
|
141
|
-
[
|
142
|
-
memory_view.format,
|
143
|
-
memory_view.item_size,
|
144
|
-
memory_view.byte_size,
|
145
|
-
memory_view.to_s,
|
146
|
-
])
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
test("UInt16Array") do
|
151
|
-
values = [0, (2 ** 16) - 1]
|
152
|
-
array = Arrow::UInt16Array.new(values)
|
153
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
154
|
-
assert_equal([
|
155
|
-
"S",
|
156
|
-
2,
|
157
|
-
2 * values.size,
|
158
|
-
values.pack("S*"),
|
159
|
-
],
|
160
|
-
[
|
161
|
-
memory_view.format,
|
162
|
-
memory_view.item_size,
|
163
|
-
memory_view.byte_size,
|
164
|
-
memory_view.to_s,
|
165
|
-
])
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
test("UInt32Array") do
|
170
|
-
values = [0, (2 ** 32) - 1]
|
171
|
-
array = Arrow::UInt32Array.new(values)
|
172
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
173
|
-
assert_equal([
|
174
|
-
"L",
|
175
|
-
4,
|
176
|
-
4 * values.size,
|
177
|
-
values.pack("L*"),
|
178
|
-
],
|
179
|
-
[
|
180
|
-
memory_view.format,
|
181
|
-
memory_view.item_size,
|
182
|
-
memory_view.byte_size,
|
183
|
-
memory_view.to_s,
|
184
|
-
])
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
test("UInt64Array") do
|
189
|
-
values = [(2 ** 64) - 1]
|
190
|
-
array = Arrow::UInt64Array.new(values)
|
191
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
192
|
-
assert_equal([
|
193
|
-
"Q",
|
194
|
-
8,
|
195
|
-
8 * values.size,
|
196
|
-
values.pack("Q*"),
|
197
|
-
],
|
198
|
-
[
|
199
|
-
memory_view.format,
|
200
|
-
memory_view.item_size,
|
201
|
-
memory_view.byte_size,
|
202
|
-
memory_view.to_s,
|
203
|
-
])
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
test("FloatArray") do
|
208
|
-
values = [-1.1, 0.0, 1.1]
|
209
|
-
array = Arrow::FloatArray.new(values)
|
210
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
211
|
-
assert_equal([
|
212
|
-
"f",
|
213
|
-
4,
|
214
|
-
4 * values.size,
|
215
|
-
values.pack("f*"),
|
216
|
-
],
|
217
|
-
[
|
218
|
-
memory_view.format,
|
219
|
-
memory_view.item_size,
|
220
|
-
memory_view.byte_size,
|
221
|
-
memory_view.to_s,
|
222
|
-
])
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
test("DoubleArray") do
|
227
|
-
values = [-1.1, 0.0, 1.1]
|
228
|
-
array = Arrow::DoubleArray.new(values)
|
229
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
230
|
-
assert_equal([
|
231
|
-
"d",
|
232
|
-
8,
|
233
|
-
8 * values.size,
|
234
|
-
values.pack("d*"),
|
235
|
-
],
|
236
|
-
[
|
237
|
-
memory_view.format,
|
238
|
-
memory_view.item_size,
|
239
|
-
memory_view.byte_size,
|
240
|
-
memory_view.to_s,
|
241
|
-
])
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
test("FixedSizeBinaryArray") do
|
246
|
-
values = ["\x01\x02", "\x03\x04", "\x05\x06"]
|
247
|
-
data_type = Arrow::FixedSizeBinaryDataType.new(2)
|
248
|
-
array = Arrow::FixedSizeBinaryArray.new(data_type, values)
|
249
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
250
|
-
assert_equal([
|
251
|
-
"C2",
|
252
|
-
2,
|
253
|
-
2 * values.size,
|
254
|
-
values.join("").b,
|
255
|
-
],
|
256
|
-
[
|
257
|
-
memory_view.format,
|
258
|
-
memory_view.item_size,
|
259
|
-
memory_view.byte_size,
|
260
|
-
memory_view.to_s,
|
261
|
-
])
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
test("Date32Array") do
|
266
|
-
n_days_since_epoch = 17406 # 2017-08-28
|
267
|
-
values = [n_days_since_epoch]
|
268
|
-
array = Arrow::Date32Array.new(values)
|
269
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
270
|
-
assert_equal([
|
271
|
-
"l",
|
272
|
-
4,
|
273
|
-
4 * values.size,
|
274
|
-
values.pack("l*"),
|
275
|
-
],
|
276
|
-
[
|
277
|
-
memory_view.format,
|
278
|
-
memory_view.item_size,
|
279
|
-
memory_view.byte_size,
|
280
|
-
memory_view.to_s,
|
281
|
-
])
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
test("Date64Array") do
|
286
|
-
n_msecs_since_epoch = 1503878400000 # 2017-08-28T00:00:00Z
|
287
|
-
values = [n_msecs_since_epoch]
|
288
|
-
array = Arrow::Date64Array.new(values)
|
289
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
290
|
-
assert_equal([
|
291
|
-
"q",
|
292
|
-
8,
|
293
|
-
8 * values.size,
|
294
|
-
values.pack("q*"),
|
295
|
-
],
|
296
|
-
[
|
297
|
-
memory_view.format,
|
298
|
-
memory_view.item_size,
|
299
|
-
memory_view.byte_size,
|
300
|
-
memory_view.to_s,
|
301
|
-
])
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
test("Time32Array") do
|
306
|
-
values = [1, 2, 3]
|
307
|
-
array = Arrow::Time32Array.new(:milli, values)
|
308
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
309
|
-
assert_equal([
|
310
|
-
"l",
|
311
|
-
4,
|
312
|
-
4 * values.size,
|
313
|
-
values.pack("l*"),
|
314
|
-
],
|
315
|
-
[
|
316
|
-
memory_view.format,
|
317
|
-
memory_view.item_size,
|
318
|
-
memory_view.byte_size,
|
319
|
-
memory_view.to_s,
|
320
|
-
])
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
test("Time64Array") do
|
325
|
-
values = [1, 2, 3]
|
326
|
-
array = Arrow::Time64Array.new(:nano, values)
|
327
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
328
|
-
assert_equal([
|
329
|
-
"q",
|
330
|
-
8,
|
331
|
-
8 * values.size,
|
332
|
-
values.pack("q*"),
|
333
|
-
],
|
334
|
-
[
|
335
|
-
memory_view.format,
|
336
|
-
memory_view.item_size,
|
337
|
-
memory_view.byte_size,
|
338
|
-
memory_view.to_s,
|
339
|
-
])
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
test("TimestampArray") do
|
344
|
-
values = [1, 2, 3]
|
345
|
-
array = Arrow::TimestampArray.new(:micro, values)
|
346
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
347
|
-
assert_equal([
|
348
|
-
"q",
|
349
|
-
8,
|
350
|
-
8 * values.size,
|
351
|
-
values.pack("q*"),
|
352
|
-
],
|
353
|
-
[
|
354
|
-
memory_view.format,
|
355
|
-
memory_view.item_size,
|
356
|
-
memory_view.byte_size,
|
357
|
-
memory_view.to_s,
|
358
|
-
])
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
test("Decimal128Array") do
|
363
|
-
values = [
|
364
|
-
Arrow::Decimal128.new("10.1"),
|
365
|
-
Arrow::Decimal128.new("11.1"),
|
366
|
-
Arrow::Decimal128.new("10.2"),
|
367
|
-
]
|
368
|
-
data_type = Arrow::Decimal128DataType.new(3, 1)
|
369
|
-
array = Arrow::Decimal128Array.new(data_type, values)
|
370
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
371
|
-
assert_equal([
|
372
|
-
"q2",
|
373
|
-
16,
|
374
|
-
16 * values.size,
|
375
|
-
values.collect {|value| value.to_bytes.to_s}.join(""),
|
376
|
-
],
|
377
|
-
[
|
378
|
-
memory_view.format,
|
379
|
-
memory_view.item_size,
|
380
|
-
memory_view.byte_size,
|
381
|
-
memory_view.to_s,
|
382
|
-
])
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
test("Decimal256Array") do
|
387
|
-
values = [
|
388
|
-
Arrow::Decimal256.new("10.1"),
|
389
|
-
Arrow::Decimal256.new("11.1"),
|
390
|
-
Arrow::Decimal256.new("10.2"),
|
391
|
-
]
|
392
|
-
data_type = Arrow::Decimal256DataType.new(3, 1)
|
393
|
-
array = Arrow::Decimal256Array.new(data_type, values)
|
394
|
-
Fiddle::MemoryView.export(array) do |memory_view|
|
395
|
-
assert_equal([
|
396
|
-
"q4",
|
397
|
-
32,
|
398
|
-
32 * values.size,
|
399
|
-
values.collect {|value| value.to_bytes.to_s}.join(""),
|
400
|
-
],
|
401
|
-
[
|
402
|
-
memory_view.format,
|
403
|
-
memory_view.item_size,
|
404
|
-
memory_view.byte_size,
|
405
|
-
memory_view.to_s,
|
406
|
-
])
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
test("Buffer") do
|
411
|
-
values = [0, nil, nil] * 3
|
412
|
-
array = Arrow::Int8Array.new(values)
|
413
|
-
buffer = array.null_bitmap
|
414
|
-
Fiddle::MemoryView.export(buffer) do |memory_view|
|
415
|
-
if little_endian?
|
416
|
-
template = "b"
|
417
|
-
else
|
418
|
-
template = "B"
|
419
|
-
end
|
420
|
-
assert_equal([
|
421
|
-
"#{template}8",
|
422
|
-
1,
|
423
|
-
2,
|
424
|
-
["100" * 3].pack("#{template}*"),
|
425
|
-
],
|
426
|
-
[
|
427
|
-
memory_view.format,
|
428
|
-
memory_view.item_size,
|
429
|
-
memory_view.byte_size,
|
430
|
-
memory_view.to_s,
|
431
|
-
])
|
432
|
-
end
|
433
|
-
end
|
434
|
-
end
|