red-arrow 18.1.0 → 19.0.1
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/lib/arrow/array.rb +7 -4
- data/lib/arrow/column.rb +4 -4
- data/lib/arrow/jruby/array-builder.rb +114 -0
- data/lib/arrow/jruby/array.rb +109 -0
- data/{test/helper/fixture.rb → lib/arrow/jruby/chunked-array.rb} +14 -6
- data/lib/arrow/jruby/compression-type.rb +26 -0
- data/{test/test-boolean-scalar.rb → lib/arrow/jruby/csv-read-options.rb} +12 -6
- data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
- data/lib/arrow/jruby/decimal128.rb +28 -0
- data/lib/arrow/jruby/decimal256.rb +28 -0
- data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/error.rb} +7 -4
- data/lib/arrow/jruby/file-system.rb +24 -0
- data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
- data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
- data/{test/fixture/integer-float.csv → lib/arrow/jruby/record-batch.rb} +8 -4
- data/{test/fixture/float-integer.csv → lib/arrow/jruby/sort-key.rb} +8 -4
- data/lib/arrow/jruby/sort-options.rb +24 -0
- data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
- data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
- data/lib/arrow/jruby/writable.rb +24 -0
- data/lib/arrow/jruby.rb +52 -0
- data/lib/arrow/libraries.rb +126 -0
- data/lib/arrow/list-array-builder.rb +1 -0
- data/lib/arrow/loader.rb +3 -111
- data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +6 -4
- data/lib/arrow/version.rb +1 -1
- data/lib/arrow.rb +2 -7
- data/red-arrow.gemspec +15 -6
- metadata +26 -229
- data/test/each-raw-record/test-basic-arrays.rb +0 -411
- data/test/each-raw-record/test-dense-union-array.rb +0 -566
- data/test/each-raw-record/test-dictionary-array.rb +0 -341
- data/test/each-raw-record/test-list-array.rb +0 -628
- data/test/each-raw-record/test-map-array.rb +0 -507
- data/test/each-raw-record/test-multiple-columns.rb +0 -72
- data/test/each-raw-record/test-sparse-union-array.rb +0 -528
- data/test/each-raw-record/test-struct-array.rb +0 -529
- data/test/each-raw-record/test-table.rb +0 -47
- data/test/fixture/TestOrcFile.test1.orc +0 -0
- data/test/fixture/with-header-float.csv +0 -20
- data/test/fixture/with-header.csv +0 -20
- data/test/fixture/without-header-float.csv +0 -19
- data/test/fixture/without-header.csv +0 -19
- data/test/helper/omittable.rb +0 -49
- data/test/helper.rb +0 -31
- data/test/raw-records/test-basic-arrays.rb +0 -405
- data/test/raw-records/test-dense-union-array.rb +0 -566
- data/test/raw-records/test-dictionary-array.rb +0 -341
- data/test/raw-records/test-list-array.rb +0 -628
- data/test/raw-records/test-map-array.rb +0 -507
- data/test/raw-records/test-multiple-columns.rb +0 -65
- data/test/raw-records/test-sparse-union-array.rb +0 -556
- data/test/raw-records/test-struct-array.rb +0 -529
- data/test/raw-records/test-table.rb +0 -47
- data/test/run-test.rb +0 -71
- data/test/test-array-builder.rb +0 -198
- data/test/test-array.rb +0 -332
- data/test/test-bigdecimal.rb +0 -40
- data/test/test-binary-dictionary-array-builder.rb +0 -103
- data/test/test-buffer.rb +0 -49
- data/test/test-chunked-array.rb +0 -198
- data/test/test-column.rb +0 -123
- data/test/test-csv-loader.rb +0 -297
- data/test/test-data-type.rb +0 -84
- data/test/test-date32-array.rb +0 -24
- data/test/test-date64-array.rb +0 -25
- data/test/test-decimal128-array-builder.rb +0 -126
- data/test/test-decimal128-array.rb +0 -47
- data/test/test-decimal128-data-type.rb +0 -31
- data/test/test-decimal128.rb +0 -126
- data/test/test-decimal256-array-builder.rb +0 -126
- data/test/test-decimal256-array.rb +0 -47
- data/test/test-decimal256-data-type.rb +0 -31
- data/test/test-decimal256.rb +0 -126
- data/test/test-dense-union-array.rb +0 -42
- data/test/test-dense-union-data-type.rb +0 -41
- data/test/test-dictionary-array.rb +0 -41
- data/test/test-dictionary-data-type.rb +0 -40
- data/test/test-expression.rb +0 -51
- data/test/test-feather.rb +0 -49
- data/test/test-field.rb +0 -117
- data/test/test-file-output-stream.rb +0 -54
- data/test/test-fixed-size-binary-array-builder.rb +0 -92
- data/test/test-fixed-size-binary-array.rb +0 -36
- data/test/test-float-scalar.rb +0 -46
- data/test/test-function.rb +0 -210
- data/test/test-group.rb +0 -193
- data/test/test-half-float-array.rb +0 -43
- data/test/test-half-float.rb +0 -130
- data/test/test-list-array-builder.rb +0 -79
- data/test/test-list-array.rb +0 -32
- data/test/test-list-data-type.rb +0 -69
- data/test/test-map-array-builder.rb +0 -110
- data/test/test-map-array.rb +0 -33
- data/test/test-memory-view.rb +0 -434
- data/test/test-orc.rb +0 -173
- data/test/test-ractor.rb +0 -34
- data/test/test-record-batch-builder.rb +0 -125
- data/test/test-record-batch-file-reader.rb +0 -136
- data/test/test-record-batch-iterator.rb +0 -37
- data/test/test-record-batch-reader.rb +0 -46
- data/test/test-record-batch-stream-reader.rb +0 -129
- data/test/test-record-batch.rb +0 -182
- data/test/test-scalar.rb +0 -65
- data/test/test-schema.rb +0 -134
- data/test/test-slicer.rb +0 -589
- data/test/test-sort-indices.rb +0 -40
- data/test/test-sort-key.rb +0 -81
- data/test/test-sort-options.rb +0 -58
- data/test/test-sparse-union-array.rb +0 -38
- data/test/test-sparse-union-data-type.rb +0 -41
- data/test/test-stream-listener.rb +0 -60
- data/test/test-string-dictionary-array-builder.rb +0 -103
- data/test/test-struct-array-builder.rb +0 -184
- data/test/test-struct-array.rb +0 -94
- data/test/test-struct-data-type.rb +0 -112
- data/test/test-table.rb +0 -1530
- data/test/test-tensor.rb +0 -297
- data/test/test-time.rb +0 -288
- data/test/test-time32-array.rb +0 -81
- data/test/test-time32-data-type.rb +0 -42
- data/test/test-time64-array.rb +0 -81
- data/test/test-time64-data-type.rb +0 -42
- data/test/test-timestamp-array.rb +0 -45
- data/test/test-timestamp-data-type.rb +0 -42
- data/test/values/test-basic-arrays.rb +0 -335
- data/test/values/test-dense-union-array.rb +0 -552
- data/test/values/test-dictionary-array.rb +0 -325
- data/test/values/test-list-array.rb +0 -587
- data/test/values/test-map-array.rb +0 -489
- data/test/values/test-sparse-union-array.rb +0 -543
- data/test/values/test-struct-array.rb +0 -524
data/test/test-slicer.rb
DELETED
@@ -1,589 +0,0 @@
|
|
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 SlicerTest < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
@count_field = Arrow::Field.new("count", :uint32)
|
21
|
-
@visible_field = Arrow::Field.new("visible", :boolean)
|
22
|
-
schema = Arrow::Schema.new([@count_field, @visible_field])
|
23
|
-
count_arrays = [
|
24
|
-
Arrow::UInt32Array.new([0, 1, 2]),
|
25
|
-
Arrow::UInt32Array.new([4, 8, 16]),
|
26
|
-
Arrow::UInt32Array.new([32, 64, nil]),
|
27
|
-
Arrow::UInt32Array.new([256]),
|
28
|
-
]
|
29
|
-
visible_arrays = [
|
30
|
-
Arrow::BooleanArray.new([nil, true, false, nil]),
|
31
|
-
Arrow::BooleanArray.new([true]),
|
32
|
-
Arrow::BooleanArray.new([true, false]),
|
33
|
-
Arrow::BooleanArray.new([nil]),
|
34
|
-
Arrow::BooleanArray.new([nil]),
|
35
|
-
Arrow::BooleanArray.new([true]),
|
36
|
-
]
|
37
|
-
@count_array = Arrow::ChunkedArray.new(count_arrays)
|
38
|
-
@visible_array = Arrow::ChunkedArray.new(visible_arrays)
|
39
|
-
@table = Arrow::Table.new(schema, [@count_array, @visible_array])
|
40
|
-
end
|
41
|
-
|
42
|
-
sub_test_case("column") do
|
43
|
-
test("BooleanArray") do
|
44
|
-
sliced_table = @table.slice do |slicer|
|
45
|
-
slicer.visible
|
46
|
-
end
|
47
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
48
|
-
count visible
|
49
|
-
(uint32) (bool)
|
50
|
-
0 1 true
|
51
|
-
1 8 true
|
52
|
-
2 16 true
|
53
|
-
3 256 true
|
54
|
-
TABLE
|
55
|
-
end
|
56
|
-
|
57
|
-
test("not BooleanArray") do
|
58
|
-
sliced_table = @table.slice do |slicer|
|
59
|
-
slicer.count
|
60
|
-
end
|
61
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
62
|
-
count visible
|
63
|
-
(uint32) (bool)
|
64
|
-
0 1 true
|
65
|
-
1 2 false
|
66
|
-
2 4 (null)
|
67
|
-
3 8 true
|
68
|
-
4 16 true
|
69
|
-
5 32 false
|
70
|
-
6 64 (null)
|
71
|
-
7 256 true
|
72
|
-
TABLE
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
sub_test_case("!column") do
|
77
|
-
test("BooleanArray") do
|
78
|
-
sliced_table = @table.slice do |slicer|
|
79
|
-
!slicer.visible
|
80
|
-
end
|
81
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
82
|
-
count visible
|
83
|
-
(uint32) (bool)
|
84
|
-
0 2 false
|
85
|
-
1 32 false
|
86
|
-
TABLE
|
87
|
-
end
|
88
|
-
|
89
|
-
test("not BooleanArray") do
|
90
|
-
sliced_table = @table.slice do |slicer|
|
91
|
-
!slicer.count
|
92
|
-
end
|
93
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
94
|
-
count visible
|
95
|
-
(uint32) (bool)
|
96
|
-
0 0 (null)
|
97
|
-
TABLE
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
test("column.null?") do
|
102
|
-
sliced_table = @table.slice do |slicer|
|
103
|
-
slicer.visible.null?
|
104
|
-
end
|
105
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
106
|
-
count visible
|
107
|
-
(uint32) (bool)
|
108
|
-
0 0 (null)
|
109
|
-
1 4 (null)
|
110
|
-
2 64 (null)
|
111
|
-
3 (null) (null)
|
112
|
-
TABLE
|
113
|
-
end
|
114
|
-
|
115
|
-
test("column.valid?") do
|
116
|
-
sliced_table = @table.slice do |slicer|
|
117
|
-
slicer.visible.valid?
|
118
|
-
end
|
119
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
120
|
-
count visible
|
121
|
-
(uint32) (bool)
|
122
|
-
0 1 true
|
123
|
-
1 2 false
|
124
|
-
2 8 true
|
125
|
-
3 16 true
|
126
|
-
4 32 false
|
127
|
-
5 256 true
|
128
|
-
TABLE
|
129
|
-
end
|
130
|
-
|
131
|
-
sub_test_case("column ==") do
|
132
|
-
test("nil") do
|
133
|
-
sliced_table = @table.slice do |slicer|
|
134
|
-
slicer.visible == nil
|
135
|
-
end
|
136
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
137
|
-
count visible
|
138
|
-
(uint32) (bool)
|
139
|
-
0 0 (null)
|
140
|
-
1 4 (null)
|
141
|
-
2 64 (null)
|
142
|
-
3 (null) (null)
|
143
|
-
TABLE
|
144
|
-
end
|
145
|
-
|
146
|
-
test("value") do
|
147
|
-
sliced_table = @table.slice do |slicer|
|
148
|
-
slicer.visible == true
|
149
|
-
end
|
150
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
151
|
-
count visible
|
152
|
-
(uint32) (bool)
|
153
|
-
0 1 true
|
154
|
-
1 8 true
|
155
|
-
2 16 true
|
156
|
-
3 256 true
|
157
|
-
TABLE
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
sub_test_case("!(column ==)") do
|
162
|
-
test("nil") do
|
163
|
-
sliced_table = @table.slice do |slicer|
|
164
|
-
!(slicer.visible == nil)
|
165
|
-
end
|
166
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
167
|
-
count visible
|
168
|
-
(uint32) (bool)
|
169
|
-
0 1 true
|
170
|
-
1 2 false
|
171
|
-
2 8 true
|
172
|
-
3 16 true
|
173
|
-
4 32 false
|
174
|
-
5 256 true
|
175
|
-
TABLE
|
176
|
-
end
|
177
|
-
|
178
|
-
test("value") do
|
179
|
-
sliced_table = @table.slice do |slicer|
|
180
|
-
!(slicer.visible == true)
|
181
|
-
end
|
182
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
183
|
-
count visible
|
184
|
-
(uint32) (bool)
|
185
|
-
0 2 false
|
186
|
-
1 32 false
|
187
|
-
TABLE
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
sub_test_case("column !=") do
|
192
|
-
test("nil") do
|
193
|
-
sliced_table = @table.slice do |slicer|
|
194
|
-
slicer.visible != nil
|
195
|
-
end
|
196
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
197
|
-
count visible
|
198
|
-
(uint32) (bool)
|
199
|
-
0 1 true
|
200
|
-
1 2 false
|
201
|
-
2 8 true
|
202
|
-
3 16 true
|
203
|
-
4 32 false
|
204
|
-
5 256 true
|
205
|
-
TABLE
|
206
|
-
end
|
207
|
-
|
208
|
-
test("value") do
|
209
|
-
sliced_table = @table.slice do |slicer|
|
210
|
-
slicer.visible != true
|
211
|
-
end
|
212
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
213
|
-
count visible
|
214
|
-
(uint32) (bool)
|
215
|
-
0 2 false
|
216
|
-
1 32 false
|
217
|
-
TABLE
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
test("column < value") do
|
222
|
-
sliced_table = @table.slice do |slicer|
|
223
|
-
slicer.count < 16
|
224
|
-
end
|
225
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
226
|
-
count visible
|
227
|
-
(uint32) (bool)
|
228
|
-
0 0 (null)
|
229
|
-
1 1 true
|
230
|
-
2 2 false
|
231
|
-
3 4 (null)
|
232
|
-
4 8 true
|
233
|
-
TABLE
|
234
|
-
end
|
235
|
-
|
236
|
-
test("!(column < value)") do
|
237
|
-
sliced_table = @table.slice do |slicer|
|
238
|
-
!(slicer.count < 16)
|
239
|
-
end
|
240
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
241
|
-
count visible
|
242
|
-
(uint32) (bool)
|
243
|
-
0 16 true
|
244
|
-
1 32 false
|
245
|
-
2 64 (null)
|
246
|
-
3 256 true
|
247
|
-
TABLE
|
248
|
-
end
|
249
|
-
|
250
|
-
test("column <= value") do
|
251
|
-
sliced_table = @table.slice do |slicer|
|
252
|
-
slicer.count <= 16
|
253
|
-
end
|
254
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
255
|
-
count visible
|
256
|
-
(uint32) (bool)
|
257
|
-
0 0 (null)
|
258
|
-
1 1 true
|
259
|
-
2 2 false
|
260
|
-
3 4 (null)
|
261
|
-
4 8 true
|
262
|
-
5 16 true
|
263
|
-
TABLE
|
264
|
-
end
|
265
|
-
|
266
|
-
test("!(column <= value)") do
|
267
|
-
sliced_table = @table.slice do |slicer|
|
268
|
-
!(slicer.count <= 16)
|
269
|
-
end
|
270
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
271
|
-
count visible
|
272
|
-
(uint32) (bool)
|
273
|
-
0 32 false
|
274
|
-
1 64 (null)
|
275
|
-
2 256 true
|
276
|
-
TABLE
|
277
|
-
end
|
278
|
-
|
279
|
-
test("column > value") do
|
280
|
-
sliced_table = @table.slice do |slicer|
|
281
|
-
slicer.count > 16
|
282
|
-
end
|
283
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
284
|
-
count visible
|
285
|
-
(uint32) (bool)
|
286
|
-
0 32 false
|
287
|
-
1 64 (null)
|
288
|
-
2 256 true
|
289
|
-
TABLE
|
290
|
-
end
|
291
|
-
|
292
|
-
test("!(column > value)") do
|
293
|
-
sliced_table = @table.slice do |slicer|
|
294
|
-
!(slicer.count > 16)
|
295
|
-
end
|
296
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
297
|
-
count visible
|
298
|
-
(uint32) (bool)
|
299
|
-
0 0 (null)
|
300
|
-
1 1 true
|
301
|
-
2 2 false
|
302
|
-
3 4 (null)
|
303
|
-
4 8 true
|
304
|
-
5 16 true
|
305
|
-
TABLE
|
306
|
-
end
|
307
|
-
|
308
|
-
test("column >= value") do
|
309
|
-
sliced_table = @table.slice do |slicer|
|
310
|
-
slicer.count >= 16
|
311
|
-
end
|
312
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
313
|
-
count visible
|
314
|
-
(uint32) (bool)
|
315
|
-
0 16 true
|
316
|
-
1 32 false
|
317
|
-
2 64 (null)
|
318
|
-
3 256 true
|
319
|
-
TABLE
|
320
|
-
end
|
321
|
-
|
322
|
-
test("!(column >= value)") do
|
323
|
-
sliced_table = @table.slice do |slicer|
|
324
|
-
!(slicer.count >= 16)
|
325
|
-
end
|
326
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
327
|
-
count visible
|
328
|
-
(uint32) (bool)
|
329
|
-
0 0 (null)
|
330
|
-
1 1 true
|
331
|
-
2 2 false
|
332
|
-
3 4 (null)
|
333
|
-
4 8 true
|
334
|
-
TABLE
|
335
|
-
end
|
336
|
-
|
337
|
-
test("column.in") do
|
338
|
-
sliced_table = @table.slice do |slicer|
|
339
|
-
slicer.count.in?([1, 4, 16, 64])
|
340
|
-
end
|
341
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
342
|
-
count visible
|
343
|
-
(uint32) (bool)
|
344
|
-
0 1 true
|
345
|
-
1 4 (null)
|
346
|
-
2 16 true
|
347
|
-
3 64 (null)
|
348
|
-
TABLE
|
349
|
-
end
|
350
|
-
|
351
|
-
test("!column.in") do
|
352
|
-
sliced_table = @table.slice do |slicer|
|
353
|
-
!slicer.count.in?([1, 4, 16, 64])
|
354
|
-
end
|
355
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
356
|
-
count visible
|
357
|
-
(uint32) (bool)
|
358
|
-
0 0 (null)
|
359
|
-
1 2 false
|
360
|
-
2 8 true
|
361
|
-
3 32 false
|
362
|
-
4 (null) (null)
|
363
|
-
5 256 true
|
364
|
-
TABLE
|
365
|
-
end
|
366
|
-
|
367
|
-
test("condition & condition") do
|
368
|
-
sliced_table = @table.slice do |slicer|
|
369
|
-
slicer.visible & (slicer.count >= 16)
|
370
|
-
end
|
371
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
372
|
-
count visible
|
373
|
-
(uint32) (bool)
|
374
|
-
0 16 true
|
375
|
-
1 256 true
|
376
|
-
TABLE
|
377
|
-
end
|
378
|
-
|
379
|
-
test("condition | condition") do
|
380
|
-
sliced_table = @table.slice do |slicer|
|
381
|
-
slicer.visible | (slicer.count >= 16)
|
382
|
-
end
|
383
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
384
|
-
count visible
|
385
|
-
(uint32) (bool)
|
386
|
-
0 1 true
|
387
|
-
1 8 true
|
388
|
-
2 16 true
|
389
|
-
3 32 false
|
390
|
-
4 256 true
|
391
|
-
TABLE
|
392
|
-
end
|
393
|
-
|
394
|
-
test("condition ^ condition") do
|
395
|
-
sliced_table = @table.slice do |slicer|
|
396
|
-
slicer.visible ^ (slicer.count >= 16)
|
397
|
-
end
|
398
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
399
|
-
count visible
|
400
|
-
(uint32) (bool)
|
401
|
-
0 1 true
|
402
|
-
1 8 true
|
403
|
-
2 32 false
|
404
|
-
TABLE
|
405
|
-
end
|
406
|
-
|
407
|
-
test("select") do
|
408
|
-
sliced_table = @table.slice do |slicer|
|
409
|
-
slicer.visible.select do |value|
|
410
|
-
value.nil? or value
|
411
|
-
end
|
412
|
-
end
|
413
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
414
|
-
count visible
|
415
|
-
(uint32) (bool)
|
416
|
-
0 0 (null)
|
417
|
-
1 1 true
|
418
|
-
2 4 (null)
|
419
|
-
3 8 true
|
420
|
-
4 16 true
|
421
|
-
5 64 (null)
|
422
|
-
6 (null) (null)
|
423
|
-
7 256 true
|
424
|
-
TABLE
|
425
|
-
end
|
426
|
-
|
427
|
-
test("!select") do
|
428
|
-
sliced_table = @table.slice do |slicer|
|
429
|
-
!slicer.visible.select do |value|
|
430
|
-
value.nil? or value
|
431
|
-
end
|
432
|
-
end
|
433
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
434
|
-
count visible
|
435
|
-
(uint32) (bool)
|
436
|
-
0 2 false
|
437
|
-
1 32 false
|
438
|
-
TABLE
|
439
|
-
end
|
440
|
-
|
441
|
-
test("reject") do
|
442
|
-
sliced_table = @table.slice do |slicer|
|
443
|
-
slicer.visible.reject do |value|
|
444
|
-
value.nil? or value
|
445
|
-
end
|
446
|
-
end
|
447
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
448
|
-
count visible
|
449
|
-
(uint32) (bool)
|
450
|
-
0 2 false
|
451
|
-
1 32 false
|
452
|
-
TABLE
|
453
|
-
end
|
454
|
-
|
455
|
-
test("!reject") do
|
456
|
-
sliced_table = @table.slice do |slicer|
|
457
|
-
!slicer.visible.reject do |value|
|
458
|
-
value.nil? or value
|
459
|
-
end
|
460
|
-
end
|
461
|
-
assert_equal(<<-TABLE, sliced_table.to_s)
|
462
|
-
count visible
|
463
|
-
(uint32) (bool)
|
464
|
-
0 0 (null)
|
465
|
-
1 1 true
|
466
|
-
2 4 (null)
|
467
|
-
3 8 true
|
468
|
-
4 16 true
|
469
|
-
5 64 (null)
|
470
|
-
6 (null) (null)
|
471
|
-
7 256 true
|
472
|
-
TABLE
|
473
|
-
end
|
474
|
-
|
475
|
-
sub_test_case "MatchSubstringOptions family" do
|
476
|
-
def setup
|
477
|
-
@table = Arrow::Table.new(
|
478
|
-
string: ["array", "Arrow", "carrot", nil, "window"]
|
479
|
-
)
|
480
|
-
end
|
481
|
-
|
482
|
-
test("end_with?") do
|
483
|
-
sliced_table = @table.slice do |slicer|
|
484
|
-
slicer.string.end_with?("ow")
|
485
|
-
end
|
486
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
487
|
-
string
|
488
|
-
(utf8)
|
489
|
-
0 Arrow
|
490
|
-
1 window
|
491
|
-
TABLE
|
492
|
-
end
|
493
|
-
|
494
|
-
test("match_like?") do
|
495
|
-
sliced_table = @table.slice do |slicer|
|
496
|
-
slicer.string.match_like?("_rr%")
|
497
|
-
end
|
498
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
499
|
-
string
|
500
|
-
(utf8)
|
501
|
-
0 array
|
502
|
-
1 Arrow
|
503
|
-
TABLE
|
504
|
-
end
|
505
|
-
|
506
|
-
test("match_substring?") do
|
507
|
-
sliced_table = @table.slice do |slicer|
|
508
|
-
slicer.string.match_substring?("arr")
|
509
|
-
end
|
510
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
511
|
-
string
|
512
|
-
(utf8)
|
513
|
-
0 array
|
514
|
-
1 carrot
|
515
|
-
TABLE
|
516
|
-
end
|
517
|
-
|
518
|
-
test("match_substring?(ignore_case:)") do
|
519
|
-
sliced_table = @table.slice do |slicer|
|
520
|
-
slicer.string.match_substring?("arr", ignore_case: true)
|
521
|
-
end
|
522
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
523
|
-
string
|
524
|
-
(utf8)
|
525
|
-
0 array
|
526
|
-
1 Arrow
|
527
|
-
2 carrot
|
528
|
-
TABLE
|
529
|
-
end
|
530
|
-
|
531
|
-
test("!match_substring?") do
|
532
|
-
sliced_table = @table.slice do |slicer|
|
533
|
-
!slicer.string.match_substring?("arr")
|
534
|
-
end
|
535
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
536
|
-
string
|
537
|
-
(utf8)
|
538
|
-
0 Arrow
|
539
|
-
1 window
|
540
|
-
TABLE
|
541
|
-
end
|
542
|
-
|
543
|
-
test("match_substring?(Regexp)") do
|
544
|
-
sliced_table = @table.slice do |slicer|
|
545
|
-
slicer.string.match_substring?(/[dr]ow/)
|
546
|
-
end
|
547
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
548
|
-
string
|
549
|
-
(utf8)
|
550
|
-
0 Arrow
|
551
|
-
1 window
|
552
|
-
TABLE
|
553
|
-
end
|
554
|
-
|
555
|
-
test("match_substring?(/String/i)") do
|
556
|
-
sliced_table = @table.slice do |slicer|
|
557
|
-
slicer.string.match_substring?(/arr/i)
|
558
|
-
end
|
559
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
560
|
-
string
|
561
|
-
(utf8)
|
562
|
-
0 array
|
563
|
-
1 Arrow
|
564
|
-
2 carrot
|
565
|
-
TABLE
|
566
|
-
end
|
567
|
-
|
568
|
-
test("match_substring? - invalid") do
|
569
|
-
message =
|
570
|
-
'pattern must be either String or Regexp: ["arr"]'
|
571
|
-
assert_raise(ArgumentError.new(message)) do
|
572
|
-
@table.slice do |slicer|
|
573
|
-
slicer.string.match_substring?(["arr"])
|
574
|
-
end
|
575
|
-
end
|
576
|
-
end
|
577
|
-
|
578
|
-
test("start_with?") do
|
579
|
-
sliced_table = @table.slice do |slicer|
|
580
|
-
slicer.string.start_with?("ca")
|
581
|
-
end
|
582
|
-
assert_equal(<<~TABLE, sliced_table.to_s)
|
583
|
-
string
|
584
|
-
(utf8)
|
585
|
-
0 carrot
|
586
|
-
TABLE
|
587
|
-
end
|
588
|
-
end
|
589
|
-
end
|
data/test/test-sort-indices.rb
DELETED
@@ -1,40 +0,0 @@
|
|
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
|
data/test/test-sort-key.rb
DELETED
@@ -1,81 +0,0 @@
|
|
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
|