red-arrow 4.0.1 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -0
  3. data/README.md +23 -0
  4. data/ext/arrow/arrow.cpp +3 -0
  5. data/ext/arrow/converters.cpp +5 -0
  6. data/ext/arrow/converters.hpp +126 -0
  7. data/ext/arrow/extconf.rb +13 -0
  8. data/ext/arrow/memory-view.cpp +311 -0
  9. data/ext/arrow/memory-view.hpp +26 -0
  10. data/ext/arrow/raw-records.cpp +1 -0
  11. data/ext/arrow/values.cpp +1 -0
  12. data/lib/arrow/aggregate-node-options.rb +35 -0
  13. data/lib/arrow/aggregation.rb +46 -0
  14. data/lib/arrow/array-builder.rb +5 -0
  15. data/lib/arrow/array.rb +12 -0
  16. data/lib/arrow/binary-dictionary-array-builder.rb +27 -0
  17. data/lib/arrow/buffer.rb +10 -6
  18. data/lib/arrow/column-containable.rb +100 -1
  19. data/lib/arrow/constructor-arguments-gc-guardable.rb +25 -0
  20. data/lib/arrow/datum.rb +102 -0
  21. data/lib/arrow/equal-options.rb +38 -0
  22. data/lib/arrow/expression.rb +48 -0
  23. data/lib/arrow/file-system.rb +34 -0
  24. data/lib/arrow/function.rb +52 -0
  25. data/lib/arrow/group.rb +116 -124
  26. data/lib/arrow/loader.rb +58 -0
  27. data/lib/arrow/map-array-builder.rb +109 -0
  28. data/lib/arrow/map-array.rb +26 -0
  29. data/lib/arrow/map-data-type.rb +89 -0
  30. data/lib/arrow/path-extension.rb +1 -1
  31. data/lib/arrow/record-batch-reader.rb +41 -0
  32. data/lib/arrow/record-batch.rb +0 -2
  33. data/lib/arrow/s3-global-options.rb +38 -0
  34. data/lib/arrow/scalar.rb +32 -0
  35. data/lib/arrow/slicer.rb +44 -143
  36. data/lib/arrow/sort-key.rb +61 -55
  37. data/lib/arrow/sort-options.rb +8 -8
  38. data/lib/arrow/source-node-options.rb +32 -0
  39. data/lib/arrow/string-dictionary-array-builder.rb +27 -0
  40. data/lib/arrow/symbol-values-appendable.rb +34 -0
  41. data/lib/arrow/table-concatenate-options.rb +36 -0
  42. data/lib/arrow/table-formatter.rb +141 -17
  43. data/lib/arrow/table-list-formatter.rb +5 -3
  44. data/lib/arrow/table-loader.rb +119 -44
  45. data/lib/arrow/table-saver.rb +36 -5
  46. data/lib/arrow/table-table-formatter.rb +7 -31
  47. data/lib/arrow/table.rb +112 -40
  48. data/lib/arrow/version.rb +1 -1
  49. data/red-arrow.gemspec +1 -9
  50. data/test/helper.rb +3 -0
  51. data/test/raw-records/test-dense-union-array.rb +14 -0
  52. data/test/raw-records/test-list-array.rb +19 -0
  53. data/test/raw-records/test-map-array.rb +441 -0
  54. data/test/raw-records/test-sparse-union-array.rb +14 -0
  55. data/test/raw-records/test-struct-array.rb +15 -0
  56. data/test/test-array-builder.rb +7 -0
  57. data/test/test-array.rb +34 -0
  58. data/test/test-binary-dictionary-array-builder.rb +103 -0
  59. data/test/test-boolean-scalar.rb +26 -0
  60. data/test/test-csv-loader.rb +8 -8
  61. data/test/test-expression.rb +40 -0
  62. data/test/test-float-scalar.rb +46 -0
  63. data/test/test-function.rb +210 -0
  64. data/test/test-group.rb +75 -51
  65. data/test/test-map-array-builder.rb +110 -0
  66. data/test/test-map-array.rb +33 -0
  67. data/test/test-map-data-type.rb +36 -0
  68. data/test/test-memory-view.rb +434 -0
  69. data/test/test-record-batch-reader.rb +46 -0
  70. data/test/test-record-batch.rb +42 -0
  71. data/test/test-slicer.rb +166 -167
  72. data/test/test-string-dictionary-array-builder.rb +103 -0
  73. data/test/test-table.rb +376 -56
  74. data/test/values/test-dense-union-array.rb +14 -0
  75. data/test/values/test-list-array.rb +17 -0
  76. data/test/values/test-map-array.rb +433 -0
  77. data/test/values/test-sparse-union-array.rb +14 -0
  78. data/test/values/test-struct-array.rb +15 -0
  79. metadata +117 -168
@@ -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
@@ -0,0 +1,32 @@
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 Scalar
20
+ # @param other [Arrow::Scalar] The scalar to be compared.
21
+ # @param options [Arrow::EqualOptions, Hash] (nil)
22
+ # The options to custom how to compare.
23
+ #
24
+ # @return [Boolean]
25
+ # `true` if both of them have the same data, `false` otherwise.
26
+ #
27
+ # @since 5.0.0
28
+ def equal_scalar?(other, options=nil)
29
+ equal_options(other, options)
30
+ end
31
+ end
32
+ end
data/lib/arrow/slicer.rb CHANGED
@@ -16,9 +16,6 @@
16
16
  # under the License.
17
17
 
18
18
  module Arrow
19
- # Experimental
20
- #
21
- # TODO: Almost codes should be implemented in Apache Arrow C++.
22
19
  class Slicer
23
20
  def initialize(table)
24
21
  @table = table
@@ -43,6 +40,21 @@ module Arrow
43
40
  super
44
41
  end
45
42
 
43
+ module Helper
44
+ class << self
45
+ def ensure_boolean(column)
46
+ case column.data_type
47
+ when Arrow::BooleanDataType
48
+ column.data
49
+ else
50
+ options = CastOptions.new
51
+ options.to_data_type = Arrow::BooleanDataType.new
52
+ Function.find("cast").execute([column.data], options).value
53
+ end
54
+ end
55
+ end
56
+ end
57
+
46
58
  class Condition
47
59
  def evaluate
48
60
  message = "Slicer::Condition must define \#evaluate: #{inspect}"
@@ -69,43 +81,28 @@ module Arrow
69
81
  end
70
82
 
71
83
  def evaluate
72
- values1 = @condition1.evaluate.each
73
- values2 = @condition2.evaluate.each
74
- raw_array = []
75
- begin
76
- loop do
77
- value1 = values1.next
78
- value2 = values2.next
79
- if value1.nil? or value2.nil?
80
- raw_array << nil
81
- else
82
- raw_array << evaluate_value(value1, value2)
83
- end
84
- end
85
- rescue StopIteration
86
- end
87
- BooleanArray.new(raw_array)
84
+ function.execute([@condition1.evaluate, @condition2.evaluate]).value
88
85
  end
89
86
  end
90
87
 
91
88
  class AndCondition < LogicalCondition
92
89
  private
93
- def evaluate_value(value1, value2)
94
- value1 and value2
90
+ def function
91
+ Function.find("and")
95
92
  end
96
93
  end
97
94
 
98
95
  class OrCondition < LogicalCondition
99
96
  private
100
- def evaluate_value(value1, value2)
101
- value1 or value2
97
+ def function
98
+ Function.find("or")
102
99
  end
103
100
  end
104
101
 
105
102
  class XorCondition < LogicalCondition
106
103
  private
107
- def evaluate_value(value1, value2)
108
- value1 ^ value2
104
+ def function
105
+ Function.find("xor")
109
106
  end
110
107
  end
111
108
 
@@ -115,21 +112,7 @@ module Arrow
115
112
  end
116
113
 
117
114
  def evaluate
118
- data = @column.data
119
-
120
- case @column.data_type
121
- when BooleanDataType
122
- data
123
- else
124
- if data.n_chunks == 1
125
- data.get_chunk(0).cast(BooleanDataType.new, nil)
126
- else
127
- arrays = data.each_chunk.collect do |chunk|
128
- chunk.cast(BooleanDataType.new, nil)
129
- end
130
- ChunkedArray.new(arrays)
131
- end
132
- end
115
+ Helper.ensure_boolean(@column)
133
116
  end
134
117
 
135
118
  def !@
@@ -187,23 +170,8 @@ module Arrow
187
170
  end
188
171
 
189
172
  def evaluate
190
- data = @column.data
191
- raw_array = []
192
- data.each_chunk do |chunk|
193
- if chunk.is_a?(BooleanArray)
194
- boolean_array = chunk
195
- else
196
- boolean_array = chunk.cast(BooleanDataType.new, nil)
197
- end
198
- boolean_array.each do |value|
199
- if value.nil?
200
- raw_array << value
201
- else
202
- raw_array << !value
203
- end
204
- end
205
- end
206
- BooleanArray.new(raw_array)
173
+ data = Helper.ensure_boolean(@column)
174
+ Function.find("invert").execute([data]).value
207
175
  end
208
176
 
209
177
  def !@
@@ -222,19 +190,10 @@ module Arrow
222
190
  end
223
191
 
224
192
  def evaluate
225
- case @value
226
- when nil
227
- raw_array = @column.collect(&:nil?)
228
- BooleanArray.new(raw_array)
193
+ if @value.nil?
194
+ Function.find("is_null").execute([@column.data]).value
229
195
  else
230
- raw_array = @column.collect do |value|
231
- if value.nil?
232
- nil
233
- else
234
- @value == value
235
- end
236
- end
237
- BooleanArray.new(raw_array)
196
+ Function.find("equal").execute([@column.data, @value]).value
238
197
  end
239
198
  end
240
199
  end
@@ -250,25 +209,10 @@ module Arrow
250
209
  end
251
210
 
252
211
  def evaluate
253
- case @value
254
- when nil
255
- if @column.n_nulls.zero?
256
- raw_array = [true] * @column.n_rows
257
- else
258
- raw_array = @column.n_rows.times.collect do |i|
259
- @column.valid?(i)
260
- end
261
- end
262
- BooleanArray.new(raw_array)
212
+ if @value.nil?
213
+ Function.find("is_valid").execute([@column.data]).value
263
214
  else
264
- raw_array = @column.collect do |value|
265
- if value.nil?
266
- nil
267
- else
268
- @value != value
269
- end
270
- end
271
- BooleanArray.new(raw_array)
215
+ Function.find("not_equal").execute([@column.data, @value]).value
272
216
  end
273
217
  end
274
218
  end
@@ -284,14 +228,7 @@ module Arrow
284
228
  end
285
229
 
286
230
  def evaluate
287
- raw_array = @column.collect do |value|
288
- if value.nil?
289
- nil
290
- else
291
- @value > value
292
- end
293
- end
294
- BooleanArray.new(raw_array)
231
+ Function.find("less").execute([@column.data, @value]).value
295
232
  end
296
233
  end
297
234
 
@@ -306,14 +243,7 @@ module Arrow
306
243
  end
307
244
 
308
245
  def evaluate
309
- raw_array = @column.collect do |value|
310
- if value.nil?
311
- nil
312
- else
313
- @value >= value
314
- end
315
- end
316
- BooleanArray.new(raw_array)
246
+ Function.find("less_equal").execute([@column.data, @value]).value
317
247
  end
318
248
  end
319
249
 
@@ -328,14 +258,7 @@ module Arrow
328
258
  end
329
259
 
330
260
  def evaluate
331
- raw_array = @column.collect do |value|
332
- if value.nil?
333
- nil
334
- else
335
- @value < value
336
- end
337
- end
338
- BooleanArray.new(raw_array)
261
+ Function.find("greater").execute([@column.data, @value]).value
339
262
  end
340
263
  end
341
264
 
@@ -350,14 +273,7 @@ module Arrow
350
273
  end
351
274
 
352
275
  def evaluate
353
- raw_array = @column.collect do |value|
354
- if value.nil?
355
- nil
356
- else
357
- @value <= value
358
- end
359
- end
360
- BooleanArray.new(raw_array)
276
+ Function.find("greater_equal").execute([@column.data, @value]).value
361
277
  end
362
278
  end
363
279
 
@@ -372,18 +288,10 @@ module Arrow
372
288
  end
373
289
 
374
290
  def evaluate
375
- values_index = {}
376
- @values.each do |value|
377
- values_index[value] = true
378
- end
379
- raw_array = @column.collect do |value|
380
- if value.nil?
381
- nil
382
- else
383
- values_index.key?(value)
384
- end
385
- end
386
- BooleanArray.new(raw_array)
291
+ values = @values
292
+ values = Array.new(values) unless values.is_a?(Array)
293
+ options = SetLookupOptions.new(values)
294
+ Function.find("is_in").execute([@column.data], options).value
387
295
  end
388
296
  end
389
297
 
@@ -398,18 +306,11 @@ module Arrow
398
306
  end
399
307
 
400
308
  def evaluate
401
- values_index = {}
402
- @values.each do |value|
403
- values_index[value] = true
404
- end
405
- raw_array = @column.collect do |value|
406
- if value.nil?
407
- nil
408
- else
409
- not values_index.key?(value)
410
- end
411
- end
412
- BooleanArray.new(raw_array)
309
+ values = @values
310
+ values = Array.new(values) unless values.is_a?(Array)
311
+ options = SetLookupOptions.new(values)
312
+ booleans = Function.find("is_in").execute([@column.data], options).value
313
+ Function.find("invert").execute([booleans]).value
413
314
  end
414
315
  end
415
316
 
@@ -29,25 +29,26 @@ module Arrow
29
29
  #
30
30
  # @return [Arrow::SortKey] The given sort key itself.
31
31
  #
32
- # @overload resolve(name)
32
+ # @overload resolve(target)
33
33
  #
34
- # Creates a new suitable sort key from column name with
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(name, order)
40
+ # @overload resolve(target, order)
41
41
  #
42
- # Creates a new suitable sort key from column name without
43
- # leading order mark and order. See {#initialize} for details.
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(name, order=nil)
49
- return name if name.is_a?(self)
50
- new(name, order)
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(name)
69
+ # @overload initialize(target)
69
70
  #
70
- # @param name [Symbol, String] The name of the sort column.
71
+ # @param target [Symbol, String] The name or dot path of the
72
+ # sort column.
71
73
  #
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.
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 `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
+ # 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.name # => "count"
87
- # key.order # => Arrow::SortOrder::ASCENDING
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.name # => "count"
92
- # key.order # => Arrow::SortOrder::ASCENDING
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.name # => "count"
97
- # key.order # => Arrow::SortOrder::DESCENDING
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.name # => "-count"
102
- # key.order # => Arrow::SortOrder::ASCENDING
103
+ # key.target # => "-count"
104
+ # key.order # => Arrow::SortOrder::ASCENDING
103
105
  #
104
- # @overload initialize(name, order)
106
+ # @overload initialize(target, order)
105
107
  #
106
- # @param name [Symbol, String] The name of the sort column.
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 `name` is used
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.name # => "-count"
121
- # key.order # => Arrow::SortOrder::ASCENDING
123
+ # key.target # => "-count"
124
+ # key.order # => Arrow::SortOrder::ASCENDING
122
125
  #
123
- # @example Order by abbreviated name with Symbol
126
+ # @example Order by abbreviated target with Symbol
124
127
  # key = Arrow::SortKey.new("count", :desc)
125
- # key.name # => "count"
126
- # key.order # => Arrow::SortOrder::DESCENDING
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.name # => "count"
131
- # key.order # => Arrow::SortOrder::DESCENDING
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.name # => "count"
136
- # key.order # => Arrow::SortOrder::DESCENDING
138
+ # key.target # => "count"
139
+ # key.order # => Arrow::SortOrder::DESCENDING
137
140
  #
138
141
  # @since 4.0.0
139
- def initialize(name, order=nil)
140
- name, order = normalize_name(name, order)
142
+ def initialize(target, order=nil)
143
+ target, order = normalize_target(target, order)
141
144
  order = normalize_order(order) || :ascending
142
- initialize_raw(name, order)
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
- "+#{name}"
160
+ "+#{target}"
158
161
  else
159
- "-#{name}"
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 normalize_name(name, order)
165
- case name
170
+ def normalize_target(target, order)
171
+ case target
166
172
  when Symbol
167
- return name.to_s, order
173
+ return target.to_s, order
168
174
  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
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 name, order
181
+ return target, order
176
182
  end
177
183
  else
178
- return name, order
184
+ return target, order
179
185
  end
180
186
  end
181
187
 
@@ -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(name)
81
+ # @overload add_sort_key(target)
82
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.
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(name, order)
92
+ # @overload add_sort_key(target, order)
93
93
  #
94
- # @param name [Symbol, String] The sort key name.
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(name, order=nil)
106
- add_sort_key_raw(SortKey.resolve(name, order))
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
@@ -0,0 +1,32 @@
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 SourceNodeOptions
20
+ class << self
21
+ # @api private
22
+ def try_convert(value)
23
+ case value
24
+ when RecordBatchReader, RecordBatch, Table
25
+ new(value)
26
+ else
27
+ nil
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
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 StringDictionaryArrayBuilder
20
+ include SymbolValuesAppendable
21
+
22
+ private
23
+ def create_values_array_builder
24
+ StringArrayBuilder.new
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
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
+ module SymbolValuesAppendable
20
+ def append_values(values, is_valids=nil)
21
+ builder = create_values_array_builder
22
+ values = values.collect do |value|
23
+ case value
24
+ when Symbol
25
+ value.to_s
26
+ else
27
+ value
28
+ end
29
+ end
30
+ builder.append_values(values, is_valids)
31
+ append_array(builder.finish)
32
+ end
33
+ end
34
+ end