red-arrow 3.0.0 → 4.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 +118 -0
- data/lib/arrow/data-type.rb +14 -5
- data/lib/arrow/dense-union-data-type.rb +2 -2
- data/lib/arrow/dictionary-data-type.rb +2 -2
- data/lib/arrow/loader.rb +2 -0
- data/lib/arrow/sort-key.rb +193 -0
- data/lib/arrow/sort-options.rb +109 -0
- data/lib/arrow/sparse-union-data-type.rb +2 -2
- data/lib/arrow/time32-data-type.rb +2 -2
- data/lib/arrow/time64-data-type.rb +2 -2
- data/lib/arrow/timestamp-data-type.rb +2 -2
- data/lib/arrow/version.rb +1 -1
- data/test/test-array.rb +120 -0
- data/test/test-decimal128-data-type.rb +2 -2
- data/test/test-orc.rb +19 -23
- data/test/test-sort-indices.rb +40 -0
- data/test/test-sort-key.rb +81 -0
- data/test/test-sort-options.rb +58 -0
- metadata +76 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f048aad4d5cc38373c1acc3976ba7012292c2b21315be7334704b6abbd4076fa
|
4
|
+
data.tar.gz: 426aac582a879286bd8f6ae632f4851bcc00025a08032142f07073fd4c665c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f7ab5ce2884d205b7d498db7f74d50c9c6228a4c27de8638fb921535c71fed28aa69ffdcb55bc27300e8b5995d5f31b0e78a29b2bd0513fcbf60d1514a58f79
|
7
|
+
data.tar.gz: b6d28706fb0b4845c2b134e22f4988199e8714bf41e24a73d02b38a6161142ad04c7ebf30185791afb3c3a0b7a02701e92193b6ae55ff1e78089d60f3ca91c9a
|
data/lib/arrow/array.rb
CHANGED
@@ -100,5 +100,123 @@ module Arrow
|
|
100
100
|
is_in_raw(values)
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
# @api private
|
105
|
+
alias_method :concatenate_raw, :concatenate
|
106
|
+
# Concatenates the given other arrays to the array.
|
107
|
+
#
|
108
|
+
# @param other_arrays [::Array, Arrow::Array] The arrays to be
|
109
|
+
# concatenated.
|
110
|
+
#
|
111
|
+
# Each other array is processed by {#resolve} before they're
|
112
|
+
# concatenated.
|
113
|
+
#
|
114
|
+
# @example Raw Ruby Array
|
115
|
+
# array = Arrow::Int32Array.new([1])
|
116
|
+
# array.concatenate([2, 3], [4]) # => Arrow::Int32Array.new([1, 2, 3, 4])
|
117
|
+
#
|
118
|
+
# @example Arrow::Array
|
119
|
+
# array = Arrow::Int32Array.new([1])
|
120
|
+
# array.concatenate(Arrow::Int32Array.new([2, 3]),
|
121
|
+
# Arrow::Int8Array.new([4])) # => Arrow::Int32Array.new([1, 2, 3, 4])
|
122
|
+
#
|
123
|
+
# @since 4.0.0
|
124
|
+
def concatenate(*other_arrays)
|
125
|
+
other_arrays = other_arrays.collect do |other_array|
|
126
|
+
resolve(other_array)
|
127
|
+
end
|
128
|
+
concatenate_raw(other_arrays)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Concatenates the given other array to the array.
|
132
|
+
#
|
133
|
+
# If you have multiple arrays to be concatenated, you should use
|
134
|
+
# {#concatenate} to concatenate multiple arrays at once.
|
135
|
+
#
|
136
|
+
# @param other_array [::Array, Arrow::Array] The array to be concatenated.
|
137
|
+
#
|
138
|
+
# `@other_array` is processed by {#resolve} before it's
|
139
|
+
# concatenated.
|
140
|
+
#
|
141
|
+
# @example Raw Ruby Array
|
142
|
+
# Arrow::Int32Array.new([1]) + [2, 3] # => Arrow::Int32Array.new([1, 2, 3])
|
143
|
+
#
|
144
|
+
# @example Arrow::Array
|
145
|
+
# Arrow::Int32Array.new([1]) +
|
146
|
+
# Arrow::Int32Array.new([2, 3]) # => Arrow::Int32Array.new([1, 2, 3])
|
147
|
+
#
|
148
|
+
# @since 4.0.0
|
149
|
+
def +(other_array)
|
150
|
+
concatenate(other_array)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Ensures returning the same data type array from the given array.
|
154
|
+
#
|
155
|
+
# @return [Arrow::Array]
|
156
|
+
#
|
157
|
+
# @overload resolve(other_raw_array)
|
158
|
+
#
|
159
|
+
# @param other_raw_array [::Array] A raw Ruby Array. A new Arrow::Array
|
160
|
+
# is built by `self.class.new`.
|
161
|
+
#
|
162
|
+
# @example Raw Ruby Array
|
163
|
+
# int32_array = Arrow::Int32Array.new([1])
|
164
|
+
# other_array = int32_array.resolve([2, 3, 4])
|
165
|
+
# other_array # => Arrow::Int32Array.new([2, 3, 4])
|
166
|
+
#
|
167
|
+
# @overload resolve(other_array)
|
168
|
+
#
|
169
|
+
# @param other_array [Arrow::Array] Another Arrow::Array.
|
170
|
+
#
|
171
|
+
# If the given other array is an same data type array of
|
172
|
+
# `self`, the given other array is returned as-is.
|
173
|
+
#
|
174
|
+
# If the given other array isn't an same data type array of
|
175
|
+
# `self`, the given other array is casted.
|
176
|
+
#
|
177
|
+
# @example Same data type
|
178
|
+
# int32_array = Arrow::Int32Array.new([1])
|
179
|
+
# other_int32_array = Arrow::Int32Array.new([2, 3, 4])
|
180
|
+
# other_array = int32_array.resolve(other_int32_array)
|
181
|
+
# other_array.object_id == other_int32_array.object_id
|
182
|
+
#
|
183
|
+
# @example Other data type
|
184
|
+
# int32_array = Arrow::Int32Array.new([1])
|
185
|
+
# other_int8_array = Arrow::Int8Array.new([2, 3, 4])
|
186
|
+
# other_array = int32_array.resolve(other_int32_array)
|
187
|
+
# other_array #=> Arrow::Int32Array.new([2, 3, 4])
|
188
|
+
#
|
189
|
+
# @since 4.0.0
|
190
|
+
def resolve(other_array)
|
191
|
+
if other_array.is_a?(::Array)
|
192
|
+
builder_class = self.class.builder_class
|
193
|
+
if builder_class.nil?
|
194
|
+
message =
|
195
|
+
"[array][resolve] can't build #{value_data_type} array " +
|
196
|
+
"from raw Ruby Array"
|
197
|
+
raise ArgumentError, message
|
198
|
+
end
|
199
|
+
if builder_class.buildable?([other_array])
|
200
|
+
other_array = builder_class.build(other_array)
|
201
|
+
elsif builder_class.buildable?([value_data_type, other_array])
|
202
|
+
other_array = builder_class.build(value_data_type, other_array)
|
203
|
+
else
|
204
|
+
message =
|
205
|
+
"[array][resolve] need to implement " +
|
206
|
+
"a feature that building #{value_data_type} array " +
|
207
|
+
"from raw Ruby Array"
|
208
|
+
raise NotImpelemented, message
|
209
|
+
end
|
210
|
+
other_array
|
211
|
+
elsif other_array.respond_to?(:value_data_type)
|
212
|
+
return other_array if value_data_type == other_array.value_data_type
|
213
|
+
other_array.cast(value_data_type)
|
214
|
+
else
|
215
|
+
message =
|
216
|
+
"[array][resolve] can't build #{value_data_type} array: " +
|
217
|
+
"#{other_array.inspect}"
|
218
|
+
raise ArgumentError, message
|
219
|
+
end
|
220
|
+
end
|
103
221
|
end
|
104
222
|
end
|
data/lib/arrow/data-type.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
module Arrow
|
19
19
|
class DataType
|
20
20
|
class << self
|
21
|
-
#
|
21
|
+
# Ensure returning suitable {Arrow::DataType}.
|
22
22
|
#
|
23
23
|
# @overload resolve(data_type)
|
24
24
|
#
|
@@ -31,17 +31,21 @@ module Arrow
|
|
31
31
|
#
|
32
32
|
# @overload resolve(name)
|
33
33
|
#
|
34
|
-
# Creates a suitable data type from type name. For
|
35
|
-
# you can create {Arrow::BooleanDataType} from
|
34
|
+
# Creates a suitable data type from the given type name. For
|
35
|
+
# example, you can create {Arrow::BooleanDataType} from
|
36
|
+
# `:boolean`.
|
36
37
|
#
|
37
38
|
# @param name [String, Symbol] The type name of the data type.
|
38
39
|
#
|
40
|
+
# @return [Arrow::DataType] A new suitable data type.
|
41
|
+
#
|
39
42
|
# @example Create a boolean data type
|
40
43
|
# Arrow::DataType.resolve(:boolean)
|
41
44
|
#
|
42
45
|
# @overload resolve(name_with_arguments)
|
43
46
|
#
|
44
|
-
# Creates a suitable data type from type name
|
47
|
+
# Creates a new suitable data type from the given type name
|
48
|
+
# with arguments.
|
45
49
|
#
|
46
50
|
# @param name_with_arguments [::Array<String, ...>]
|
47
51
|
# The type name of the data type as the first element.
|
@@ -51,6 +55,8 @@ module Arrow
|
|
51
55
|
# For example, {Arrow::TimestampDataType} needs unit as
|
52
56
|
# additional information.
|
53
57
|
#
|
58
|
+
# @return [Arrow::DataType] A new suitable data type.
|
59
|
+
#
|
54
60
|
# @example Create a boolean data type
|
55
61
|
# Arrow::DataType.resolve([:boolean])
|
56
62
|
#
|
@@ -59,7 +65,8 @@ module Arrow
|
|
59
65
|
#
|
60
66
|
# @overload resolve(description)
|
61
67
|
#
|
62
|
-
# Creates a suitable data type from data type
|
68
|
+
# Creates a new suitable data type from the given data type
|
69
|
+
# description.
|
63
70
|
#
|
64
71
|
# Data type description is a raw `Hash`. Data type description
|
65
72
|
# must have `:type` value. `:type` is the type of the data type.
|
@@ -74,6 +81,8 @@ module Arrow
|
|
74
81
|
# @option description [String, Symbol] :type The type name of
|
75
82
|
# the data type.
|
76
83
|
#
|
84
|
+
# @return [Arrow::DataType] A new suitable data type.
|
85
|
+
#
|
77
86
|
# @example Create a boolean data type
|
78
87
|
# Arrow::DataType.resolve(type: :boolean)
|
79
88
|
#
|
@@ -33,7 +33,7 @@ module Arrow
|
|
33
33
|
# @param type_codes [::Array<Integer>] The IDs that indicates
|
34
34
|
# corresponding fields.
|
35
35
|
#
|
36
|
-
# @example Create a dense union data type for {2: visible, 9: count}
|
36
|
+
# @example Create a dense union data type for `{2: visible, 9: count}`
|
37
37
|
# fields = [
|
38
38
|
# Arrow::Field.new("visible", :boolean),
|
39
39
|
# {
|
@@ -57,7 +57,7 @@ module Arrow
|
|
57
57
|
# @option description [::Array<Integer>] :type_codes The IDs
|
58
58
|
# that indicates corresponding fields.
|
59
59
|
#
|
60
|
-
# @example Create a dense union data type for {2: visible, 9: count}
|
60
|
+
# @example Create a dense union data type for `{2: visible, 9: count}`
|
61
61
|
# fields = [
|
62
62
|
# Arrow::Field.new("visible", :boolean),
|
63
63
|
# {
|
@@ -50,7 +50,7 @@ module Arrow
|
|
50
50
|
# @param ordered [Boolean] Whether dictionary contents are
|
51
51
|
# ordered or not.
|
52
52
|
#
|
53
|
-
# @example Create a dictionary data type for {0: "Hello", 1: "World"}
|
53
|
+
# @example Create a dictionary data type for `{0: "Hello", 1: "World"}`
|
54
54
|
# index_data_type = :int8
|
55
55
|
# value_data_type = :string
|
56
56
|
# ordered = true
|
@@ -91,7 +91,7 @@ module Arrow
|
|
91
91
|
# @option description [Boolean] :ordered Whether dictionary
|
92
92
|
# contents are ordered or not.
|
93
93
|
#
|
94
|
-
# @example Create a dictionary data type for {0: "Hello", 1: "World"}
|
94
|
+
# @example Create a dictionary data type for `{0: "Hello", 1: "World"}`
|
95
95
|
# Arrow::DictionaryDataType.new(index_data_type: :int8,
|
96
96
|
# value_data_type: :string,
|
97
97
|
# ordered: true)
|
data/lib/arrow/loader.rb
CHANGED
@@ -82,6 +82,8 @@ module Arrow
|
|
82
82
|
require "arrow/rolling-window"
|
83
83
|
require "arrow/schema"
|
84
84
|
require "arrow/slicer"
|
85
|
+
require "arrow/sort-key"
|
86
|
+
require "arrow/sort-options"
|
85
87
|
require "arrow/sparse-union-data-type"
|
86
88
|
require "arrow/struct-array"
|
87
89
|
require "arrow/struct-array-builder"
|
@@ -0,0 +1,193 @@
|
|
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 SortKey
|
20
|
+
class << self
|
21
|
+
# Ensure returning suitable {Arrow::SortKey}.
|
22
|
+
#
|
23
|
+
# @overload resolve(sort_key)
|
24
|
+
#
|
25
|
+
# Returns the given sort key itself. This is convenient to use
|
26
|
+
# this method as {Arrow::SortKey} converter.
|
27
|
+
#
|
28
|
+
# @param sort_key [Arrow::SortKey] The sort key.
|
29
|
+
#
|
30
|
+
# @return [Arrow::SortKey] The given sort key itself.
|
31
|
+
#
|
32
|
+
# @overload resolve(name)
|
33
|
+
#
|
34
|
+
# Creates a new suitable sort key from column name with
|
35
|
+
# leading order mark. See {#initialize} for details about
|
36
|
+
# order mark.
|
37
|
+
#
|
38
|
+
# @return [Arrow::SortKey] A new suitable sort key.
|
39
|
+
#
|
40
|
+
# @overload resolve(name, order)
|
41
|
+
#
|
42
|
+
# Creates a new suitable sort key from column name without
|
43
|
+
# leading order mark and order. See {#initialize} for details.
|
44
|
+
#
|
45
|
+
# @return [Arrow::SortKey] A new suitable sort key.
|
46
|
+
#
|
47
|
+
# @since 4.0.0
|
48
|
+
def resolve(name, order=nil)
|
49
|
+
return name if name.is_a?(self)
|
50
|
+
new(name, order)
|
51
|
+
end
|
52
|
+
|
53
|
+
# @api private
|
54
|
+
def try_convert(value)
|
55
|
+
case value
|
56
|
+
when Symbol, String
|
57
|
+
new(value.to_s, :ascending)
|
58
|
+
else
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
alias_method :initialize_raw, :initialize
|
65
|
+
private :initialize_raw
|
66
|
+
# Creates a new {Arrow::SortKey}.
|
67
|
+
#
|
68
|
+
# @overload initialize(name)
|
69
|
+
#
|
70
|
+
# @param name [Symbol, String] The name of the sort column.
|
71
|
+
#
|
72
|
+
# If `name` is a String, the first character may be processed
|
73
|
+
# as the "leading order mark". If the first character is `"+"`
|
74
|
+
# or `"-"`, they are processed as a leading order mark. If the
|
75
|
+
# first character is processed as a leading order mark, the
|
76
|
+
# first character is removed from sort column name and
|
77
|
+
# corresponding order is used. `"+"` uses ascending order and
|
78
|
+
# `"-"` uses ascending order.
|
79
|
+
#
|
80
|
+
# If `name` is not a String nor `name` doesn't start with the
|
81
|
+
# leading order mark, sort column name is `name` as-is and
|
82
|
+
# ascending order is used.
|
83
|
+
#
|
84
|
+
# @example String without the leading order mark
|
85
|
+
# key = Arrow::SortKey.new("count")
|
86
|
+
# key.name # => "count"
|
87
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
88
|
+
#
|
89
|
+
# @example String with the "+" leading order mark
|
90
|
+
# key = Arrow::SortKey.new("+count")
|
91
|
+
# key.name # => "count"
|
92
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
93
|
+
#
|
94
|
+
# @example String with the "-" leading order mark
|
95
|
+
# key = Arrow::SortKey.new("-count")
|
96
|
+
# key.name # => "count"
|
97
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
98
|
+
#
|
99
|
+
# @example Symbol that starts with "-"
|
100
|
+
# key = Arrow::SortKey.new(:"-count")
|
101
|
+
# key.name # => "-count"
|
102
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
103
|
+
#
|
104
|
+
# @overload initialize(name, order)
|
105
|
+
#
|
106
|
+
# @param name [Symbol, String] The name of the sort column.
|
107
|
+
#
|
108
|
+
# No leading order mark processing. The given `name` is used
|
109
|
+
# as-is.
|
110
|
+
#
|
111
|
+
# @param order [Symbol, String, Arrow::SortOrder] How to order
|
112
|
+
# by this sort key.
|
113
|
+
#
|
114
|
+
# If this is a Symbol or String, this must be `:ascending`,
|
115
|
+
# `"ascending"`, `:asc`, `"asc"`, `:descending`,
|
116
|
+
# `"descending"`, `:desc` or `"desc"`.
|
117
|
+
#
|
118
|
+
# @example No leading order mark processing
|
119
|
+
# key = Arrow::SortKey.new("-count", :ascending)
|
120
|
+
# key.name # => "-count"
|
121
|
+
# key.order # => Arrow::SortOrder::ASCENDING
|
122
|
+
#
|
123
|
+
# @example Order by abbreviated name with Symbol
|
124
|
+
# key = Arrow::SortKey.new("count", :desc)
|
125
|
+
# key.name # => "count"
|
126
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
127
|
+
#
|
128
|
+
# @example Order by String
|
129
|
+
# key = Arrow::SortKey.new("count", "descending")
|
130
|
+
# key.name # => "count"
|
131
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
132
|
+
#
|
133
|
+
# @example Order by Arrow::SortOrder
|
134
|
+
# key = Arrow::SortKey.new("count", Arrow::SortOrder::DESCENDING)
|
135
|
+
# key.name # => "count"
|
136
|
+
# key.order # => Arrow::SortOrder::DESCENDING
|
137
|
+
#
|
138
|
+
# @since 4.0.0
|
139
|
+
def initialize(name, order=nil)
|
140
|
+
name, order = normalize_name(name, order)
|
141
|
+
order = normalize_order(order) || :ascending
|
142
|
+
initialize_raw(name, order)
|
143
|
+
end
|
144
|
+
|
145
|
+
# @return [String] The string representation of this sort key. You
|
146
|
+
# can use recreate {Arrow::SortKey} by
|
147
|
+
# `Arrow::SortKey.new(key.to_s)`.
|
148
|
+
#
|
149
|
+
# @example Recreate Arrow::SortKey
|
150
|
+
# key = Arrow::SortKey.new("-count")
|
151
|
+
# key.to_s # => "-count"
|
152
|
+
# key == Arrow::SortKey.new(key.to_s) # => true
|
153
|
+
#
|
154
|
+
# @since 4.0.0
|
155
|
+
def to_s
|
156
|
+
if order == SortOrder::ASCENDING
|
157
|
+
"+#{name}"
|
158
|
+
else
|
159
|
+
"-#{name}"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
def normalize_name(name, order)
|
165
|
+
case name
|
166
|
+
when Symbol
|
167
|
+
return name.to_s, order
|
168
|
+
when String
|
169
|
+
return name, order if order
|
170
|
+
if name.start_with?("-")
|
171
|
+
return name[1..-1], order || :descending
|
172
|
+
elsif name.start_with?("+")
|
173
|
+
return name[1..-1], order || :ascending
|
174
|
+
else
|
175
|
+
return name, order
|
176
|
+
end
|
177
|
+
else
|
178
|
+
return name, order
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def normalize_order(order)
|
183
|
+
case order
|
184
|
+
when :asc, "asc"
|
185
|
+
:ascending
|
186
|
+
when :desc, "desc"
|
187
|
+
:descending
|
188
|
+
else
|
189
|
+
order
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,109 @@
|
|
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 SortOptions
|
20
|
+
class << self
|
21
|
+
# @api private
|
22
|
+
def try_convert(value)
|
23
|
+
case value
|
24
|
+
when Symbol, String
|
25
|
+
new(value)
|
26
|
+
when ::Array
|
27
|
+
new(*value)
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
alias_method :initialize_raw, :initialize
|
35
|
+
private :initialize_raw
|
36
|
+
# @param sort_keys [::Array<String, Symbol, Arrow::SortKey>] The
|
37
|
+
# sort keys to be used. See {Arrow::SortKey.resolve} how to
|
38
|
+
# resolve each sort key in `sort_keys`.
|
39
|
+
#
|
40
|
+
# You can add more sort keys by {#add_sort_key} later.
|
41
|
+
#
|
42
|
+
# @example No initial sort keys
|
43
|
+
# options = Arrow::SortOptions.new
|
44
|
+
# options.sort_keys # => []
|
45
|
+
#
|
46
|
+
# @example String sort keys
|
47
|
+
# options = Arrow::SortOptions.new("count", "-age")
|
48
|
+
# options.sort_keys.collect(&:to_s) # => ["+count", "-age"]
|
49
|
+
#
|
50
|
+
# @example Symbol sort keys
|
51
|
+
# options = Arrow::SortOptions.new(:count, :age)
|
52
|
+
# options.sort_keys.collect(&:to_s) # => ["+count", "+age"]
|
53
|
+
#
|
54
|
+
# @example Mixed sort keys
|
55
|
+
# options = Arrow::SortOptions.new(:count, "-age")
|
56
|
+
# options.sort_keys.collect(&:to_s) # => ["+count", "-age"]
|
57
|
+
#
|
58
|
+
# @since 4.0.0
|
59
|
+
def initialize(*sort_keys)
|
60
|
+
initialize_raw
|
61
|
+
sort_keys.each do |sort_key|
|
62
|
+
add_sort_key(sort_key)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# @api private
|
67
|
+
alias_method :add_sort_key_raw, :add_sort_key
|
68
|
+
# Add a sort key.
|
69
|
+
#
|
70
|
+
# @return [void]
|
71
|
+
#
|
72
|
+
# @overload add_sort_key(key)
|
73
|
+
#
|
74
|
+
# @param key [Arrow::SortKey] The sort key to be added.
|
75
|
+
#
|
76
|
+
# @example Add a key to sort by "price" column in descending order
|
77
|
+
# options = Arrow::SortOptions.new
|
78
|
+
# options.add_sort_key(Arrow::SortKey.new(:price, :descending))
|
79
|
+
# options.sort_keys.collect(&:to_s) # => ["-price"]
|
80
|
+
#
|
81
|
+
# @overload add_sort_key(name)
|
82
|
+
#
|
83
|
+
# @param name [Symbol, String] The sort key name to be
|
84
|
+
# added. See also {Arrow::SortKey#initialize} for the leading
|
85
|
+
# order mark for String name.
|
86
|
+
#
|
87
|
+
# @example Add a key to sort by "price" column in descending order
|
88
|
+
# options = Arrow::SortOptions.new
|
89
|
+
# options.add_sort_key("-price")
|
90
|
+
# options.sort_keys.collect(&:to_s) # => ["-price"]
|
91
|
+
#
|
92
|
+
# @overload add_sort_key(name, order)
|
93
|
+
#
|
94
|
+
# @param name [Symbol, String] The sort key name.
|
95
|
+
#
|
96
|
+
# @param order [Symbol, String, Arrow::SortOrder] The sort
|
97
|
+
# order. See {Arrow::SortKey#initialize} for details.
|
98
|
+
#
|
99
|
+
# @example Add a key to sort by "price" column in descending order
|
100
|
+
# options = Arrow::SortOptions.new
|
101
|
+
# options.add_sort_key("price", :desc)
|
102
|
+
# options.sort_keys.collect(&:to_s) # => ["-price"]
|
103
|
+
#
|
104
|
+
# @since 4.0.0
|
105
|
+
def add_sort_key(name, order=nil)
|
106
|
+
add_sort_key_raw(SortKey.resolve(name, order))
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -33,7 +33,7 @@ module Arrow
|
|
33
33
|
# @param type_codes [::Array<Integer>] The IDs that indicates
|
34
34
|
# corresponding fields.
|
35
35
|
#
|
36
|
-
# @example Create a sparse union data type for {2: visible, 9: count}
|
36
|
+
# @example Create a sparse union data type for `{2: visible, 9: count}`
|
37
37
|
# fields = [
|
38
38
|
# Arrow::Field.new("visible", :boolean),
|
39
39
|
# {
|
@@ -57,7 +57,7 @@ module Arrow
|
|
57
57
|
# @option description [::Array<Integer>] :type_codes The IDs
|
58
58
|
# that indicates corresponding fields.
|
59
59
|
#
|
60
|
-
# @example Create a sparse union data type for {2: visible, 9: count}
|
60
|
+
# @example Create a sparse union data type for `{2: visible, 9: count}`
|
61
61
|
# fields = [
|
62
62
|
# Arrow::Field.new("visible", :boolean),
|
63
63
|
# {
|
@@ -29,7 +29,7 @@ module Arrow
|
|
29
29
|
#
|
30
30
|
# The unit must be second or millisecond.
|
31
31
|
#
|
32
|
-
# @example Create a time32 data type with
|
32
|
+
# @example Create a time32 data type with Arrow::TimeUnit
|
33
33
|
# Arrow::Time32DataType.new(Arrow::TimeUnit::MILLI)
|
34
34
|
#
|
35
35
|
# @example Create a time32 data type with Symbol
|
@@ -45,7 +45,7 @@ module Arrow
|
|
45
45
|
#
|
46
46
|
# The unit must be second or millisecond.
|
47
47
|
#
|
48
|
-
# @example Create a time32 data type with
|
48
|
+
# @example Create a time32 data type with Arrow::TimeUnit
|
49
49
|
# Arrow::Time32DataType.new(unit: Arrow::TimeUnit::MILLI)
|
50
50
|
#
|
51
51
|
# @example Create a time32 data type with Symbol
|
@@ -29,7 +29,7 @@ module Arrow
|
|
29
29
|
#
|
30
30
|
# The unit must be microsecond or nanosecond.
|
31
31
|
#
|
32
|
-
# @example Create a time64 data type with
|
32
|
+
# @example Create a time64 data type with Arrow::TimeUnit
|
33
33
|
# Arrow::Time64DataType.new(Arrow::TimeUnit::NANO)
|
34
34
|
#
|
35
35
|
# @example Create a time64 data type with Symbol
|
@@ -45,7 +45,7 @@ module Arrow
|
|
45
45
|
#
|
46
46
|
# The unit must be microsecond or nanosecond.
|
47
47
|
#
|
48
|
-
# @example Create a time64 data type with
|
48
|
+
# @example Create a time64 data type with Arrow::TimeUnit
|
49
49
|
# Arrow::Time64DataType.new(unit: Arrow::TimeUnit::NANO)
|
50
50
|
#
|
51
51
|
# @example Create a time64 data type with Symbol
|
@@ -27,7 +27,7 @@ module Arrow
|
|
27
27
|
# @param unit [Arrow::TimeUnit, Symbol] The unit of the
|
28
28
|
# timestamp data type.
|
29
29
|
#
|
30
|
-
# @example Create a timestamp data type with
|
30
|
+
# @example Create a timestamp data type with Arrow::TimeUnit
|
31
31
|
# Arrow::TimestampDataType.new(Arrow::TimeUnit::MILLI)
|
32
32
|
#
|
33
33
|
# @example Create a timestamp data type with Symbol
|
@@ -41,7 +41,7 @@ module Arrow
|
|
41
41
|
# @option description [Arrow::TimeUnit, Symbol] :unit The unit of
|
42
42
|
# the timestamp data type.
|
43
43
|
#
|
44
|
-
# @example Create a timestamp data type with
|
44
|
+
# @example Create a timestamp data type with Arrow::TimeUnit
|
45
45
|
# Arrow::TimestampDataType.new(unit: Arrow::TimeUnit::MILLI)
|
46
46
|
#
|
47
47
|
# @example Create a timestamp data type with Symbol
|
data/lib/arrow/version.rb
CHANGED
data/test/test-array.rb
CHANGED
@@ -168,4 +168,124 @@ class ArrayTest < Test::Unit::TestCase
|
|
168
168
|
@array.is_in(right))
|
169
169
|
end
|
170
170
|
end
|
171
|
+
|
172
|
+
sub_test_case("#concatenate") do
|
173
|
+
test("Arrow::Array: same") do
|
174
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
175
|
+
Arrow::Int32Array.new([1, 2, nil]).
|
176
|
+
concatenate(Arrow::Int32Array.new([4, 5]),
|
177
|
+
Arrow::Int32Array.new([6])))
|
178
|
+
end
|
179
|
+
|
180
|
+
test("Arrow::Array: castable") do
|
181
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
182
|
+
Arrow::Int32Array.new([1, 2, nil]).
|
183
|
+
concatenate(Arrow::Int8Array.new([4, 5]),
|
184
|
+
Arrow::UInt32Array.new([6])))
|
185
|
+
end
|
186
|
+
|
187
|
+
test("Arrow::Array: non-castable") do
|
188
|
+
assert_raise(Arrow::Error::Invalid) do
|
189
|
+
Arrow::Int32Array.new([1, 2, nil]).
|
190
|
+
concatenate(Arrow::StringArray.new(["X"]))
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
test("Array") do
|
195
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,nil, 6]),
|
196
|
+
Arrow::Int32Array.new([1, 2, nil]).
|
197
|
+
concatenate([4, nil],
|
198
|
+
[6]))
|
199
|
+
end
|
200
|
+
|
201
|
+
test("invalid") do
|
202
|
+
message = "[array][resolve] can't build int32 array: 4"
|
203
|
+
assert_raise(ArgumentError.new(message)) do
|
204
|
+
Arrow::Int32Array.new([1, 2, nil]).
|
205
|
+
concatenate(4)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
sub_test_case("#+") do
|
211
|
+
test("Arrow::Array: same") do
|
212
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
213
|
+
Arrow::Int32Array.new([1, 2, nil]) +
|
214
|
+
Arrow::Int32Array.new([4, 5, 6]))
|
215
|
+
end
|
216
|
+
|
217
|
+
test("Arrow::Array: castable") do
|
218
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,5, 6]),
|
219
|
+
Arrow::Int32Array.new([1, 2, nil]) +
|
220
|
+
Arrow::Int8Array.new([4, 5, 6]))
|
221
|
+
end
|
222
|
+
|
223
|
+
test("Arrow::Array: non-castable") do
|
224
|
+
assert_raise(Arrow::Error::Invalid) do
|
225
|
+
Arrow::Int32Array.new([1, 2, nil]) +
|
226
|
+
Arrow::StringArray.new(["X"])
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
test("Array") do
|
231
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil, 4 ,nil, 6]),
|
232
|
+
Arrow::Int32Array.new([1, 2, nil]) +
|
233
|
+
[4, nil, 6])
|
234
|
+
end
|
235
|
+
|
236
|
+
test("invalid") do
|
237
|
+
message = "[array][resolve] can't build int32 array: 4"
|
238
|
+
assert_raise(ArgumentError.new(message)) do
|
239
|
+
Arrow::Int32Array.new([1, 2, nil]) + 4
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
sub_test_case("#resolve") do
|
245
|
+
test("Arrow::Array: same") do
|
246
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil]),
|
247
|
+
Arrow::Int32Array.new([]).
|
248
|
+
resolve(Arrow::Int32Array.new([1, 2, nil])))
|
249
|
+
end
|
250
|
+
|
251
|
+
test("Arrow::Array: castable") do
|
252
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil]),
|
253
|
+
Arrow::Int32Array.new([]).
|
254
|
+
resolve(Arrow::Int8Array.new([1, 2, nil])))
|
255
|
+
end
|
256
|
+
|
257
|
+
test("Arrow::Array: non-castable") do
|
258
|
+
assert_raise(Arrow::Error::Invalid) do
|
259
|
+
Arrow::Int32Array.new([]) +
|
260
|
+
Arrow::StringArray.new(["X"])
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
test("Array: non-parametric") do
|
265
|
+
assert_equal(Arrow::Int32Array.new([1, 2, nil]),
|
266
|
+
Arrow::Int32Array.new([]).
|
267
|
+
resolve([1, 2, nil]))
|
268
|
+
end
|
269
|
+
|
270
|
+
test("Array: parametric") do
|
271
|
+
list_data_type = Arrow::ListDataType.new(name: "visible", type: :boolean)
|
272
|
+
list_array = Arrow::ListArray.new(list_data_type, [])
|
273
|
+
assert_equal(Arrow::ListArray.new(list_data_type,
|
274
|
+
[
|
275
|
+
[true, false],
|
276
|
+
nil,
|
277
|
+
]),
|
278
|
+
list_array.resolve([
|
279
|
+
[true, false],
|
280
|
+
nil,
|
281
|
+
]))
|
282
|
+
end
|
283
|
+
|
284
|
+
test("invalid") do
|
285
|
+
message = "[array][resolve] can't build int32 array: 4"
|
286
|
+
assert_raise(ArgumentError.new(message)) do
|
287
|
+
Arrow::Int32Array.new([]).resolve(4)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
171
291
|
end
|
@@ -18,12 +18,12 @@
|
|
18
18
|
class Decimal128DataTypeTest < Test::Unit::TestCase
|
19
19
|
sub_test_case(".new") do
|
20
20
|
test("ordered arguments") do
|
21
|
-
assert_equal("
|
21
|
+
assert_equal("decimal128(8, 2)",
|
22
22
|
Arrow::Decimal128DataType.new(8, 2).to_s)
|
23
23
|
end
|
24
24
|
|
25
25
|
test("description") do
|
26
|
-
assert_equal("
|
26
|
+
assert_equal("decimal128(8, 2)",
|
27
27
|
Arrow::Decimal128DataType.new(precision: 8,
|
28
28
|
scale: 2).to_s)
|
29
29
|
end
|
data/test/test-orc.rb
CHANGED
@@ -118,39 +118,35 @@ class ORCTest < Test::Unit::TestCase
|
|
118
118
|
]
|
119
119
|
],
|
120
120
|
[
|
121
|
-
"map:
|
122
|
-
"struct<key: string, value: " +
|
123
|
-
"struct<int1: int32, string1: string>>>",
|
121
|
+
"map: map<string, struct<int1: int32, string1: string>>",
|
124
122
|
[
|
125
123
|
<<-MAP.chomp
|
126
124
|
[
|
125
|
+
keys:
|
126
|
+
[]
|
127
|
+
values:
|
127
128
|
-- is_valid: all not null
|
128
|
-
-- child 0 type:
|
129
|
+
-- child 0 type: int32
|
129
130
|
[]
|
130
|
-
-- child 1 type:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
-- child 1 type: string
|
132
|
+
[],
|
133
|
+
keys:
|
134
|
+
[
|
135
|
+
"chani",
|
136
|
+
"mauddib"
|
137
|
+
]
|
138
|
+
values:
|
136
139
|
-- is_valid: all not null
|
137
|
-
-- child 0 type:
|
140
|
+
-- child 0 type: int32
|
141
|
+
[
|
142
|
+
5,
|
143
|
+
1
|
144
|
+
]
|
145
|
+
-- child 1 type: string
|
138
146
|
[
|
139
147
|
"chani",
|
140
148
|
"mauddib"
|
141
149
|
]
|
142
|
-
-- child 1 type: struct<int1: int32, string1: string>
|
143
|
-
-- is_valid: all not null
|
144
|
-
-- child 0 type: int32
|
145
|
-
[
|
146
|
-
5,
|
147
|
-
1
|
148
|
-
]
|
149
|
-
-- child 1 type: string
|
150
|
-
[
|
151
|
-
"chani",
|
152
|
-
"mauddib"
|
153
|
-
]
|
154
150
|
]
|
155
151
|
MAP
|
156
152
|
],
|
@@ -0,0 +1,40 @@
|
|
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 SortIndicesTest < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@table = Arrow::Table.new(number1: [16, -1, 2, 32, -4, -4, -8],
|
21
|
+
number2: [32, 2, -16, 8, 1, 4, 1])
|
22
|
+
end
|
23
|
+
|
24
|
+
sub_test_case("Table") do
|
25
|
+
test("Symbol") do
|
26
|
+
assert_equal(Arrow::UInt64Array.new([6, 4, 5, 1, 2, 0, 3]),
|
27
|
+
@table.sort_indices(:number1))
|
28
|
+
end
|
29
|
+
|
30
|
+
test("-String") do
|
31
|
+
assert_equal(Arrow::UInt64Array.new([3, 0, 2, 1, 4, 5, 6]),
|
32
|
+
@table.sort_indices("-number1"))
|
33
|
+
end
|
34
|
+
|
35
|
+
test("Symbol, -String") do
|
36
|
+
assert_equal(Arrow::UInt64Array.new([6, 5, 4, 1, 2, 0, 3]),
|
37
|
+
@table.sort_indices([:number1, "-number2"]))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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 SortKeyTest < Test::Unit::TestCase
|
19
|
+
sub_test_case(".resolve") do
|
20
|
+
test("SortKey") do
|
21
|
+
assert_equal(Arrow::SortKey.new("-count"),
|
22
|
+
Arrow::SortKey.resolve(Arrow::SortKey.new("-count")))
|
23
|
+
end
|
24
|
+
|
25
|
+
test("-String") do
|
26
|
+
assert_equal(Arrow::SortKey.new("-count"),
|
27
|
+
Arrow::SortKey.resolve("-count"))
|
28
|
+
end
|
29
|
+
|
30
|
+
test("Symbol, Symbol") do
|
31
|
+
assert_equal(Arrow::SortKey.new("-count"),
|
32
|
+
Arrow::SortKey.resolve(:count, :desc))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
sub_test_case("#initialize") do
|
37
|
+
test("String") do
|
38
|
+
assert_equal("+count",
|
39
|
+
Arrow::SortKey.new("count").to_s)
|
40
|
+
end
|
41
|
+
|
42
|
+
test("+String") do
|
43
|
+
assert_equal("+count",
|
44
|
+
Arrow::SortKey.new("+count").to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
test("-String") do
|
48
|
+
assert_equal("-count",
|
49
|
+
Arrow::SortKey.new("-count").to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
test("Symbol") do
|
53
|
+
assert_equal("+-count",
|
54
|
+
Arrow::SortKey.new(:"-count").to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
test("String, Symbol") do
|
58
|
+
assert_equal("--count",
|
59
|
+
Arrow::SortKey.new("-count", :desc).to_s)
|
60
|
+
end
|
61
|
+
|
62
|
+
test("String, String") do
|
63
|
+
assert_equal("--count",
|
64
|
+
Arrow::SortKey.new("-count", "desc").to_s)
|
65
|
+
end
|
66
|
+
|
67
|
+
test("String, SortOrder") do
|
68
|
+
assert_equal("--count",
|
69
|
+
Arrow::SortKey.new("-count",
|
70
|
+
Arrow::SortOrder::DESCENDING).to_s)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
sub_test_case("#to_s") do
|
75
|
+
test("recreatable") do
|
76
|
+
key = Arrow::SortKey.new("-count", :desc)
|
77
|
+
assert_equal(key,
|
78
|
+
Arrow::SortKey.new(key.to_s))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
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:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apache Arrow Developers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -254,6 +254,8 @@ files:
|
|
254
254
|
- lib/arrow/rolling-window.rb
|
255
255
|
- lib/arrow/schema.rb
|
256
256
|
- lib/arrow/slicer.rb
|
257
|
+
- lib/arrow/sort-key.rb
|
258
|
+
- lib/arrow/sort-options.rb
|
257
259
|
- lib/arrow/sparse-union-data-type.rb
|
258
260
|
- lib/arrow/struct-array-builder.rb
|
259
261
|
- lib/arrow/struct-array.rb
|
@@ -337,6 +339,9 @@ files:
|
|
337
339
|
- test/test-rolling-window.rb
|
338
340
|
- test/test-schema.rb
|
339
341
|
- test/test-slicer.rb
|
342
|
+
- test/test-sort-indices.rb
|
343
|
+
- test/test-sort-key.rb
|
344
|
+
- test/test-sort-options.rb
|
340
345
|
- test/test-sparse-union-data-type.rb
|
341
346
|
- test/test-struct-array-builder.rb
|
342
347
|
- test/test-struct-array.rb
|
@@ -359,8 +364,8 @@ homepage: https://arrow.apache.org/
|
|
359
364
|
licenses:
|
360
365
|
- Apache-2.0
|
361
366
|
metadata:
|
362
|
-
msys2_mingw_dependencies: arrow>=
|
363
|
-
post_install_message:
|
367
|
+
msys2_mingw_dependencies: arrow>=4.0.0
|
368
|
+
post_install_message:
|
364
369
|
rdoc_options: []
|
365
370
|
require_paths:
|
366
371
|
- lib
|
@@ -375,85 +380,88 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
375
380
|
- !ruby/object:Gem::Version
|
376
381
|
version: '0'
|
377
382
|
requirements: []
|
378
|
-
rubygems_version: 3.2.
|
379
|
-
signing_key:
|
383
|
+
rubygems_version: 3.2.15
|
384
|
+
signing_key:
|
380
385
|
specification_version: 4
|
381
386
|
summary: Red Arrow is the Ruby bindings of Apache Arrow
|
382
387
|
test_files:
|
383
|
-
- test/
|
384
|
-
- test/
|
385
|
-
- test/
|
386
|
-
- test/
|
387
|
-
- test/
|
388
|
-
- test/
|
389
|
-
- test/
|
390
|
-
- test/
|
391
|
-
- test/
|
388
|
+
- test/fixture/TestOrcFile.test1.orc
|
389
|
+
- test/fixture/float-integer.csv
|
390
|
+
- test/fixture/integer-float.csv
|
391
|
+
- test/fixture/null-with-double-quote.csv
|
392
|
+
- test/fixture/null-without-double-quote.csv
|
393
|
+
- test/fixture/with-header-float.csv
|
394
|
+
- test/fixture/with-header.csv
|
395
|
+
- test/fixture/without-header-float.csv
|
396
|
+
- test/fixture/without-header.csv
|
397
|
+
- test/helper/fixture.rb
|
398
|
+
- test/helper/omittable.rb
|
392
399
|
- test/helper.rb
|
393
|
-
- test/test-
|
394
|
-
- test/test-
|
400
|
+
- test/raw-records/test-basic-arrays.rb
|
401
|
+
- test/raw-records/test-dense-union-array.rb
|
402
|
+
- test/raw-records/test-list-array.rb
|
403
|
+
- test/raw-records/test-multiple-columns.rb
|
404
|
+
- test/raw-records/test-sparse-union-array.rb
|
405
|
+
- test/raw-records/test-struct-array.rb
|
406
|
+
- test/raw-records/test-table.rb
|
395
407
|
- test/run-test.rb
|
396
|
-
- test/test-timestamp-array.rb
|
397
|
-
- test/test-date32-array.rb
|
398
408
|
- test/test-array-builder.rb
|
409
|
+
- test/test-array.rb
|
410
|
+
- test/test-bigdecimal.rb
|
411
|
+
- test/test-buffer.rb
|
412
|
+
- test/test-chunked-array.rb
|
413
|
+
- test/test-column.rb
|
414
|
+
- test/test-csv-loader.rb
|
415
|
+
- test/test-data-type.rb
|
416
|
+
- test/test-date32-array.rb
|
399
417
|
- test/test-date64-array.rb
|
400
|
-
- test/test-
|
418
|
+
- test/test-decimal128-array-builder.rb
|
419
|
+
- test/test-decimal128-array.rb
|
401
420
|
- test/test-decimal128-data-type.rb
|
402
|
-
- test/test-
|
403
|
-
- test/test-
|
421
|
+
- test/test-decimal128.rb
|
422
|
+
- test/test-decimal256-array-builder.rb
|
423
|
+
- test/test-decimal256-array.rb
|
424
|
+
- test/test-decimal256-data-type.rb
|
404
425
|
- test/test-decimal256.rb
|
426
|
+
- test/test-dense-union-data-type.rb
|
405
427
|
- test/test-dictionary-array.rb
|
406
|
-
- test/test-
|
407
|
-
- test/test-
|
428
|
+
- test/test-dictionary-data-type.rb
|
429
|
+
- test/test-feather.rb
|
408
430
|
- test/test-field.rb
|
409
|
-
- test/test-
|
410
|
-
- test/test-
|
411
|
-
- test/test-bigdecimal.rb
|
431
|
+
- test/test-file-output-stream.rb
|
432
|
+
- test/test-fixed-size-binary-array-builder.rb
|
412
433
|
- test/test-fixed-size-binary-array.rb
|
413
|
-
- test/test-list-array.rb
|
414
|
-
- test/test-decimal256-data-type.rb
|
415
|
-
- test/test-time64-array.rb
|
416
|
-
- test/test-rolling-window.rb
|
417
|
-
- test/test-dictionary-data-type.rb
|
418
|
-
- test/fixture/integer-float.csv
|
419
|
-
- test/fixture/without-header-float.csv
|
420
|
-
- test/fixture/null-with-double-quote.csv
|
421
|
-
- test/fixture/with-header-float.csv
|
422
|
-
- test/fixture/TestOrcFile.test1.orc
|
423
|
-
- test/fixture/null-without-double-quote.csv
|
424
|
-
- test/fixture/without-header.csv
|
425
|
-
- test/fixture/with-header.csv
|
426
|
-
- test/fixture/float-integer.csv
|
427
|
-
- test/test-orc.rb
|
428
|
-
- test/test-null-array.rb
|
429
|
-
- test/test-time32-data-type.rb
|
430
|
-
- test/test-struct-data-type.rb
|
431
434
|
- test/test-group.rb
|
432
|
-
- test/test-buffer.rb
|
433
|
-
- test/values/test-struct-array.rb
|
434
|
-
- test/values/test-basic-arrays.rb
|
435
|
-
- test/values/test-list-array.rb
|
436
|
-
- test/values/test-dense-union-array.rb
|
437
|
-
- test/values/test-sparse-union-array.rb
|
438
|
-
- test/test-slicer.rb
|
439
435
|
- test/test-list-array-builder.rb
|
440
|
-
- test/test-
|
436
|
+
- test/test-list-array.rb
|
437
|
+
- test/test-list-data-type.rb
|
438
|
+
- test/test-null-array.rb
|
439
|
+
- test/test-orc.rb
|
441
440
|
- test/test-record-batch-builder.rb
|
442
|
-
- test/
|
443
|
-
- test/raw-records/test-table.rb
|
444
|
-
- test/raw-records/test-basic-arrays.rb
|
445
|
-
- test/raw-records/test-list-array.rb
|
446
|
-
- test/raw-records/test-dense-union-array.rb
|
447
|
-
- test/raw-records/test-sparse-union-array.rb
|
448
|
-
- test/raw-records/test-multiple-columns.rb
|
449
|
-
- test/test-array.rb
|
450
|
-
- test/test-file-output-stream.rb
|
441
|
+
- test/test-record-batch-file-reader.rb
|
451
442
|
- test/test-record-batch-iterator.rb
|
452
|
-
- test/test-
|
453
|
-
- test/test-
|
454
|
-
- test/test-chunked-array.rb
|
443
|
+
- test/test-record-batch.rb
|
444
|
+
- test/test-rolling-window.rb
|
455
445
|
- test/test-schema.rb
|
446
|
+
- test/test-slicer.rb
|
447
|
+
- test/test-sort-indices.rb
|
448
|
+
- test/test-sort-key.rb
|
449
|
+
- test/test-sort-options.rb
|
450
|
+
- test/test-sparse-union-data-type.rb
|
456
451
|
- test/test-struct-array-builder.rb
|
457
|
-
- test/
|
458
|
-
- test/
|
452
|
+
- test/test-struct-array.rb
|
453
|
+
- test/test-struct-data-type.rb
|
454
|
+
- test/test-table.rb
|
455
|
+
- test/test-tensor.rb
|
456
|
+
- test/test-time.rb
|
459
457
|
- test/test-time32-array.rb
|
458
|
+
- test/test-time32-data-type.rb
|
459
|
+
- test/test-time64-array.rb
|
460
|
+
- test/test-time64-data-type.rb
|
461
|
+
- test/test-timestamp-array.rb
|
462
|
+
- test/test-timestamp-data-type.rb
|
463
|
+
- test/values/test-basic-arrays.rb
|
464
|
+
- test/values/test-dense-union-array.rb
|
465
|
+
- test/values/test-list-array.rb
|
466
|
+
- test/values/test-sparse-union-array.rb
|
467
|
+
- test/values/test-struct-array.rb
|