red-arrow 6.0.1 → 9.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/Gemfile +10 -0
- data/ext/arrow/arrow.cpp +12 -0
- data/ext/arrow/converters.hpp +49 -10
- data/ext/arrow/extconf.rb +7 -5
- data/ext/arrow/raw-records.cpp +3 -2
- data/ext/arrow/red-arrow.hpp +7 -0
- data/ext/arrow/values.cpp +3 -2
- data/lib/arrow/array-builder.rb +40 -6
- data/lib/arrow/array-computable.rb +37 -0
- data/lib/arrow/array.rb +16 -0
- data/lib/arrow/chunked-array.rb +21 -0
- data/lib/arrow/column.rb +28 -0
- data/lib/arrow/data-type.rb +2 -1
- data/lib/arrow/datum.rb +2 -0
- data/lib/arrow/day-time-interval-array-builder.rb +29 -0
- data/lib/arrow/decimal128-array-builder.rb +16 -6
- data/lib/arrow/decimal128.rb +14 -0
- data/lib/arrow/decimal256-array-builder.rb +16 -6
- data/lib/arrow/decimal256.rb +14 -0
- data/lib/arrow/field.rb +44 -3
- data/lib/arrow/function.rb +52 -0
- data/lib/arrow/list-data-type.rb +1 -6
- data/lib/arrow/loader.rb +19 -0
- data/lib/arrow/month-day-nano-interval-array-builder.rb +29 -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/string-array-builder.rb +30 -0
- 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/time-unit.rb +31 -0
- data/lib/arrow/time32-array-builder.rb +2 -14
- data/lib/arrow/time32-data-type.rb +9 -38
- data/lib/arrow/time64-array-builder.rb +2 -14
- data/lib/arrow/time64-data-type.rb +9 -38
- data/lib/arrow/timestamp-array-builder.rb +2 -14
- data/lib/arrow/timestamp-data-type.rb +9 -34
- data/lib/arrow/version.rb +1 -1
- data/red-arrow.gemspec +2 -11
- data/test/helper.rb +2 -0
- data/test/raw-records/test-basic-arrays.rb +30 -0
- data/test/raw-records/test-dense-union-array.rb +27 -0
- data/test/raw-records/test-dictionary-array.rb +341 -0
- data/test/raw-records/test-list-array.rb +39 -0
- data/test/raw-records/test-map-array.rb +37 -0
- data/test/raw-records/test-sparse-union-array.rb +27 -0
- data/test/raw-records/test-struct-array.rb +30 -0
- data/test/test-array-builder.rb +62 -0
- data/test/test-chunked-array.rb +6 -0
- data/test/test-column.rb +31 -0
- data/test/test-decimal128-array-builder.rb +14 -0
- data/test/test-decimal128-array.rb +5 -2
- data/test/test-decimal128.rb +26 -2
- data/test/test-decimal256-array-builder.rb +14 -0
- data/test/test-decimal256-array.rb +5 -2
- data/test/test-decimal256.rb +26 -2
- data/test/test-field.rb +26 -0
- data/test/test-function.rb +48 -14
- data/test/test-table.rb +204 -6
- data/test/values/test-basic-arrays.rb +30 -0
- data/test/values/test-dense-union-array.rb +27 -0
- data/test/values/test-dictionary-array.rb +325 -0
- data/test/values/test-list-array.rb +39 -0
- data/test/values/test-map-array.rb +33 -0
- data/test/values/test-sparse-union-array.rb +27 -0
- data/test/values/test-struct-array.rb +30 -0
- metadata +95 -196
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)
|
data/lib/arrow/table.rb
CHANGED
@@ -448,6 +448,84 @@ module Arrow
|
|
448
448
|
self.class.new(schema, packed_arrays)
|
449
449
|
end
|
450
450
|
|
451
|
+
# @overload join(right, key, type: :inner, left_outputs: nil, right_outputs: nil)
|
452
|
+
# @!macro join_common_before
|
453
|
+
# @param right [Arrow::Table] The right table.
|
454
|
+
#
|
455
|
+
# Join columns with `right` on join key columns.
|
456
|
+
#
|
457
|
+
# @!macro join_common_after
|
458
|
+
# @param type [Arrow::JoinType] How to join.
|
459
|
+
# @param left_outputs [::Array<String, Symbol>] Output columns in
|
460
|
+
# `self`.
|
461
|
+
#
|
462
|
+
# If both of `left_outputs` and `right_outputs` aren't
|
463
|
+
# specified, all columns in `self` and `right` are
|
464
|
+
# outputted.
|
465
|
+
# @param right_outputs [::Array<String, Symbol>] Output columns in
|
466
|
+
# `right`.
|
467
|
+
#
|
468
|
+
# If both of `left_outputs` and `right_outputs` aren't
|
469
|
+
# specified, all columns in `self` and `right` are
|
470
|
+
# outputted.
|
471
|
+
# @return [Arrow::Table]
|
472
|
+
# The joined `Arrow::Table`.
|
473
|
+
#
|
474
|
+
# @macro join_common_before
|
475
|
+
# @param key [String, Symbol] A join key.
|
476
|
+
# @macro join_common_after
|
477
|
+
#
|
478
|
+
# @overload join(right, keys, type: :inner, left_outputs: nil, right_outputs: nil)
|
479
|
+
#
|
480
|
+
# @macro join_common_before
|
481
|
+
# @param keys [::Array<String, Symbol>] Join keys.
|
482
|
+
# @macro join_common_after
|
483
|
+
#
|
484
|
+
# @overload join(right, keys, type: :inner, left_outputs: nil, right_outputs: nil)
|
485
|
+
#
|
486
|
+
# @macro join_common_before
|
487
|
+
# @param keys [Hash] Specify join keys in `self` and `right` separately.
|
488
|
+
# @option keys [String, Symbol, ::Array<String, Symbol>] :left
|
489
|
+
# Join keys in `self`.
|
490
|
+
# @option keys [String, Symbol, ::Array<String, Symbol>] :right
|
491
|
+
# Join keys in `right`.
|
492
|
+
# @macro join_common_after
|
493
|
+
#
|
494
|
+
# @since 7.0.0
|
495
|
+
def join(right, keys, type: :inner, left_outputs: nil, right_outputs: nil)
|
496
|
+
plan = ExecutePlan.new
|
497
|
+
left_node = plan.build_source_node(self)
|
498
|
+
right_node = plan.build_source_node(right)
|
499
|
+
if keys.is_a?(Hash)
|
500
|
+
left_keys = keys[:left]
|
501
|
+
right_keys = keys[:right]
|
502
|
+
else
|
503
|
+
left_keys = keys
|
504
|
+
right_keys = keys
|
505
|
+
end
|
506
|
+
left_keys = Array(left_keys)
|
507
|
+
right_keys = Array(right_keys)
|
508
|
+
hash_join_node_options = HashJoinNodeOptions.new(type,
|
509
|
+
left_keys,
|
510
|
+
right_keys)
|
511
|
+
unless left_outputs.nil?
|
512
|
+
hash_join_node_options.left_outputs = left_outputs
|
513
|
+
end
|
514
|
+
unless right_outputs.nil?
|
515
|
+
hash_join_node_options.right_outputs = right_outputs
|
516
|
+
end
|
517
|
+
hash_join_node = plan.build_hash_join_node(left_node,
|
518
|
+
right_node,
|
519
|
+
hash_join_node_options)
|
520
|
+
sink_node_options = SinkNodeOptions.new
|
521
|
+
plan.build_sink_node(hash_join_node, sink_node_options)
|
522
|
+
plan.validate
|
523
|
+
plan.start
|
524
|
+
plan.wait
|
525
|
+
reader = sink_node_options.get_reader(hash_join_node.output_schema)
|
526
|
+
reader.read_all
|
527
|
+
end
|
528
|
+
|
451
529
|
alias_method :to_s_raw, :to_s
|
452
530
|
def to_s(options={})
|
453
531
|
format = options[:format]
|
@@ -0,0 +1,31 @@
|
|
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 TimeUnit
|
20
|
+
class << self
|
21
|
+
# @api private
|
22
|
+
def try_convert(value)
|
23
|
+
if value.is_a?(Hash) and value.size == 1 and value[:unit]
|
24
|
+
super(value[:unit])
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -18,24 +18,12 @@
|
|
18
18
|
module Arrow
|
19
19
|
class Time32ArrayBuilder
|
20
20
|
class << self
|
21
|
-
def build(
|
22
|
-
builder = new(
|
21
|
+
def build(data_type, values)
|
22
|
+
builder = new(data_type)
|
23
23
|
builder.build(values)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
alias_method :initialize_raw, :initialize
|
28
|
-
def initialize(unit_or_data_type)
|
29
|
-
case unit_or_data_type
|
30
|
-
when DataType
|
31
|
-
data_type = unit_or_data_type
|
32
|
-
else
|
33
|
-
unit = unit_or_data_type
|
34
|
-
data_type = Time32DataType.new(unit)
|
35
|
-
end
|
36
|
-
initialize_raw(data_type)
|
37
|
-
end
|
38
|
-
|
39
27
|
def unit
|
40
28
|
@unit ||= value_data_type.unit
|
41
29
|
end
|
@@ -17,45 +17,16 @@
|
|
17
17
|
|
18
18
|
module Arrow
|
19
19
|
class Time32DataType
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
# The unit must be second or millisecond.
|
31
|
-
#
|
32
|
-
# @example Create a time32 data type with Arrow::TimeUnit
|
33
|
-
# Arrow::Time32DataType.new(Arrow::TimeUnit::MILLI)
|
34
|
-
#
|
35
|
-
# @example Create a time32 data type with Symbol
|
36
|
-
# Arrow::Time32DataType.new(:milli)
|
37
|
-
#
|
38
|
-
# @overload initialize(description)
|
39
|
-
#
|
40
|
-
# @param description [Hash] The description of the time32 data
|
41
|
-
# type. It must have `:unit` value.
|
42
|
-
#
|
43
|
-
# @option description [Arrow::TimeUnit, Symbol] :unit The unit of
|
44
|
-
# the time32 data type.
|
45
|
-
#
|
46
|
-
# The unit must be second or millisecond.
|
47
|
-
#
|
48
|
-
# @example Create a time32 data type with Arrow::TimeUnit
|
49
|
-
# Arrow::Time32DataType.new(unit: Arrow::TimeUnit::MILLI)
|
50
|
-
#
|
51
|
-
# @example Create a time32 data type with Symbol
|
52
|
-
# Arrow::Time32DataType.new(unit: :milli)
|
53
|
-
def initialize(unit)
|
54
|
-
if unit.is_a?(Hash)
|
55
|
-
description = unit
|
56
|
-
unit = description[:unit]
|
20
|
+
class << self
|
21
|
+
# @api private
|
22
|
+
def try_convert(value)
|
23
|
+
case value
|
24
|
+
when Symbol, Arrow::TimeUnit
|
25
|
+
new(value)
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
57
29
|
end
|
58
|
-
initialize_raw(unit)
|
59
30
|
end
|
60
31
|
end
|
61
32
|
end
|
@@ -18,24 +18,12 @@
|
|
18
18
|
module Arrow
|
19
19
|
class Time64ArrayBuilder
|
20
20
|
class << self
|
21
|
-
def build(
|
22
|
-
builder = new(
|
21
|
+
def build(data_type, values)
|
22
|
+
builder = new(data_type)
|
23
23
|
builder.build(values)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
alias_method :initialize_raw, :initialize
|
28
|
-
def initialize(unit_or_data_type)
|
29
|
-
case unit_or_data_type
|
30
|
-
when DataType
|
31
|
-
data_type = unit_or_data_type
|
32
|
-
else
|
33
|
-
unit = unit_or_data_type
|
34
|
-
data_type = Time64DataType.new(unit)
|
35
|
-
end
|
36
|
-
initialize_raw(data_type)
|
37
|
-
end
|
38
|
-
|
39
27
|
def unit
|
40
28
|
@unit ||= value_data_type.unit
|
41
29
|
end
|
@@ -17,45 +17,16 @@
|
|
17
17
|
|
18
18
|
module Arrow
|
19
19
|
class Time64DataType
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
# The unit must be microsecond or nanosecond.
|
31
|
-
#
|
32
|
-
# @example Create a time64 data type with Arrow::TimeUnit
|
33
|
-
# Arrow::Time64DataType.new(Arrow::TimeUnit::NANO)
|
34
|
-
#
|
35
|
-
# @example Create a time64 data type with Symbol
|
36
|
-
# Arrow::Time64DataType.new(:nano)
|
37
|
-
#
|
38
|
-
# @overload initialize(description)
|
39
|
-
#
|
40
|
-
# @param description [Hash] The description of the time64 data
|
41
|
-
# type. It must have `:unit` value.
|
42
|
-
#
|
43
|
-
# @option description [Arrow::TimeUnit, Symbol] :unit The unit of
|
44
|
-
# the time64 data type.
|
45
|
-
#
|
46
|
-
# The unit must be microsecond or nanosecond.
|
47
|
-
#
|
48
|
-
# @example Create a time64 data type with Arrow::TimeUnit
|
49
|
-
# Arrow::Time64DataType.new(unit: Arrow::TimeUnit::NANO)
|
50
|
-
#
|
51
|
-
# @example Create a time64 data type with Symbol
|
52
|
-
# Arrow::Time64DataType.new(unit: :nano)
|
53
|
-
def initialize(unit)
|
54
|
-
if unit.is_a?(Hash)
|
55
|
-
description = unit
|
56
|
-
unit = description[:unit]
|
20
|
+
class << self
|
21
|
+
# @api private
|
22
|
+
def try_convert(value)
|
23
|
+
case value
|
24
|
+
when Symbol, Arrow::TimeUnit
|
25
|
+
new(value)
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
57
29
|
end
|
58
|
-
initialize_raw(unit)
|
59
30
|
end
|
60
31
|
end
|
61
32
|
end
|
@@ -18,24 +18,12 @@
|
|
18
18
|
module Arrow
|
19
19
|
class TimestampArrayBuilder
|
20
20
|
class << self
|
21
|
-
def build(
|
22
|
-
builder = new(
|
21
|
+
def build(data_type, values)
|
22
|
+
builder = new(data_type)
|
23
23
|
builder.build(values)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
alias_method :initialize_raw, :initialize
|
28
|
-
def initialize(unit_or_data_type)
|
29
|
-
case unit_or_data_type
|
30
|
-
when DataType
|
31
|
-
data_type = unit_or_data_type
|
32
|
-
else
|
33
|
-
unit = unit_or_data_type
|
34
|
-
data_type = TimestampDataType.new(unit)
|
35
|
-
end
|
36
|
-
initialize_raw(data_type)
|
37
|
-
end
|
38
|
-
|
39
27
|
private
|
40
28
|
def unit_id
|
41
29
|
@unit_id ||= value_data_type.unit.nick.to_sym
|
@@ -17,41 +17,16 @@
|
|
17
17
|
|
18
18
|
module Arrow
|
19
19
|
class TimestampDataType
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
# @example Create a timestamp data type with Arrow::TimeUnit
|
31
|
-
# Arrow::TimestampDataType.new(Arrow::TimeUnit::MILLI)
|
32
|
-
#
|
33
|
-
# @example Create a timestamp data type with Symbol
|
34
|
-
# Arrow::TimestampDataType.new(:milli)
|
35
|
-
#
|
36
|
-
# @overload initialize(description)
|
37
|
-
#
|
38
|
-
# @param description [Hash] The description of the timestamp data
|
39
|
-
# type. It must have `:unit` value.
|
40
|
-
#
|
41
|
-
# @option description [Arrow::TimeUnit, Symbol] :unit The unit of
|
42
|
-
# the timestamp data type.
|
43
|
-
#
|
44
|
-
# @example Create a timestamp data type with Arrow::TimeUnit
|
45
|
-
# Arrow::TimestampDataType.new(unit: Arrow::TimeUnit::MILLI)
|
46
|
-
#
|
47
|
-
# @example Create a timestamp data type with Symbol
|
48
|
-
# Arrow::TimestampDataType.new(unit: :milli)
|
49
|
-
def initialize(unit)
|
50
|
-
if unit.is_a?(Hash)
|
51
|
-
description = unit
|
52
|
-
unit = description[:unit]
|
20
|
+
class << self
|
21
|
+
# @api private
|
22
|
+
def try_convert(value)
|
23
|
+
case value
|
24
|
+
when Symbol, Arrow::TimeUnit
|
25
|
+
new(value)
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
53
29
|
end
|
54
|
-
initialize_raw(unit)
|
55
30
|
end
|
56
31
|
end
|
57
32
|
end
|
data/lib/arrow/version.rb
CHANGED
data/red-arrow.gemspec
CHANGED
@@ -46,21 +46,12 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.test_files += Dir.glob("test/**/*")
|
47
47
|
spec.extensions = ["ext/arrow/extconf.rb"]
|
48
48
|
|
49
|
-
spec.add_runtime_dependency("bigdecimal", ">=
|
49
|
+
spec.add_runtime_dependency("bigdecimal", ">= 3.1.0")
|
50
50
|
spec.add_runtime_dependency("extpp", ">= 0.0.7")
|
51
|
-
spec.add_runtime_dependency("gio2", ">= 3.
|
51
|
+
spec.add_runtime_dependency("gio2", ">= 3.5.0")
|
52
52
|
spec.add_runtime_dependency("native-package-installer")
|
53
53
|
spec.add_runtime_dependency("pkg-config")
|
54
54
|
|
55
|
-
spec.add_development_dependency("benchmark-driver")
|
56
|
-
spec.add_development_dependency("bundler")
|
57
|
-
spec.add_development_dependency("faker")
|
58
|
-
spec.add_development_dependency("fiddle", ">= 1.0.9")
|
59
|
-
spec.add_development_dependency("rake")
|
60
|
-
spec.add_development_dependency("redcarpet")
|
61
|
-
spec.add_development_dependency("test-unit")
|
62
|
-
spec.add_development_dependency("yard")
|
63
|
-
|
64
55
|
required_msys2_package_version = version_components[0, 3].join(".")
|
65
56
|
spec.metadata["msys2_mingw_dependencies"] =
|
66
57
|
"arrow>=#{required_msys2_package_version}"
|