red-arrow 6.0.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/ext/arrow/extconf.rb +1 -1
- data/lib/arrow/datum.rb +2 -0
- data/lib/arrow/function.rb +52 -0
- data/lib/arrow/loader.rb +14 -0
- data/lib/arrow/s3-global-options.rb +38 -0
- data/lib/arrow/sort-key.rb +61 -55
- data/lib/arrow/sort-options.rb +8 -8
- data/lib/arrow/table-loader.rb +99 -62
- data/lib/arrow/table-saver.rb +7 -2
- data/lib/arrow/table.rb +78 -0
- data/lib/arrow/version.rb +1 -1
- data/red-arrow.gemspec +1 -10
- data/test/helper.rb +2 -0
- data/test/test-function.rb +48 -14
- data/test/test-table.rb +186 -3
- metadata +84 -194
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cee7217ce22a2c2d7a20bbe073ffe41efbab3d9628cfdc0e19e077acb4965557
|
4
|
+
data.tar.gz: da14c7fd57bf63294fbe46f74bb286b0d6e26dafaa80b977d11639c275dbd677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e22fdcc86f32f0443a6335099ce510840dfae9134bb4ffe6d51bfcbfdc2d66f87bbe29cd46a7af670077add2d12786474eaa3a716a27dc161fcd69b7c40974
|
7
|
+
data.tar.gz: 23b84e6766953cc89e8502043065dfdcf0c6a83ef1f29feae2a85e6ec3f7e01f0800f975eeb38076b255688a818984b9ae5eca2da483b96e42c5dd132089355a
|
data/Gemfile
CHANGED
data/ext/arrow/extconf.rb
CHANGED
@@ -28,7 +28,7 @@ end
|
|
28
28
|
checking_for(checking_message("Homebrew")) do
|
29
29
|
platform = NativePackageInstaller::Platform.detect
|
30
30
|
if platform.is_a?(NativePackageInstaller::Platform::Homebrew)
|
31
|
-
openssl_prefix = `brew --prefix openssl
|
31
|
+
openssl_prefix = `brew --prefix openssl`.chomp
|
32
32
|
unless openssl_prefix.empty?
|
33
33
|
PKGConfig.add_path("#{openssl_prefix}/lib/pkgconfig")
|
34
34
|
end
|
data/lib/arrow/datum.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
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
|
+
module Arrow
|
19
|
+
class Function
|
20
|
+
alias_method :execute_raw, :execute
|
21
|
+
def execute(args, options=nil, context=nil)
|
22
|
+
options = resolve_options(options)
|
23
|
+
execute_raw(args, options, context)
|
24
|
+
end
|
25
|
+
alias_method :call, :execute
|
26
|
+
|
27
|
+
private
|
28
|
+
def resolve_options(options)
|
29
|
+
return nil if options.nil?
|
30
|
+
return options if options.is_a?(FunctionOptions)
|
31
|
+
|
32
|
+
arrow_options_class = options_type&.to_class
|
33
|
+
if arrow_options_class
|
34
|
+
if arrow_options_class.respond_to?(:try_convert)
|
35
|
+
arrow_options = arrow_options_class.try_convert(options)
|
36
|
+
return arrow_options if arrow_options
|
37
|
+
end
|
38
|
+
arrow_options = (default_options || arrow_options_class.new)
|
39
|
+
else
|
40
|
+
arrow_options = default_options
|
41
|
+
end
|
42
|
+
return arrow_options if arrow_options.nil?
|
43
|
+
|
44
|
+
options.each do |key, value|
|
45
|
+
setter = :"#{key}="
|
46
|
+
next unless arrow_options.respond_to?(setter)
|
47
|
+
arrow_options.__send__(setter, value)
|
48
|
+
end
|
49
|
+
arrow_options
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/arrow/loader.rb
CHANGED
@@ -30,6 +30,7 @@ module Arrow
|
|
30
30
|
require_libraries
|
31
31
|
require_extension_library
|
32
32
|
gc_guard
|
33
|
+
self.class.start_callback_dispatch_thread
|
33
34
|
end
|
34
35
|
|
35
36
|
def require_libraries
|
@@ -76,6 +77,7 @@ module Arrow
|
|
76
77
|
require "arrow/file-system"
|
77
78
|
require "arrow/fixed-size-binary-array"
|
78
79
|
require "arrow/fixed-size-binary-array-builder"
|
80
|
+
require "arrow/function"
|
79
81
|
require "arrow/group"
|
80
82
|
require "arrow/list-array-builder"
|
81
83
|
require "arrow/list-data-type"
|
@@ -93,6 +95,7 @@ module Arrow
|
|
93
95
|
require "arrow/record-batch-reader"
|
94
96
|
require "arrow/record-batch-stream-reader"
|
95
97
|
require "arrow/rolling-window"
|
98
|
+
require "arrow/s3-global-options"
|
96
99
|
require "arrow/scalar"
|
97
100
|
require "arrow/schema"
|
98
101
|
require "arrow/slicer"
|
@@ -212,5 +215,16 @@ module Arrow
|
|
212
215
|
super
|
213
216
|
end
|
214
217
|
end
|
218
|
+
|
219
|
+
def prepare_function_info_lock_gvl(function_info, klass)
|
220
|
+
super
|
221
|
+
case klass.name
|
222
|
+
when "Arrow::RecordBatchFileReader"
|
223
|
+
case function_info.name
|
224
|
+
when "new"
|
225
|
+
function_info.lock_gvl_default = false
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
215
229
|
end
|
216
230
|
end
|
@@ -0,0 +1,38 @@
|
|
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
|
+
module Arrow
|
19
|
+
class S3GlobalOptions
|
20
|
+
class << self
|
21
|
+
# @api private
|
22
|
+
def try_convert(value)
|
23
|
+
case value
|
24
|
+
when Hash
|
25
|
+
options = new
|
26
|
+
value.each do |k, v|
|
27
|
+
setter = :"#{k}="
|
28
|
+
return unless options.respond_to?(setter)
|
29
|
+
options.__send__(setter, v)
|
30
|
+
end
|
31
|
+
options
|
32
|
+
else
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/arrow/sort-key.rb
CHANGED
@@ -29,25 +29,26 @@ module Arrow
|
|
29
29
|
#
|
30
30
|
# @return [Arrow::SortKey] The given sort key itself.
|
31
31
|
#
|
32
|
-
# @overload resolve(
|
32
|
+
# @overload resolve(target)
|
33
33
|
#
|
34
|
-
# Creates a new suitable sort key from column name
|
35
|
-
# leading order mark. See {#initialize} for details about
|
34
|
+
# Creates a new suitable sort key from column name or dot path
|
35
|
+
# with leading order mark. See {#initialize} for details about
|
36
36
|
# order mark.
|
37
37
|
#
|
38
38
|
# @return [Arrow::SortKey] A new suitable sort key.
|
39
39
|
#
|
40
|
-
# @overload resolve(
|
40
|
+
# @overload resolve(target, order)
|
41
41
|
#
|
42
|
-
# Creates a new suitable sort key from column name
|
43
|
-
# leading order mark and order. See {#initialize} for
|
42
|
+
# Creates a new suitable sort key from column name or dot path
|
43
|
+
# without leading order mark and order. See {#initialize} for
|
44
|
+
# details.
|
44
45
|
#
|
45
46
|
# @return [Arrow::SortKey] A new suitable sort key.
|
46
47
|
#
|
47
48
|
# @since 4.0.0
|
48
|
-
def resolve(
|
49
|
-
return
|
50
|
-
new(
|
49
|
+
def resolve(target, order=nil)
|
50
|
+
return target if target.is_a?(self)
|
51
|
+
new(target, order)
|
51
52
|
end
|
52
53
|
|
53
54
|
# @api private
|
@@ -65,47 +66,49 @@ module Arrow
|
|
65
66
|
private :initialize_raw
|
66
67
|
# Creates a new {Arrow::SortKey}.
|
67
68
|
#
|
68
|
-
# @overload initialize(
|
69
|
+
# @overload initialize(target)
|
69
70
|
#
|
70
|
-
# @param
|
71
|
+
# @param target [Symbol, String] The name or dot path of the
|
72
|
+
# sort column.
|
71
73
|
#
|
72
|
-
# If `
|
73
|
-
# as the "leading order mark". If the first
|
74
|
-
# or `"-"`, they are processed as a leading
|
75
|
-
# first character is processed as a leading
|
76
|
-
# first character is removed from sort column
|
77
|
-
# corresponding order is used. `"+"` uses ascending
|
78
|
-
# `"-"` uses ascending order.
|
74
|
+
# If `target` is a String, the first character may be
|
75
|
+
# processed as the "leading order mark". If the first
|
76
|
+
# character is `"+"` or `"-"`, they are processed as a leading
|
77
|
+
# order mark. If the first character is processed as a leading
|
78
|
+
# order mark, the first character is removed from sort column
|
79
|
+
# target and corresponding order is used. `"+"` uses ascending
|
80
|
+
# order and `"-"` uses ascending order.
|
79
81
|
#
|
80
|
-
# If `
|
81
|
-
# leading order mark, sort column
|
82
|
+
# If `target` is not a String nor `target` doesn't start with the
|
83
|
+
# leading order mark, sort column target is `target` as-is and
|
82
84
|
# ascending order is used.
|
83
85
|
#
|
84
86
|
# @example String without the leading order mark
|
85
87
|
# key = Arrow::SortKey.new("count")
|
86
|
-
# key.
|
87
|
-
# key.order
|
88
|
+
# key.target # => "count"
|
89
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
88
90
|
#
|
89
91
|
# @example String with the "+" leading order mark
|
90
92
|
# key = Arrow::SortKey.new("+count")
|
91
|
-
# key.
|
92
|
-
# key.order
|
93
|
+
# key.target # => "count"
|
94
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
93
95
|
#
|
94
96
|
# @example String with the "-" leading order mark
|
95
97
|
# key = Arrow::SortKey.new("-count")
|
96
|
-
# key.
|
97
|
-
# key.order
|
98
|
+
# key.target # => "count"
|
99
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
98
100
|
#
|
99
101
|
# @example Symbol that starts with "-"
|
100
102
|
# key = Arrow::SortKey.new(:"-count")
|
101
|
-
# key.
|
102
|
-
# key.order
|
103
|
+
# key.target # => "-count"
|
104
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
103
105
|
#
|
104
|
-
# @overload initialize(
|
106
|
+
# @overload initialize(target, order)
|
105
107
|
#
|
106
|
-
# @param
|
108
|
+
# @param target [Symbol, String] The name or dot path of the
|
109
|
+
# sort column.
|
107
110
|
#
|
108
|
-
# No leading order mark processing. The given `
|
111
|
+
# No leading order mark processing. The given `target` is used
|
109
112
|
# as-is.
|
110
113
|
#
|
111
114
|
# @param order [Symbol, String, Arrow::SortOrder] How to order
|
@@ -117,29 +120,29 @@ module Arrow
|
|
117
120
|
#
|
118
121
|
# @example No leading order mark processing
|
119
122
|
# key = Arrow::SortKey.new("-count", :ascending)
|
120
|
-
# key.
|
121
|
-
# key.order
|
123
|
+
# key.target # => "-count"
|
124
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
122
125
|
#
|
123
|
-
# @example Order by abbreviated
|
126
|
+
# @example Order by abbreviated target with Symbol
|
124
127
|
# key = Arrow::SortKey.new("count", :desc)
|
125
|
-
# key.
|
126
|
-
# key.order
|
128
|
+
# key.target # => "count"
|
129
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
127
130
|
#
|
128
131
|
# @example Order by String
|
129
132
|
# key = Arrow::SortKey.new("count", "descending")
|
130
|
-
# key.
|
131
|
-
# key.order
|
133
|
+
# key.target # => "count"
|
134
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
132
135
|
#
|
133
136
|
# @example Order by Arrow::SortOrder
|
134
137
|
# key = Arrow::SortKey.new("count", Arrow::SortOrder::DESCENDING)
|
135
|
-
# key.
|
136
|
-
# key.order
|
138
|
+
# key.target # => "count"
|
139
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
137
140
|
#
|
138
141
|
# @since 4.0.0
|
139
|
-
def initialize(
|
140
|
-
|
142
|
+
def initialize(target, order=nil)
|
143
|
+
target, order = normalize_target(target, order)
|
141
144
|
order = normalize_order(order) || :ascending
|
142
|
-
initialize_raw(
|
145
|
+
initialize_raw(target, order)
|
143
146
|
end
|
144
147
|
|
145
148
|
# @return [String] The string representation of this sort key. You
|
@@ -154,28 +157,31 @@ module Arrow
|
|
154
157
|
# @since 4.0.0
|
155
158
|
def to_s
|
156
159
|
if order == SortOrder::ASCENDING
|
157
|
-
"+#{
|
160
|
+
"+#{target}"
|
158
161
|
else
|
159
|
-
"-#{
|
162
|
+
"-#{target}"
|
160
163
|
end
|
161
164
|
end
|
162
165
|
|
166
|
+
# For backward compatibility
|
167
|
+
alias_method :name, :target
|
168
|
+
|
163
169
|
private
|
164
|
-
def
|
165
|
-
case
|
170
|
+
def normalize_target(target, order)
|
171
|
+
case target
|
166
172
|
when Symbol
|
167
|
-
return
|
173
|
+
return target.to_s, order
|
168
174
|
when String
|
169
|
-
return
|
170
|
-
if
|
171
|
-
return
|
172
|
-
elsif
|
173
|
-
return
|
175
|
+
return target, order if order
|
176
|
+
if target.start_with?("-")
|
177
|
+
return target[1..-1], order || :descending
|
178
|
+
elsif target.start_with?("+")
|
179
|
+
return target[1..-1], order || :ascending
|
174
180
|
else
|
175
|
-
return
|
181
|
+
return target, order
|
176
182
|
end
|
177
183
|
else
|
178
|
-
return
|
184
|
+
return target, order
|
179
185
|
end
|
180
186
|
end
|
181
187
|
|
data/lib/arrow/sort-options.rb
CHANGED
@@ -78,20 +78,20 @@ module Arrow
|
|
78
78
|
# options.add_sort_key(Arrow::SortKey.new(:price, :descending))
|
79
79
|
# options.sort_keys.collect(&:to_s) # => ["-price"]
|
80
80
|
#
|
81
|
-
# @overload add_sort_key(
|
81
|
+
# @overload add_sort_key(target)
|
82
82
|
#
|
83
|
-
# @param
|
84
|
-
# added. See also {Arrow::SortKey#initialize} for the
|
85
|
-
# order mark for String
|
83
|
+
# @param target [Symbol, String] The sort key name or dot path
|
84
|
+
# to be added. See also {Arrow::SortKey#initialize} for the
|
85
|
+
# leading order mark for `String` target.
|
86
86
|
#
|
87
87
|
# @example Add a key to sort by "price" column in descending order
|
88
88
|
# options = Arrow::SortOptions.new
|
89
89
|
# options.add_sort_key("-price")
|
90
90
|
# options.sort_keys.collect(&:to_s) # => ["-price"]
|
91
91
|
#
|
92
|
-
# @overload add_sort_key(
|
92
|
+
# @overload add_sort_key(target, order)
|
93
93
|
#
|
94
|
-
# @param
|
94
|
+
# @param target [Symbol, String] The sort key name or dot path.
|
95
95
|
#
|
96
96
|
# @param order [Symbol, String, Arrow::SortOrder] The sort
|
97
97
|
# order. See {Arrow::SortKey#initialize} for details.
|
@@ -102,8 +102,8 @@ module Arrow
|
|
102
102
|
# options.sort_keys.collect(&:to_s) # => ["-price"]
|
103
103
|
#
|
104
104
|
# @since 4.0.0
|
105
|
-
def add_sort_key(
|
106
|
-
add_sort_key_raw(SortKey.resolve(
|
105
|
+
def add_sort_key(target, order=nil)
|
106
|
+
add_sort_key_raw(SortKey.resolve(target, order))
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
data/lib/arrow/table-loader.rb
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
-
require "uri"
|
18
|
+
require "open-uri"
|
19
19
|
|
20
20
|
module Arrow
|
21
21
|
class TableLoader
|
@@ -34,30 +34,47 @@ module Arrow
|
|
34
34
|
|
35
35
|
def load
|
36
36
|
if @input.is_a?(URI)
|
37
|
-
|
37
|
+
custom_load_method_candidates = []
|
38
|
+
if @input.scheme
|
39
|
+
custom_load_method_candidates << "load_from_uri_#{@input.scheme}"
|
40
|
+
end
|
41
|
+
custom_load_method_candidates << "load_from_uri"
|
38
42
|
elsif @input.is_a?(String) and ::File.directory?(@input)
|
39
|
-
|
43
|
+
custom_load_method_candidates = ["load_from_directory"]
|
40
44
|
else
|
41
|
-
|
45
|
+
custom_load_method_candidates = ["load_from_file"]
|
42
46
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
custom_load_method_candidates.each do |custom_load_method|
|
48
|
+
next unless respond_to?(custom_load_method, true)
|
49
|
+
return __send__(custom_load_method)
|
50
|
+
end
|
51
|
+
available_schemes = []
|
52
|
+
(methods(true) | private_methods(true)).each do |name|
|
53
|
+
match_data = /\Aload_from_/.match(name.to_s)
|
54
|
+
if match_data
|
55
|
+
available_schemes << match_data.post_match
|
50
56
|
end
|
51
|
-
message = "Arrow::Table load source must be one of ["
|
52
|
-
message << available_schemes.join(", ")
|
53
|
-
message << "]: #{@input.inspect}"
|
54
|
-
raise ArgumentError, message
|
55
57
|
end
|
56
|
-
|
58
|
+
message = "Arrow::Table load source must be one of ["
|
59
|
+
message << available_schemes.join(", ")
|
60
|
+
message << "]: #{@input.inspect}"
|
61
|
+
raise ArgumentError, message
|
57
62
|
end
|
58
63
|
|
59
64
|
private
|
65
|
+
def load_from_uri_http
|
66
|
+
load_by_reader
|
67
|
+
end
|
68
|
+
|
69
|
+
def load_from_uri_https
|
70
|
+
load_by_reader
|
71
|
+
end
|
72
|
+
|
60
73
|
def load_from_file
|
74
|
+
load_by_reader
|
75
|
+
end
|
76
|
+
|
77
|
+
def load_by_reader
|
61
78
|
format = @options[:format]
|
62
79
|
custom_load_method = "load_as_#{format}"
|
63
80
|
unless respond_to?(custom_load_method, true)
|
@@ -111,10 +128,29 @@ module Arrow
|
|
111
128
|
end
|
112
129
|
|
113
130
|
def open_input_stream
|
114
|
-
|
115
|
-
|
131
|
+
case @input
|
132
|
+
when Buffer
|
133
|
+
yield(BufferInputStream.new(@input))
|
134
|
+
when URI
|
135
|
+
@input.open do |ruby_input|
|
136
|
+
case @options[:format]
|
137
|
+
when :stream, :arrow_streaming
|
138
|
+
Gio::RubyInputStream.open(ruby_input) do |gio_input|
|
139
|
+
GIOInputStream.open(gio_input) do |input|
|
140
|
+
yield(input)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
else
|
144
|
+
# TODO: We need to consider Ruby's GVL carefully to use
|
145
|
+
# Ruby object directly for input with other formats. We
|
146
|
+
# read data and use it as Buffer for now.
|
147
|
+
data = GLib::Bytes.new(ruby_input.read.freeze)
|
148
|
+
buffer = Buffer.new(data)
|
149
|
+
yield(BufferInputStream.new(buffer))
|
150
|
+
end
|
151
|
+
end
|
116
152
|
else
|
117
|
-
MemoryMappedInputStream.new(@input)
|
153
|
+
yield(MemoryMappedInputStream.new(@input))
|
118
154
|
end
|
119
155
|
end
|
120
156
|
|
@@ -130,32 +166,19 @@ module Arrow
|
|
130
166
|
end
|
131
167
|
|
132
168
|
def load_as_arrow
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
RecordBatchFileReader,
|
138
|
-
RecordBatchStreamReader,
|
139
|
-
]
|
140
|
-
reader_class_candidates.each do |reader_class_candidate|
|
141
|
-
input = open_input_stream
|
142
|
-
begin
|
143
|
-
reader = reader_class_candidate.new(input)
|
144
|
-
rescue Arrow::Error
|
145
|
-
error = $!
|
146
|
-
else
|
147
|
-
break
|
148
|
-
end
|
169
|
+
begin
|
170
|
+
load_as_arrow_file
|
171
|
+
rescue
|
172
|
+
load_as_arrows
|
149
173
|
end
|
150
|
-
raise error if reader.nil?
|
151
|
-
load_raw(input, reader)
|
152
174
|
end
|
153
175
|
|
154
176
|
# @since 1.0.0
|
155
177
|
def load_as_arrow_file
|
156
|
-
|
157
|
-
|
158
|
-
|
178
|
+
open_input_stream do |input|
|
179
|
+
reader = RecordBatchFileReader.new(input)
|
180
|
+
load_raw(input, reader)
|
181
|
+
end
|
159
182
|
end
|
160
183
|
|
161
184
|
# @deprecated Use `format: :arrow_file` instead.
|
@@ -163,34 +186,46 @@ module Arrow
|
|
163
186
|
load_as_arrow_file
|
164
187
|
end
|
165
188
|
|
189
|
+
# @since 7.0.0
|
190
|
+
def load_as_arrows
|
191
|
+
open_input_stream do |input|
|
192
|
+
reader = RecordBatchStreamReader.new(input)
|
193
|
+
load_raw(input, reader)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
166
197
|
# @since 1.0.0
|
167
198
|
def load_as_arrow_streaming
|
168
|
-
|
169
|
-
reader = RecordBatchStreamReader.new(input)
|
170
|
-
load_raw(input, reader)
|
199
|
+
load_as_arrows
|
171
200
|
end
|
172
201
|
|
173
202
|
# @deprecated Use `format: :arrow_streaming` instead.
|
174
203
|
def load_as_stream
|
175
|
-
|
204
|
+
load_as_arrows
|
176
205
|
end
|
177
206
|
|
178
207
|
if Arrow.const_defined?(:ORCFileReader)
|
179
208
|
def load_as_orc
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
209
|
+
open_input_stream do |input|
|
210
|
+
reader = ORCFileReader.new(input)
|
211
|
+
field_indexes = @options[:field_indexes]
|
212
|
+
reader.set_field_indexes(field_indexes) if field_indexes
|
213
|
+
table = reader.read_stripes
|
214
|
+
table.instance_variable_set(:@input, input)
|
215
|
+
table
|
216
|
+
end
|
187
217
|
end
|
188
218
|
end
|
189
219
|
|
190
220
|
def csv_load(options)
|
191
221
|
options.delete(:format)
|
192
|
-
|
222
|
+
case @input
|
223
|
+
when Buffer
|
193
224
|
CSVLoader.load(@input.data.to_s, **options)
|
225
|
+
when URI
|
226
|
+
@input.open do |input|
|
227
|
+
CSVLoader.load(input.read, **options)
|
228
|
+
end
|
194
229
|
else
|
195
230
|
CSVLoader.load(Pathname.new(@input), **options)
|
196
231
|
end
|
@@ -207,19 +242,21 @@ module Arrow
|
|
207
242
|
end
|
208
243
|
|
209
244
|
def load_as_feather
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
245
|
+
open_input_stream do |input|
|
246
|
+
reader = FeatherFileReader.new(input)
|
247
|
+
table = reader.read
|
248
|
+
table.instance_variable_set(:@input, input)
|
249
|
+
table
|
250
|
+
end
|
215
251
|
end
|
216
252
|
|
217
253
|
def load_as_json
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
254
|
+
open_input_stream do |input|
|
255
|
+
reader = JSONReader.new(input)
|
256
|
+
table = reader.read
|
257
|
+
table.instance_variable_set(:@input, input)
|
258
|
+
table
|
259
|
+
end
|
223
260
|
end
|
224
261
|
end
|
225
262
|
end
|
data/lib/arrow/table-saver.rb
CHANGED
@@ -151,14 +151,19 @@ module Arrow
|
|
151
151
|
save_as_arrow_file
|
152
152
|
end
|
153
153
|
|
154
|
+
# @since 7.0.0
|
155
|
+
def save_as_arrows
|
156
|
+
save_raw(RecordBatchStreamWriter)
|
157
|
+
end
|
158
|
+
|
154
159
|
# @since 1.0.0
|
155
160
|
def save_as_arrow_streaming
|
156
|
-
|
161
|
+
save_as_arrows
|
157
162
|
end
|
158
163
|
|
159
164
|
# @deprecated Use `format: :arrow_streaming` instead.
|
160
165
|
def save_as_stream
|
161
|
-
|
166
|
+
save_as_arrows
|
162
167
|
end
|
163
168
|
|
164
169
|
def csv_save(**options)
|