red-arrow 18.1.0 → 19.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 +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
@@ -1,529 +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
|
-
module RawRecordsStructArrayTests
|
19
|
-
def build_schema(type)
|
20
|
-
field_description = {
|
21
|
-
name: :field,
|
22
|
-
}
|
23
|
-
if type.is_a?(Hash)
|
24
|
-
field_description = field_description.merge(type)
|
25
|
-
else
|
26
|
-
field_description[:type] = type
|
27
|
-
end
|
28
|
-
{
|
29
|
-
column: {
|
30
|
-
type: :struct,
|
31
|
-
fields: [
|
32
|
-
field_description,
|
33
|
-
],
|
34
|
-
},
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_null
|
39
|
-
records = [
|
40
|
-
[{"field" => nil}],
|
41
|
-
[nil],
|
42
|
-
]
|
43
|
-
target = build(:null, records)
|
44
|
-
assert_equal(records, target.raw_records)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_boolean
|
48
|
-
records = [
|
49
|
-
[{"field" => true}],
|
50
|
-
[nil],
|
51
|
-
[{"field" => nil}],
|
52
|
-
]
|
53
|
-
target = build(:boolean, records)
|
54
|
-
assert_equal(records, target.raw_records)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_int8
|
58
|
-
records = [
|
59
|
-
[{"field" => -(2 ** 7)}],
|
60
|
-
[nil],
|
61
|
-
[{"field" => nil}],
|
62
|
-
]
|
63
|
-
target = build(:int8, records)
|
64
|
-
assert_equal(records, target.raw_records)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_uint8
|
68
|
-
records = [
|
69
|
-
[{"field" => (2 ** 8) - 1}],
|
70
|
-
[nil],
|
71
|
-
[{"field" => nil}],
|
72
|
-
]
|
73
|
-
target = build(:uint8, records)
|
74
|
-
assert_equal(records, target.raw_records)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_int16
|
78
|
-
records = [
|
79
|
-
[{"field" => -(2 ** 15)}],
|
80
|
-
[nil],
|
81
|
-
[{"field" => nil}],
|
82
|
-
]
|
83
|
-
target = build(:int16, records)
|
84
|
-
assert_equal(records, target.raw_records)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_uint16
|
88
|
-
records = [
|
89
|
-
[{"field" => (2 ** 16) - 1}],
|
90
|
-
[nil],
|
91
|
-
[{"field" => nil}],
|
92
|
-
]
|
93
|
-
target = build(:uint16, records)
|
94
|
-
assert_equal(records, target.raw_records)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_int32
|
98
|
-
records = [
|
99
|
-
[{"field" => -(2 ** 31)}],
|
100
|
-
[nil],
|
101
|
-
[{"field" => nil}],
|
102
|
-
]
|
103
|
-
target = build(:int32, records)
|
104
|
-
assert_equal(records, target.raw_records)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_uint32
|
108
|
-
records = [
|
109
|
-
[{"field" => (2 ** 32) - 1}],
|
110
|
-
[nil],
|
111
|
-
[{"field" => nil}],
|
112
|
-
]
|
113
|
-
target = build(:uint32, records)
|
114
|
-
assert_equal(records, target.raw_records)
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_int64
|
118
|
-
records = [
|
119
|
-
[{"field" => -(2 ** 63)}],
|
120
|
-
[nil],
|
121
|
-
[{"field" => nil}],
|
122
|
-
]
|
123
|
-
target = build(:int64, records)
|
124
|
-
assert_equal(records, target.raw_records)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_uint64
|
128
|
-
records = [
|
129
|
-
[{"field" => (2 ** 64) - 1}],
|
130
|
-
[nil],
|
131
|
-
[{"field" => nil}],
|
132
|
-
]
|
133
|
-
target = build(:uint64, records)
|
134
|
-
assert_equal(records, target.raw_records)
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_float
|
138
|
-
records = [
|
139
|
-
[{"field" => -1.0}],
|
140
|
-
[nil],
|
141
|
-
[{"field" => nil}],
|
142
|
-
]
|
143
|
-
target = build(:float, records)
|
144
|
-
assert_equal(records, target.raw_records)
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_double
|
148
|
-
records = [
|
149
|
-
[{"field" => -1.0}],
|
150
|
-
[nil],
|
151
|
-
[{"field" => nil}],
|
152
|
-
]
|
153
|
-
target = build(:double, records)
|
154
|
-
assert_equal(records, target.raw_records)
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_binary
|
158
|
-
records = [
|
159
|
-
[{"field" => "\xff".b}],
|
160
|
-
[nil],
|
161
|
-
[{"field" => nil}],
|
162
|
-
]
|
163
|
-
target = build(:binary, records)
|
164
|
-
assert_equal(records, target.raw_records)
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_string
|
168
|
-
records = [
|
169
|
-
[{"field" => "Ruby"}],
|
170
|
-
[nil],
|
171
|
-
[{"field" => nil}],
|
172
|
-
]
|
173
|
-
target = build(:string, records)
|
174
|
-
assert_equal(records, target.raw_records)
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_date32
|
178
|
-
records = [
|
179
|
-
[{"field" => Date.new(1960, 1, 1)}],
|
180
|
-
[nil],
|
181
|
-
[{"field" => nil}],
|
182
|
-
]
|
183
|
-
target = build(:date32, records)
|
184
|
-
assert_equal(records, target.raw_records)
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_date64
|
188
|
-
records = [
|
189
|
-
[{"field" => DateTime.new(1960, 1, 1, 2, 9, 30)}],
|
190
|
-
[nil],
|
191
|
-
[{"field" => nil}],
|
192
|
-
]
|
193
|
-
target = build(:date64, records)
|
194
|
-
assert_equal(records, target.raw_records)
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_timestamp_second
|
198
|
-
records = [
|
199
|
-
[{"field" => Time.parse("1960-01-01T02:09:30Z")}],
|
200
|
-
[nil],
|
201
|
-
[{"field" => nil}],
|
202
|
-
]
|
203
|
-
target = build({
|
204
|
-
type: :timestamp,
|
205
|
-
unit: :second,
|
206
|
-
},
|
207
|
-
records)
|
208
|
-
assert_equal(records, target.raw_records)
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_timestamp_milli
|
212
|
-
records = [
|
213
|
-
[{"field" => Time.parse("1960-01-01T02:09:30.123Z")}],
|
214
|
-
[nil],
|
215
|
-
[{"field" => nil}],
|
216
|
-
]
|
217
|
-
target = build({
|
218
|
-
type: :timestamp,
|
219
|
-
unit: :milli,
|
220
|
-
},
|
221
|
-
records)
|
222
|
-
assert_equal(records, target.raw_records)
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_timestamp_micro
|
226
|
-
records = [
|
227
|
-
[{"field" => Time.parse("1960-01-01T02:09:30.123456Z")}],
|
228
|
-
[nil],
|
229
|
-
[{"field" => nil}],
|
230
|
-
]
|
231
|
-
target = build({
|
232
|
-
type: :timestamp,
|
233
|
-
unit: :micro,
|
234
|
-
},
|
235
|
-
records)
|
236
|
-
assert_equal(records, target.raw_records)
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_timestamp_nano
|
240
|
-
records = [
|
241
|
-
[{"field" => Time.parse("1960-01-01T02:09:30.123456789Z")}],
|
242
|
-
[nil],
|
243
|
-
[{"field" => nil}],
|
244
|
-
]
|
245
|
-
target = build({
|
246
|
-
type: :timestamp,
|
247
|
-
unit: :nano,
|
248
|
-
},
|
249
|
-
records)
|
250
|
-
assert_equal(records, target.raw_records)
|
251
|
-
end
|
252
|
-
|
253
|
-
def test_time32_second
|
254
|
-
unit = Arrow::TimeUnit::SECOND
|
255
|
-
records = [
|
256
|
-
# 00:10:00
|
257
|
-
[{"field" => Arrow::Time.new(unit, 60 * 10)}],
|
258
|
-
[nil],
|
259
|
-
[{"field" => nil}],
|
260
|
-
]
|
261
|
-
target = build({
|
262
|
-
type: :time32,
|
263
|
-
unit: :second,
|
264
|
-
},
|
265
|
-
records)
|
266
|
-
assert_equal(records, target.raw_records)
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_time32_milli
|
270
|
-
unit = Arrow::TimeUnit::MILLI
|
271
|
-
records = [
|
272
|
-
# 00:10:00.123
|
273
|
-
[{"field" => Arrow::Time.new(unit, (60 * 10) * 1000 + 123)}],
|
274
|
-
[nil],
|
275
|
-
[{"field" => nil}],
|
276
|
-
]
|
277
|
-
target = build({
|
278
|
-
type: :time32,
|
279
|
-
unit: :milli,
|
280
|
-
},
|
281
|
-
records)
|
282
|
-
assert_equal(records, target.raw_records)
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_time64_micro
|
286
|
-
unit = Arrow::TimeUnit::MICRO
|
287
|
-
records = [
|
288
|
-
# 00:10:00.123456
|
289
|
-
[{"field" => Arrow::Time.new(unit, (60 * 10) * 1_000_000 + 123_456)}],
|
290
|
-
[nil],
|
291
|
-
[{"field" => nil}],
|
292
|
-
]
|
293
|
-
target = build({
|
294
|
-
type: :time64,
|
295
|
-
unit: :micro,
|
296
|
-
},
|
297
|
-
records)
|
298
|
-
assert_equal(records, target.raw_records)
|
299
|
-
end
|
300
|
-
|
301
|
-
def test_time64_nano
|
302
|
-
unit = Arrow::TimeUnit::NANO
|
303
|
-
records = [
|
304
|
-
# 00:10:00.123456789
|
305
|
-
[{"field" => Arrow::Time.new(unit, (60 * 10) * 1_000_000_000 + 123_456_789)}],
|
306
|
-
[nil],
|
307
|
-
[{"field" => nil}],
|
308
|
-
]
|
309
|
-
target = build({
|
310
|
-
type: :time64,
|
311
|
-
unit: :nano,
|
312
|
-
},
|
313
|
-
records)
|
314
|
-
assert_equal(records, target.raw_records)
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_decimal128
|
318
|
-
records = [
|
319
|
-
[{"field" => BigDecimal("92.92")}],
|
320
|
-
[nil],
|
321
|
-
[{"field" => nil}],
|
322
|
-
]
|
323
|
-
target = build({
|
324
|
-
type: :decimal128,
|
325
|
-
precision: 8,
|
326
|
-
scale: 2,
|
327
|
-
},
|
328
|
-
records)
|
329
|
-
assert_equal(records, target.raw_records)
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_decimal256
|
333
|
-
records = [
|
334
|
-
[{"field" => BigDecimal("92.92")}],
|
335
|
-
[nil],
|
336
|
-
[{"field" => nil}],
|
337
|
-
]
|
338
|
-
target = build({
|
339
|
-
type: :decimal256,
|
340
|
-
precision: 38,
|
341
|
-
scale: 2,
|
342
|
-
},
|
343
|
-
records)
|
344
|
-
assert_equal(records, target.raw_records)
|
345
|
-
end
|
346
|
-
|
347
|
-
def test_month_interval
|
348
|
-
records = [
|
349
|
-
[{"field" => 1}],
|
350
|
-
[nil],
|
351
|
-
[{"field" => nil}],
|
352
|
-
]
|
353
|
-
target = build(:month_interval, records)
|
354
|
-
assert_equal(records, target.raw_records)
|
355
|
-
end
|
356
|
-
|
357
|
-
def test_day_time_interval
|
358
|
-
records = [
|
359
|
-
[{"field" => {day: 1, millisecond: 100}}],
|
360
|
-
[nil],
|
361
|
-
[{"field" => nil}],
|
362
|
-
]
|
363
|
-
target = build(:day_time_interval, records)
|
364
|
-
assert_equal(records, target.raw_records)
|
365
|
-
end
|
366
|
-
|
367
|
-
def test_month_day_nano_interval
|
368
|
-
records = [
|
369
|
-
[{"field" => {month: 1, day: 1, nanosecond: 100}}],
|
370
|
-
[nil],
|
371
|
-
[{"field" => nil}],
|
372
|
-
]
|
373
|
-
target = build(:month_day_nano_interval, records)
|
374
|
-
assert_equal(records, target.raw_records)
|
375
|
-
end
|
376
|
-
|
377
|
-
def test_list
|
378
|
-
records = [
|
379
|
-
[{"field" => [true, nil, false]}],
|
380
|
-
[nil],
|
381
|
-
[{"field" => nil}],
|
382
|
-
]
|
383
|
-
target = build({
|
384
|
-
type: :list,
|
385
|
-
field: {
|
386
|
-
name: :sub_element,
|
387
|
-
type: :boolean,
|
388
|
-
},
|
389
|
-
},
|
390
|
-
records)
|
391
|
-
assert_equal(records, target.raw_records)
|
392
|
-
end
|
393
|
-
|
394
|
-
def test_struct
|
395
|
-
records = [
|
396
|
-
[{"field" => {"sub_field" => true}}],
|
397
|
-
[nil],
|
398
|
-
[{"field" => nil}],
|
399
|
-
[{"field" => {"sub_field" => nil}}],
|
400
|
-
]
|
401
|
-
target = build({
|
402
|
-
type: :struct,
|
403
|
-
fields: [
|
404
|
-
{
|
405
|
-
name: :sub_field,
|
406
|
-
type: :boolean,
|
407
|
-
},
|
408
|
-
],
|
409
|
-
},
|
410
|
-
records)
|
411
|
-
assert_equal(records, target.raw_records)
|
412
|
-
end
|
413
|
-
|
414
|
-
def test_map
|
415
|
-
records = [
|
416
|
-
[{"field" => {"key1" => true, "key2" => nil}}],
|
417
|
-
[nil],
|
418
|
-
[{"field" => nil}],
|
419
|
-
]
|
420
|
-
target = build({
|
421
|
-
type: :map,
|
422
|
-
key: :string,
|
423
|
-
item: :boolean,
|
424
|
-
},
|
425
|
-
records)
|
426
|
-
assert_equal(records, target.raw_records)
|
427
|
-
end
|
428
|
-
|
429
|
-
def remove_union_field_names(records)
|
430
|
-
records.collect do |record|
|
431
|
-
record.collect do |column|
|
432
|
-
if column.nil?
|
433
|
-
column
|
434
|
-
else
|
435
|
-
value = column["field"]
|
436
|
-
value = value.values[0] unless value.nil?
|
437
|
-
{"field" => value}
|
438
|
-
end
|
439
|
-
end
|
440
|
-
end
|
441
|
-
end
|
442
|
-
|
443
|
-
def test_sparse_union
|
444
|
-
records = [
|
445
|
-
[{"field" => {"field1" => true}}],
|
446
|
-
[nil],
|
447
|
-
[{"field" => nil}],
|
448
|
-
[{"field" => {"field2" => 29}}],
|
449
|
-
[{"field" => {"field2" => nil}}],
|
450
|
-
]
|
451
|
-
target = build({
|
452
|
-
type: :sparse_union,
|
453
|
-
fields: [
|
454
|
-
{
|
455
|
-
name: :field1,
|
456
|
-
type: :boolean,
|
457
|
-
},
|
458
|
-
{
|
459
|
-
name: :field2,
|
460
|
-
type: :uint8,
|
461
|
-
},
|
462
|
-
],
|
463
|
-
type_codes: [0, 1],
|
464
|
-
},
|
465
|
-
records)
|
466
|
-
assert_equal(remove_union_field_names(records),
|
467
|
-
target.raw_records)
|
468
|
-
end
|
469
|
-
|
470
|
-
def test_dense_union
|
471
|
-
records = [
|
472
|
-
[{"field" => {"field1" => true}}],
|
473
|
-
[nil],
|
474
|
-
[{"field" => nil}],
|
475
|
-
[{"field" => {"field2" => 29}}],
|
476
|
-
[{"field" => {"field2" => nil}}],
|
477
|
-
]
|
478
|
-
target = build({
|
479
|
-
type: :dense_union,
|
480
|
-
fields: [
|
481
|
-
{
|
482
|
-
name: :field1,
|
483
|
-
type: :boolean,
|
484
|
-
},
|
485
|
-
{
|
486
|
-
name: :field2,
|
487
|
-
type: :uint8,
|
488
|
-
},
|
489
|
-
],
|
490
|
-
type_codes: [0, 1],
|
491
|
-
},
|
492
|
-
records)
|
493
|
-
assert_equal(remove_union_field_names(records),
|
494
|
-
target.raw_records)
|
495
|
-
end
|
496
|
-
|
497
|
-
def test_dictionary
|
498
|
-
records = [
|
499
|
-
[{"field" => "Ruby"}],
|
500
|
-
[nil],
|
501
|
-
[{"field" => nil}],
|
502
|
-
[{"field" => "GLib"}],
|
503
|
-
]
|
504
|
-
target = build({
|
505
|
-
type: :dictionary,
|
506
|
-
index_data_type: :int8,
|
507
|
-
value_data_type: :string,
|
508
|
-
ordered: false,
|
509
|
-
},
|
510
|
-
records)
|
511
|
-
assert_equal(records, target.raw_records)
|
512
|
-
end
|
513
|
-
end
|
514
|
-
|
515
|
-
class RawRecordsRecordBatchStructArrayTest < Test::Unit::TestCase
|
516
|
-
include RawRecordsStructArrayTests
|
517
|
-
|
518
|
-
def build(type, records)
|
519
|
-
Arrow::RecordBatch.new(build_schema(type), records)
|
520
|
-
end
|
521
|
-
end
|
522
|
-
|
523
|
-
class RawRecordsTableStructArrayTest < Test::Unit::TestCase
|
524
|
-
include RawRecordsStructArrayTests
|
525
|
-
|
526
|
-
def build(type, records)
|
527
|
-
Arrow::Table.new(build_schema(type), records)
|
528
|
-
end
|
529
|
-
end
|
@@ -1,47 +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 RawRecordsTableTest < Test::Unit::TestCase
|
19
|
-
test("2 arrays") do
|
20
|
-
raw_record_batches = [
|
21
|
-
[
|
22
|
-
[true, nil, "Ruby"],
|
23
|
-
[nil, 0, "GLib"],
|
24
|
-
[false, 2 ** 8 - 1, nil],
|
25
|
-
],
|
26
|
-
[
|
27
|
-
[nil, 10, "A"],
|
28
|
-
[true, 20, "B"],
|
29
|
-
[false, nil, "C"],
|
30
|
-
[nil, 40, nil],
|
31
|
-
]
|
32
|
-
]
|
33
|
-
raw_records = raw_record_batches.inject do |all_records, record_batch|
|
34
|
-
all_records + record_batch
|
35
|
-
end
|
36
|
-
schema = [
|
37
|
-
{name: :column0, type: :boolean},
|
38
|
-
{name: :column1, type: :uint8},
|
39
|
-
{name: :column2, type: :string},
|
40
|
-
]
|
41
|
-
record_batches = raw_record_batches.collect do |record_batch|
|
42
|
-
Arrow::RecordBatch.new(schema, record_batch)
|
43
|
-
end
|
44
|
-
table = Arrow::Table.new(schema, record_batches)
|
45
|
-
assert_equal(raw_records, table.raw_records)
|
46
|
-
end
|
47
|
-
end
|
data/test/run-test.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
5
|
-
# distributed with this work for additional information
|
6
|
-
# regarding copyright ownership. The ASF licenses this file
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
8
|
-
# "License"); you may not use this file except in compliance
|
9
|
-
# with the License. You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
14
|
-
# software distributed under the License is distributed on an
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
-
# KIND, either express or implied. See the License for the
|
17
|
-
# specific language governing permissions and limitations
|
18
|
-
# under the License.
|
19
|
-
|
20
|
-
$VERBOSE = true
|
21
|
-
|
22
|
-
require "fileutils"
|
23
|
-
require "pathname"
|
24
|
-
|
25
|
-
(ENV["ARROW_DLL_PATH"] || "").split(File::PATH_SEPARATOR).each do |path|
|
26
|
-
RubyInstaller::Runtime.add_dll_directory(path)
|
27
|
-
end
|
28
|
-
|
29
|
-
base_dir = Pathname.new(__dir__).parent.expand_path
|
30
|
-
|
31
|
-
lib_dir = base_dir + "lib"
|
32
|
-
ext_dir = base_dir + "ext" + "arrow"
|
33
|
-
test_dir = base_dir + "test"
|
34
|
-
|
35
|
-
build_dir = ENV["BUILD_DIR"]
|
36
|
-
if build_dir
|
37
|
-
build_dir = File.join(build_dir, "red-arrow")
|
38
|
-
FileUtils.mkdir_p(build_dir)
|
39
|
-
else
|
40
|
-
build_dir = ext_dir
|
41
|
-
end
|
42
|
-
|
43
|
-
make = nil
|
44
|
-
if ENV["NO_MAKE"] != "yes"
|
45
|
-
if ENV["MAKE"]
|
46
|
-
make = ENV["MAKE"]
|
47
|
-
elsif system("which gmake > #{File::NULL} 2>&1")
|
48
|
-
make = "gmake"
|
49
|
-
elsif system("which make > #{File::NULL} 2>&1")
|
50
|
-
make = "make"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
if make
|
54
|
-
Dir.chdir(build_dir.to_s) do
|
55
|
-
unless File.exist?("Makefile")
|
56
|
-
system(RbConfig.ruby,
|
57
|
-
(ext_dir + "extconf.rb").to_s,
|
58
|
-
"--enable-debug-build") or exit(false)
|
59
|
-
end
|
60
|
-
system("#{make} > #{File::NULL}") or exit(false)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
$LOAD_PATH.unshift(build_dir.to_s)
|
65
|
-
$LOAD_PATH.unshift(lib_dir.to_s)
|
66
|
-
|
67
|
-
require_relative "helper"
|
68
|
-
|
69
|
-
ENV["TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"] ||= "10000"
|
70
|
-
|
71
|
-
exit(Test::Unit::AutoRunner.run(true, test_dir.to_s))
|