red-arrow 0.4.0 → 0.4.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/doc/text/news.md +10 -0
- data/lib/arrow/array-builder.rb +40 -5
- data/lib/arrow/buffer.rb +24 -0
- data/lib/arrow/loader.rb +1 -0
- data/lib/arrow/version.rb +1 -1
- data/test/test-array-builder.rb +71 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 244f843a8c061c6853ae9325eb442adada478f30
|
4
|
+
data.tar.gz: 304840d2642191a717b21695db9012b8c8037fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8cb38809f2a5532569bd07fa1c39471887f79ce330faf5bc0c1543912cce125926d6e0d042c3a302c91ebbfe85a4f0cc56e639b109d04a656152dd0bbd733fe
|
7
|
+
data.tar.gz: 7e0c529708ae390dbd3a275308c7e14f5c7c1484ca630951c415ad0102b09a0aa5decc32875cbc74554f291aab2eed1e144ca14d07ef58d8b6121e0bd9db86ba
|
data/doc/text/news.md
CHANGED
data/lib/arrow/array-builder.rb
CHANGED
@@ -17,11 +17,46 @@ module Arrow
|
|
17
17
|
class << self
|
18
18
|
def build(values)
|
19
19
|
builder = new
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if builder.respond_to?(:append_values)
|
21
|
+
start_index = 0
|
22
|
+
current_index = 0
|
23
|
+
status = :value
|
24
|
+
values.each do |value|
|
25
|
+
if value.nil?
|
26
|
+
if status == :value
|
27
|
+
if start_index != current_index
|
28
|
+
builder.append_values(values[start_index...current_index])
|
29
|
+
start_index = current_index
|
30
|
+
end
|
31
|
+
status = :null
|
32
|
+
end
|
33
|
+
else
|
34
|
+
if status == :null
|
35
|
+
builder.append_nulls(current_index - start_index)
|
36
|
+
start_index = current_index
|
37
|
+
status = :value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
current_index += 1
|
41
|
+
end
|
42
|
+
if start_index != current_index
|
43
|
+
if status == :value
|
44
|
+
if start_index == 0 and current_index == values.size
|
45
|
+
builder.append_values(values)
|
46
|
+
else
|
47
|
+
builder.append_values(values[start_index...current_index])
|
48
|
+
end
|
49
|
+
else
|
50
|
+
builder.append_nulls(current_index - start_index)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
else
|
54
|
+
values.each do |value|
|
55
|
+
if value.nil?
|
56
|
+
builder.append_null
|
57
|
+
else
|
58
|
+
builder.append(value)
|
59
|
+
end
|
25
60
|
end
|
26
61
|
end
|
27
62
|
builder.finish
|
data/lib/arrow/buffer.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2017 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Arrow
|
16
|
+
class Buffer
|
17
|
+
alias_method :initialize_raw, :initialize
|
18
|
+
def initialize(data)
|
19
|
+
initialize_raw(data)
|
20
|
+
@data = data
|
21
|
+
end
|
22
|
+
private :initialize_raw
|
23
|
+
end
|
24
|
+
end
|
data/lib/arrow/loader.rb
CHANGED
data/lib/arrow/version.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright 2017 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
class ArrayBuilderTest < Test::Unit::TestCase
|
16
|
+
sub_test_case(".build") do
|
17
|
+
test("empty") do
|
18
|
+
array = Arrow::Int32ArrayBuilder.build([])
|
19
|
+
assert_equal([],
|
20
|
+
array.to_a)
|
21
|
+
end
|
22
|
+
|
23
|
+
test("values") do
|
24
|
+
array = Arrow::Int32ArrayBuilder.build([1, -2])
|
25
|
+
assert_equal([1, -2],
|
26
|
+
array.to_a)
|
27
|
+
end
|
28
|
+
|
29
|
+
test("values, nils") do
|
30
|
+
array = Arrow::Int32ArrayBuilder.build([1, -2, nil, nil])
|
31
|
+
assert_equal([1, -2, nil, nil],
|
32
|
+
array.to_a)
|
33
|
+
end
|
34
|
+
|
35
|
+
test("values, nils, values") do
|
36
|
+
array = Arrow::Int32ArrayBuilder.build([1, -2, nil, nil, 3, -4])
|
37
|
+
assert_equal([1, -2, nil, nil, 3, -4],
|
38
|
+
array.to_a)
|
39
|
+
end
|
40
|
+
|
41
|
+
test("values, nils, values, nils") do
|
42
|
+
array = Arrow::Int32ArrayBuilder.build([1, -2, nil, nil, 3, -4, nil, nil])
|
43
|
+
assert_equal([1, -2, nil, nil, 3, -4, nil, nil],
|
44
|
+
array.to_a)
|
45
|
+
end
|
46
|
+
|
47
|
+
test("nils") do
|
48
|
+
array = Arrow::Int32ArrayBuilder.build([nil, nil])
|
49
|
+
assert_equal([nil, nil],
|
50
|
+
array.to_a)
|
51
|
+
end
|
52
|
+
|
53
|
+
test("nils, values") do
|
54
|
+
array = Arrow::Int32ArrayBuilder.build([nil, nil, 3, -4])
|
55
|
+
assert_equal([nil, nil, 3, -4],
|
56
|
+
array.to_a)
|
57
|
+
end
|
58
|
+
|
59
|
+
test("nils, values, nil") do
|
60
|
+
array = Arrow::Int32ArrayBuilder.build([nil, nil, 3, -4, nil, nil])
|
61
|
+
assert_equal([nil, nil, 3, -4, nil, nil],
|
62
|
+
array.to_a)
|
63
|
+
end
|
64
|
+
|
65
|
+
test("nils, values, nil, values") do
|
66
|
+
array = Arrow::Int32ArrayBuilder.build([nil, nil, 3, -4, nil, nil, 5, -6])
|
67
|
+
assert_equal([nil, nil, 3, -4, nil, nil, 5, -6],
|
68
|
+
array.to_a)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red-arrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gobject-introspection
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/arrow/array-builder.rb
|
143
143
|
- lib/arrow/array.rb
|
144
144
|
- lib/arrow/block-closable.rb
|
145
|
+
- lib/arrow/buffer.rb
|
145
146
|
- lib/arrow/chunked-array.rb
|
146
147
|
- lib/arrow/column.rb
|
147
148
|
- lib/arrow/compatibility.rb
|
@@ -157,6 +158,7 @@ files:
|
|
157
158
|
- red-arrow.gemspec
|
158
159
|
- test/helper.rb
|
159
160
|
- test/run-test.rb
|
161
|
+
- test/test-array-builder.rb
|
160
162
|
- test/test-array.rb
|
161
163
|
- test/test-chunked-array.rb
|
162
164
|
- test/test-column.rb
|
@@ -189,11 +191,12 @@ specification_version: 4
|
|
189
191
|
summary: Red Arrow is a Ruby bindings of Apache Arrow. Red Arrow is based on GObject
|
190
192
|
Introspection.
|
191
193
|
test_files:
|
192
|
-
- test/test-record-batch-file-reader.rb
|
193
|
-
- test/test-column.rb
|
194
194
|
- test/test-chunked-array.rb
|
195
|
+
- test/test-table.rb
|
196
|
+
- test/test-record-batch-file-reader.rb
|
197
|
+
- test/test-array-builder.rb
|
198
|
+
- test/run-test.rb
|
195
199
|
- test/test-record-batch.rb
|
196
200
|
- test/helper.rb
|
197
|
-
- test/
|
198
|
-
- test/test-table.rb
|
201
|
+
- test/test-column.rb
|
199
202
|
- test/test-array.rb
|