red-arrow 3.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/ext/arrow/arrow.cpp +3 -0
- data/ext/arrow/converters.cpp +5 -0
- data/ext/arrow/converters.hpp +126 -0
- data/ext/arrow/extconf.rb +13 -0
- data/ext/arrow/memory-view.cpp +311 -0
- data/ext/arrow/memory-view.hpp +26 -0
- data/ext/arrow/raw-records.cpp +1 -0
- data/ext/arrow/values.cpp +1 -0
- data/lib/arrow/aggregate-node-options.rb +35 -0
- data/lib/arrow/aggregation.rb +46 -0
- data/lib/arrow/array-builder.rb +5 -0
- data/lib/arrow/array.rb +130 -0
- data/lib/arrow/binary-dictionary-array-builder.rb +27 -0
- data/lib/arrow/buffer.rb +10 -6
- data/lib/arrow/column-containable.rb +100 -1
- data/lib/arrow/constructor-arguments-gc-guardable.rb +25 -0
- data/lib/arrow/data-type.rb +14 -5
- data/lib/arrow/datum.rb +100 -0
- data/lib/arrow/dense-union-data-type.rb +2 -2
- data/lib/arrow/dictionary-data-type.rb +2 -2
- data/lib/arrow/equal-options.rb +38 -0
- data/lib/arrow/expression.rb +48 -0
- data/lib/arrow/file-system.rb +34 -0
- data/lib/arrow/group.rb +116 -124
- data/lib/arrow/loader.rb +46 -0
- data/lib/arrow/map-array-builder.rb +109 -0
- data/lib/arrow/map-array.rb +26 -0
- data/lib/arrow/map-data-type.rb +89 -0
- data/lib/arrow/path-extension.rb +1 -1
- data/lib/arrow/record-batch-reader.rb +41 -0
- data/lib/arrow/record-batch.rb +0 -2
- data/lib/arrow/scalar.rb +32 -0
- data/lib/arrow/slicer.rb +44 -143
- data/lib/arrow/sort-key.rb +193 -0
- data/lib/arrow/sort-options.rb +109 -0
- data/lib/arrow/source-node-options.rb +32 -0
- data/lib/arrow/sparse-union-data-type.rb +2 -2
- data/lib/arrow/string-dictionary-array-builder.rb +27 -0
- data/lib/arrow/symbol-values-appendable.rb +34 -0
- data/lib/arrow/table-concatenate-options.rb +36 -0
- data/lib/arrow/table-formatter.rb +141 -17
- data/lib/arrow/table-list-formatter.rb +5 -3
- data/lib/arrow/table-loader.rb +41 -3
- data/lib/arrow/table-saver.rb +29 -3
- data/lib/arrow/table-table-formatter.rb +7 -31
- data/lib/arrow/table.rb +34 -40
- 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/red-arrow.gemspec +2 -1
- data/test/helper.rb +1 -0
- data/test/raw-records/test-dense-union-array.rb +14 -0
- data/test/raw-records/test-list-array.rb +19 -0
- data/test/raw-records/test-map-array.rb +441 -0
- data/test/raw-records/test-sparse-union-array.rb +14 -0
- data/test/raw-records/test-struct-array.rb +15 -0
- data/test/test-array-builder.rb +7 -0
- data/test/test-array.rb +154 -0
- data/test/test-binary-dictionary-array-builder.rb +103 -0
- data/test/test-boolean-scalar.rb +26 -0
- data/test/test-csv-loader.rb +8 -8
- data/test/test-decimal128-data-type.rb +2 -2
- data/test/test-expression.rb +40 -0
- data/test/test-float-scalar.rb +46 -0
- data/test/test-function.rb +176 -0
- data/test/test-group.rb +75 -51
- data/test/test-map-array-builder.rb +110 -0
- data/test/test-map-array.rb +33 -0
- data/test/test-map-data-type.rb +36 -0
- data/test/test-memory-view.rb +434 -0
- data/test/test-orc.rb +19 -23
- data/test/test-record-batch-reader.rb +46 -0
- data/test/test-record-batch.rb +42 -0
- data/test/test-slicer.rb +166 -167
- data/test/test-sort-indices.rb +40 -0
- data/test/test-sort-key.rb +81 -0
- data/test/test-sort-options.rb +58 -0
- data/test/test-string-dictionary-array-builder.rb +103 -0
- data/test/test-table.rb +190 -53
- data/test/values/test-dense-union-array.rb +14 -0
- data/test/values/test-list-array.rb +17 -0
- data/test/values/test-map-array.rb +433 -0
- data/test/values/test-sparse-union-array.rb +14 -0
- data/test/values/test-struct-array.rb +15 -0
- metadata +73 -6
data/test/test-slicer.rb
CHANGED
@@ -45,15 +45,15 @@ class SlicerTest < Test::Unit::TestCase
|
|
45
45
|
slicer.visible
|
46
46
|
end
|
47
47
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
48
|
-
|
49
|
-
0
|
50
|
-
1
|
51
|
-
2
|
52
|
-
3
|
53
|
-
4
|
54
|
-
5
|
55
|
-
6
|
56
|
-
7
|
48
|
+
count visible
|
49
|
+
0 (null) (null)
|
50
|
+
1 1 true
|
51
|
+
2 (null) (null)
|
52
|
+
3 8 true
|
53
|
+
4 16 true
|
54
|
+
5 (null) (null)
|
55
|
+
6 (null) (null)
|
56
|
+
7 256 true
|
57
57
|
TABLE
|
58
58
|
end
|
59
59
|
|
@@ -62,16 +62,16 @@ class SlicerTest < Test::Unit::TestCase
|
|
62
62
|
slicer.count
|
63
63
|
end
|
64
64
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
65
|
-
|
66
|
-
0
|
67
|
-
1
|
68
|
-
2
|
69
|
-
3
|
70
|
-
4
|
71
|
-
5
|
72
|
-
6
|
73
|
-
7
|
74
|
-
8
|
65
|
+
count visible
|
66
|
+
0 1 true
|
67
|
+
1 2 false
|
68
|
+
2 4 (null)
|
69
|
+
3 8 true
|
70
|
+
4 16 true
|
71
|
+
5 32 false
|
72
|
+
6 64 (null)
|
73
|
+
7 (null) (null)
|
74
|
+
8 256 true
|
75
75
|
TABLE
|
76
76
|
end
|
77
77
|
end
|
@@ -82,13 +82,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
82
82
|
!slicer.visible
|
83
83
|
end
|
84
84
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
85
|
-
|
86
|
-
0
|
87
|
-
1
|
88
|
-
2
|
89
|
-
3
|
90
|
-
4
|
91
|
-
5
|
85
|
+
count visible
|
86
|
+
0 (null) (null)
|
87
|
+
1 2 false
|
88
|
+
2 (null) (null)
|
89
|
+
3 32 false
|
90
|
+
4 (null) (null)
|
91
|
+
5 (null) (null)
|
92
92
|
TABLE
|
93
93
|
end
|
94
94
|
|
@@ -97,9 +97,9 @@ class SlicerTest < Test::Unit::TestCase
|
|
97
97
|
!slicer.count
|
98
98
|
end
|
99
99
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
100
|
-
|
101
|
-
0
|
102
|
-
1
|
100
|
+
count visible
|
101
|
+
0 0 (null)
|
102
|
+
1 (null) (null)
|
103
103
|
TABLE
|
104
104
|
end
|
105
105
|
end
|
@@ -109,11 +109,11 @@ class SlicerTest < Test::Unit::TestCase
|
|
109
109
|
slicer.visible.null?
|
110
110
|
end
|
111
111
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
112
|
-
|
113
|
-
0
|
114
|
-
1
|
115
|
-
2
|
116
|
-
3
|
112
|
+
count visible
|
113
|
+
0 0 (null)
|
114
|
+
1 4 (null)
|
115
|
+
2 64 (null)
|
116
|
+
3 (null) (null)
|
117
117
|
TABLE
|
118
118
|
end
|
119
119
|
|
@@ -138,11 +138,11 @@ class SlicerTest < Test::Unit::TestCase
|
|
138
138
|
slicer.visible == nil
|
139
139
|
end
|
140
140
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
141
|
-
|
142
|
-
0
|
143
|
-
1
|
144
|
-
2
|
145
|
-
3
|
141
|
+
count visible
|
142
|
+
0 0 (null)
|
143
|
+
1 4 (null)
|
144
|
+
2 64 (null)
|
145
|
+
3 (null) (null)
|
146
146
|
TABLE
|
147
147
|
end
|
148
148
|
|
@@ -151,15 +151,15 @@ class SlicerTest < Test::Unit::TestCase
|
|
151
151
|
slicer.visible == true
|
152
152
|
end
|
153
153
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
154
|
-
|
155
|
-
0
|
156
|
-
1
|
157
|
-
2
|
158
|
-
3
|
159
|
-
4
|
160
|
-
5
|
161
|
-
6
|
162
|
-
7
|
154
|
+
count visible
|
155
|
+
0 (null) (null)
|
156
|
+
1 1 true
|
157
|
+
2 (null) (null)
|
158
|
+
3 8 true
|
159
|
+
4 16 true
|
160
|
+
5 (null) (null)
|
161
|
+
6 (null) (null)
|
162
|
+
7 256 true
|
163
163
|
TABLE
|
164
164
|
end
|
165
165
|
end
|
@@ -185,13 +185,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
185
185
|
!(slicer.visible == true)
|
186
186
|
end
|
187
187
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
188
|
-
|
189
|
-
0
|
190
|
-
1
|
191
|
-
2
|
192
|
-
3
|
193
|
-
4
|
194
|
-
5
|
188
|
+
count visible
|
189
|
+
0 (null) (null)
|
190
|
+
1 2 false
|
191
|
+
2 (null) (null)
|
192
|
+
3 32 false
|
193
|
+
4 (null) (null)
|
194
|
+
5 (null) (null)
|
195
195
|
TABLE
|
196
196
|
end
|
197
197
|
end
|
@@ -217,13 +217,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
217
217
|
slicer.visible != true
|
218
218
|
end
|
219
219
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
220
|
-
|
221
|
-
0
|
222
|
-
1
|
223
|
-
2
|
224
|
-
3
|
225
|
-
4
|
226
|
-
5
|
220
|
+
count visible
|
221
|
+
0 (null) (null)
|
222
|
+
1 2 false
|
223
|
+
2 (null) (null)
|
224
|
+
3 32 false
|
225
|
+
4 (null) (null)
|
226
|
+
5 (null) (null)
|
227
227
|
TABLE
|
228
228
|
end
|
229
229
|
end
|
@@ -233,13 +233,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
233
233
|
slicer.count < 16
|
234
234
|
end
|
235
235
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
236
|
-
|
237
|
-
0
|
238
|
-
1
|
239
|
-
2
|
240
|
-
3
|
241
|
-
4
|
242
|
-
5
|
236
|
+
count visible
|
237
|
+
0 0 (null)
|
238
|
+
1 1 true
|
239
|
+
2 2 false
|
240
|
+
3 4 (null)
|
241
|
+
4 8 true
|
242
|
+
5 (null) (null)
|
243
243
|
TABLE
|
244
244
|
end
|
245
245
|
|
@@ -248,12 +248,12 @@ class SlicerTest < Test::Unit::TestCase
|
|
248
248
|
!(slicer.count < 16)
|
249
249
|
end
|
250
250
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
251
|
-
|
252
|
-
0
|
253
|
-
1
|
254
|
-
2
|
255
|
-
3
|
256
|
-
4
|
251
|
+
count visible
|
252
|
+
0 16 true
|
253
|
+
1 32 false
|
254
|
+
2 64 (null)
|
255
|
+
3 (null) (null)
|
256
|
+
4 256 true
|
257
257
|
TABLE
|
258
258
|
end
|
259
259
|
|
@@ -262,14 +262,14 @@ class SlicerTest < Test::Unit::TestCase
|
|
262
262
|
slicer.count <= 16
|
263
263
|
end
|
264
264
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
265
|
-
|
266
|
-
0
|
267
|
-
1
|
268
|
-
2
|
269
|
-
3
|
270
|
-
4
|
271
|
-
5
|
272
|
-
6
|
265
|
+
count visible
|
266
|
+
0 0 (null)
|
267
|
+
1 1 true
|
268
|
+
2 2 false
|
269
|
+
3 4 (null)
|
270
|
+
4 8 true
|
271
|
+
5 16 true
|
272
|
+
6 (null) (null)
|
273
273
|
TABLE
|
274
274
|
end
|
275
275
|
|
@@ -278,11 +278,11 @@ class SlicerTest < Test::Unit::TestCase
|
|
278
278
|
!(slicer.count <= 16)
|
279
279
|
end
|
280
280
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
281
|
-
|
282
|
-
0
|
283
|
-
1
|
284
|
-
2
|
285
|
-
3
|
281
|
+
count visible
|
282
|
+
0 32 false
|
283
|
+
1 64 (null)
|
284
|
+
2 (null) (null)
|
285
|
+
3 256 true
|
286
286
|
TABLE
|
287
287
|
end
|
288
288
|
|
@@ -291,11 +291,11 @@ class SlicerTest < Test::Unit::TestCase
|
|
291
291
|
slicer.count > 16
|
292
292
|
end
|
293
293
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
294
|
-
|
295
|
-
0
|
296
|
-
1
|
297
|
-
2
|
298
|
-
3
|
294
|
+
count visible
|
295
|
+
0 32 false
|
296
|
+
1 64 (null)
|
297
|
+
2 (null) (null)
|
298
|
+
3 256 true
|
299
299
|
TABLE
|
300
300
|
end
|
301
301
|
|
@@ -304,14 +304,14 @@ class SlicerTest < Test::Unit::TestCase
|
|
304
304
|
!(slicer.count > 16)
|
305
305
|
end
|
306
306
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
307
|
-
|
308
|
-
0
|
309
|
-
1
|
310
|
-
2
|
311
|
-
3
|
312
|
-
4
|
313
|
-
5
|
314
|
-
6
|
307
|
+
count visible
|
308
|
+
0 0 (null)
|
309
|
+
1 1 true
|
310
|
+
2 2 false
|
311
|
+
3 4 (null)
|
312
|
+
4 8 true
|
313
|
+
5 16 true
|
314
|
+
6 (null) (null)
|
315
315
|
TABLE
|
316
316
|
end
|
317
317
|
|
@@ -320,12 +320,12 @@ class SlicerTest < Test::Unit::TestCase
|
|
320
320
|
slicer.count >= 16
|
321
321
|
end
|
322
322
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
323
|
-
|
324
|
-
0
|
325
|
-
1
|
326
|
-
2
|
327
|
-
3
|
328
|
-
4
|
323
|
+
count visible
|
324
|
+
0 16 true
|
325
|
+
1 32 false
|
326
|
+
2 64 (null)
|
327
|
+
3 (null) (null)
|
328
|
+
4 256 true
|
329
329
|
TABLE
|
330
330
|
end
|
331
331
|
|
@@ -334,13 +334,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
334
334
|
!(slicer.count >= 16)
|
335
335
|
end
|
336
336
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
337
|
-
|
338
|
-
0
|
339
|
-
1
|
340
|
-
2
|
341
|
-
3
|
342
|
-
4
|
343
|
-
5
|
337
|
+
count visible
|
338
|
+
0 0 (null)
|
339
|
+
1 1 true
|
340
|
+
2 2 false
|
341
|
+
3 4 (null)
|
342
|
+
4 8 true
|
343
|
+
5 (null) (null)
|
344
344
|
TABLE
|
345
345
|
end
|
346
346
|
|
@@ -351,10 +351,9 @@ class SlicerTest < Test::Unit::TestCase
|
|
351
351
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
352
352
|
count visible
|
353
353
|
0 1 true
|
354
|
-
1 4
|
354
|
+
1 4 (null)
|
355
355
|
2 16 true
|
356
|
-
3 64
|
357
|
-
4
|
356
|
+
3 64 (null)
|
358
357
|
TABLE
|
359
358
|
end
|
360
359
|
|
@@ -363,13 +362,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
363
362
|
!slicer.count.in?([1, 4, 16, 64])
|
364
363
|
end
|
365
364
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
366
|
-
|
367
|
-
0
|
368
|
-
1
|
369
|
-
2
|
370
|
-
3
|
371
|
-
4
|
372
|
-
5
|
365
|
+
count visible
|
366
|
+
0 0 (null)
|
367
|
+
1 2 false
|
368
|
+
2 8 true
|
369
|
+
3 32 false
|
370
|
+
4 (null) (null)
|
371
|
+
5 256 true
|
373
372
|
TABLE
|
374
373
|
end
|
375
374
|
|
@@ -378,13 +377,13 @@ class SlicerTest < Test::Unit::TestCase
|
|
378
377
|
slicer.visible & (slicer.count >= 16)
|
379
378
|
end
|
380
379
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
381
|
-
|
382
|
-
0
|
383
|
-
1
|
384
|
-
2
|
385
|
-
3
|
386
|
-
4
|
387
|
-
5
|
380
|
+
count visible
|
381
|
+
0 (null) (null)
|
382
|
+
1 (null) (null)
|
383
|
+
2 16 true
|
384
|
+
3 (null) (null)
|
385
|
+
4 (null) (null)
|
386
|
+
5 256 true
|
388
387
|
TABLE
|
389
388
|
end
|
390
389
|
|
@@ -393,16 +392,16 @@ class SlicerTest < Test::Unit::TestCase
|
|
393
392
|
slicer.visible | (slicer.count >= 16)
|
394
393
|
end
|
395
394
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
396
|
-
|
397
|
-
0
|
398
|
-
1
|
399
|
-
2
|
400
|
-
3
|
401
|
-
4
|
402
|
-
5
|
403
|
-
6
|
404
|
-
7
|
405
|
-
8
|
395
|
+
count visible
|
396
|
+
0 (null) (null)
|
397
|
+
1 1 true
|
398
|
+
2 (null) (null)
|
399
|
+
3 8 true
|
400
|
+
4 16 true
|
401
|
+
5 32 false
|
402
|
+
6 (null) (null)
|
403
|
+
7 (null) (null)
|
404
|
+
8 256 true
|
406
405
|
TABLE
|
407
406
|
end
|
408
407
|
|
@@ -411,14 +410,14 @@ class SlicerTest < Test::Unit::TestCase
|
|
411
410
|
slicer.visible ^ (slicer.count >= 16)
|
412
411
|
end
|
413
412
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
414
|
-
|
415
|
-
0
|
416
|
-
1
|
417
|
-
2
|
418
|
-
3
|
419
|
-
4
|
420
|
-
5
|
421
|
-
6
|
413
|
+
count visible
|
414
|
+
0 (null) (null)
|
415
|
+
1 1 true
|
416
|
+
2 (null) (null)
|
417
|
+
3 8 true
|
418
|
+
4 32 false
|
419
|
+
5 (null) (null)
|
420
|
+
6 (null) (null)
|
422
421
|
TABLE
|
423
422
|
end
|
424
423
|
|
@@ -429,15 +428,15 @@ class SlicerTest < Test::Unit::TestCase
|
|
429
428
|
end
|
430
429
|
end
|
431
430
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
432
|
-
|
433
|
-
0
|
434
|
-
1
|
435
|
-
2
|
436
|
-
3
|
437
|
-
4
|
438
|
-
5
|
439
|
-
6
|
440
|
-
7
|
431
|
+
count visible
|
432
|
+
0 0 (null)
|
433
|
+
1 1 true
|
434
|
+
2 4 (null)
|
435
|
+
3 8 true
|
436
|
+
4 16 true
|
437
|
+
5 64 (null)
|
438
|
+
6 (null) (null)
|
439
|
+
7 256 true
|
441
440
|
TABLE
|
442
441
|
end
|
443
442
|
|
@@ -474,15 +473,15 @@ class SlicerTest < Test::Unit::TestCase
|
|
474
473
|
end
|
475
474
|
end
|
476
475
|
assert_equal(<<-TABLE, sliced_table.to_s)
|
477
|
-
|
478
|
-
0
|
479
|
-
1
|
480
|
-
2
|
481
|
-
3
|
482
|
-
4
|
483
|
-
5
|
484
|
-
6
|
485
|
-
7
|
476
|
+
count visible
|
477
|
+
0 0 (null)
|
478
|
+
1 1 true
|
479
|
+
2 4 (null)
|
480
|
+
3 8 true
|
481
|
+
4 16 true
|
482
|
+
5 64 (null)
|
483
|
+
6 (null) (null)
|
484
|
+
7 256 true
|
486
485
|
TABLE
|
487
486
|
end
|
488
487
|
end
|
@@ -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
|