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-tensor.rb
DELETED
@@ -1,297 +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 TensorTest < Test::Unit::TestCase
|
19
|
-
sub_test_case("class methods") do
|
20
|
-
sub_test_case(".new") do
|
21
|
-
def setup
|
22
|
-
@raw_tensor = [
|
23
|
-
[
|
24
|
-
[1, 2, 3, 4],
|
25
|
-
[5, 6, 7, 8],
|
26
|
-
],
|
27
|
-
[
|
28
|
-
[9, 10, 11, 12],
|
29
|
-
[13, 14, 15, 16],
|
30
|
-
],
|
31
|
-
[
|
32
|
-
[17, 18, 19, 20],
|
33
|
-
[21, 22, 23, 24],
|
34
|
-
],
|
35
|
-
]
|
36
|
-
@shape = [3, 2, 4]
|
37
|
-
@strides = [8, 4, 1]
|
38
|
-
end
|
39
|
-
|
40
|
-
test("Array") do
|
41
|
-
tensor = Arrow::Tensor.new(@raw_tensor)
|
42
|
-
assert_equal({
|
43
|
-
value_data_type: Arrow::UInt8DataType.new,
|
44
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
45
|
-
shape: @shape,
|
46
|
-
strides: @strides,
|
47
|
-
dimension_names: ["", "", ""],
|
48
|
-
},
|
49
|
-
{
|
50
|
-
value_data_type: tensor.value_data_type,
|
51
|
-
buffer: tensor.buffer.data.to_s,
|
52
|
-
shape: tensor.shape,
|
53
|
-
strides: tensor.strides,
|
54
|
-
dimension_names: tensor.dimension_names,
|
55
|
-
})
|
56
|
-
end
|
57
|
-
|
58
|
-
test("Array, data_type: Symbol") do
|
59
|
-
tensor = Arrow::Tensor.new(@raw_tensor, data_type: :int32)
|
60
|
-
assert_equal({
|
61
|
-
value_data_type: Arrow::Int32DataType.new,
|
62
|
-
buffer: @raw_tensor.flatten.pack("l*"),
|
63
|
-
shape: @shape,
|
64
|
-
strides: @strides.collect {|x| x * 4},
|
65
|
-
dimension_names: ["", "", ""],
|
66
|
-
},
|
67
|
-
{
|
68
|
-
value_data_type: tensor.value_data_type,
|
69
|
-
buffer: tensor.buffer.data.to_s,
|
70
|
-
shape: tensor.shape,
|
71
|
-
strides: tensor.strides,
|
72
|
-
dimension_names: tensor.dimension_names,
|
73
|
-
})
|
74
|
-
end
|
75
|
-
|
76
|
-
test("Array, dimension_names: Array<String>") do
|
77
|
-
tensor = Arrow::Tensor.new(@raw_tensor,
|
78
|
-
dimension_names: ["a", "b", "c"])
|
79
|
-
assert_equal({
|
80
|
-
value_data_type: Arrow::UInt8DataType.new,
|
81
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
82
|
-
shape: @shape,
|
83
|
-
strides: @strides,
|
84
|
-
dimension_names: ["a", "b", "c"],
|
85
|
-
},
|
86
|
-
{
|
87
|
-
value_data_type: tensor.value_data_type,
|
88
|
-
buffer: tensor.buffer.data.to_s,
|
89
|
-
shape: tensor.shape,
|
90
|
-
strides: tensor.strides,
|
91
|
-
dimension_names: tensor.dimension_names,
|
92
|
-
})
|
93
|
-
end
|
94
|
-
|
95
|
-
test("Array, dimension_names: Array<Symbol>") do
|
96
|
-
tensor = Arrow::Tensor.new(@raw_tensor,
|
97
|
-
dimension_names: [:a, :b, :c])
|
98
|
-
assert_equal({
|
99
|
-
value_data_type: Arrow::UInt8DataType.new,
|
100
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
101
|
-
shape: @shape,
|
102
|
-
strides: @strides,
|
103
|
-
dimension_names: ["a", "b", "c"],
|
104
|
-
},
|
105
|
-
{
|
106
|
-
value_data_type: tensor.value_data_type,
|
107
|
-
buffer: tensor.buffer.data.to_s,
|
108
|
-
shape: tensor.shape,
|
109
|
-
strides: tensor.strides,
|
110
|
-
dimension_names: tensor.dimension_names,
|
111
|
-
})
|
112
|
-
end
|
113
|
-
|
114
|
-
test("Array, strides:") do
|
115
|
-
message = "strides: is only accepted with " +
|
116
|
-
"an Arrow::Buffer or String raw tensor: #{@strides.inspect}"
|
117
|
-
assert_raise(ArgumentError.new(message)) do
|
118
|
-
Arrow::Tensor.new(@raw_tensor, strides: @strides)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
test("Arrow::Buffer, data_type:, shape:") do
|
123
|
-
data_type = :uint8
|
124
|
-
data = Arrow::Buffer.new(@raw_tensor.flatten.pack("C*").freeze)
|
125
|
-
tensor = Arrow::Tensor.new(data,
|
126
|
-
data_type: data_type,
|
127
|
-
shape: @shape)
|
128
|
-
assert_equal({
|
129
|
-
value_data_type: Arrow::UInt8DataType.new,
|
130
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
131
|
-
shape: @shape,
|
132
|
-
strides: @strides,
|
133
|
-
dimension_names: ["", "", ""],
|
134
|
-
},
|
135
|
-
{
|
136
|
-
value_data_type: tensor.value_data_type,
|
137
|
-
buffer: tensor.buffer.data.to_s,
|
138
|
-
shape: tensor.shape,
|
139
|
-
strides: tensor.strides,
|
140
|
-
dimension_names: tensor.dimension_names,
|
141
|
-
})
|
142
|
-
end
|
143
|
-
|
144
|
-
test("String, data_type:, shape:") do
|
145
|
-
data_type = :uint8
|
146
|
-
data = @raw_tensor.flatten.pack("C*").freeze
|
147
|
-
tensor = Arrow::Tensor.new(data,
|
148
|
-
data_type: data_type,
|
149
|
-
shape: @shape)
|
150
|
-
assert_equal({
|
151
|
-
value_data_type: Arrow::UInt8DataType.new,
|
152
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
153
|
-
shape: @shape,
|
154
|
-
strides: @strides,
|
155
|
-
dimension_names: ["", "", ""],
|
156
|
-
},
|
157
|
-
{
|
158
|
-
value_data_type: tensor.value_data_type,
|
159
|
-
buffer: tensor.buffer.data.to_s,
|
160
|
-
shape: tensor.shape,
|
161
|
-
strides: tensor.strides,
|
162
|
-
dimension_names: tensor.dimension_names,
|
163
|
-
})
|
164
|
-
end
|
165
|
-
|
166
|
-
test("String, data_type:") do
|
167
|
-
data_type = :uint8
|
168
|
-
data = @raw_tensor.flatten.pack("C*").freeze
|
169
|
-
message = "shape: is missing: #{data.inspect}"
|
170
|
-
assert_raise(ArgumentError.new(message)) do
|
171
|
-
Arrow::Tensor.new(data, data_type: data_type)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
test("String, shape:") do
|
176
|
-
data = @raw_tensor.flatten.pack("C*").freeze
|
177
|
-
message = "data_type: is missing: #{data.inspect}"
|
178
|
-
assert_raise(ArgumentError.new(message)) do
|
179
|
-
Arrow::Tensor.new(data, shape: @shape)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
test("String - not ASCII-8BIT") do
|
184
|
-
data = "XXX"
|
185
|
-
message = "raw tensor String must be " +
|
186
|
-
"an ASCII-8BIT encoded string: #{data.encoding.inspect}"
|
187
|
-
assert_raise(ArgumentError.new(message)) do
|
188
|
-
Arrow::Tensor.new("XXX")
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
test("Symbol, Arrow::Buffer, shape:") do
|
193
|
-
data_type = :uint8
|
194
|
-
data = Arrow::Buffer.new(@raw_tensor.flatten.pack("C*").freeze)
|
195
|
-
tensor = Arrow::Tensor.new(data_type,
|
196
|
-
data,
|
197
|
-
shape: @shape)
|
198
|
-
assert_equal({
|
199
|
-
value_data_type: Arrow::UInt8DataType.new,
|
200
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
201
|
-
shape: @shape,
|
202
|
-
strides: @strides,
|
203
|
-
dimension_names: ["", "", ""],
|
204
|
-
},
|
205
|
-
{
|
206
|
-
value_data_type: tensor.value_data_type,
|
207
|
-
buffer: tensor.buffer.data.to_s,
|
208
|
-
shape: tensor.shape,
|
209
|
-
strides: tensor.strides,
|
210
|
-
dimension_names: tensor.dimension_names,
|
211
|
-
})
|
212
|
-
end
|
213
|
-
|
214
|
-
test("Symbol, String, shape:, strides: - !contiguous and column major") do
|
215
|
-
data_type = :uint8
|
216
|
-
@shape[-1] -= 1 # Ignore the last element in @raw_tensor
|
217
|
-
@strides.reverse
|
218
|
-
tensor = Arrow::Tensor.new(data_type,
|
219
|
-
@raw_tensor.flatten.pack("C*"),
|
220
|
-
shape: @shape,
|
221
|
-
strides: @strides)
|
222
|
-
assert_equal({
|
223
|
-
value_data_type: Arrow::UInt8DataType.new,
|
224
|
-
buffer: @raw_tensor.flatten.pack("C*"),
|
225
|
-
shape: @shape,
|
226
|
-
strides: @strides,
|
227
|
-
dimension_names: ["", "", ""],
|
228
|
-
contiguous: false,
|
229
|
-
row_major: false,
|
230
|
-
column_major: false,
|
231
|
-
},
|
232
|
-
{
|
233
|
-
value_data_type: tensor.value_data_type,
|
234
|
-
buffer: tensor.buffer.data.to_s,
|
235
|
-
shape: tensor.shape,
|
236
|
-
strides: tensor.strides,
|
237
|
-
dimension_names: tensor.dimension_names,
|
238
|
-
contiguous: tensor.contiguous?,
|
239
|
-
row_major: tensor.row_major?,
|
240
|
-
column_major: tensor.column_major?,
|
241
|
-
})
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
sub_test_case("instance methods") do
|
247
|
-
def setup
|
248
|
-
raw_data = [
|
249
|
-
1, 2,
|
250
|
-
3, 4,
|
251
|
-
|
252
|
-
5, 6,
|
253
|
-
7, 8,
|
254
|
-
|
255
|
-
9, 10,
|
256
|
-
11, 12,
|
257
|
-
]
|
258
|
-
data = Arrow::Buffer.new(raw_data.pack("c*").freeze)
|
259
|
-
shape = [3, 2, 2]
|
260
|
-
strides = []
|
261
|
-
names = ["a", "b", "c"]
|
262
|
-
@tensor = Arrow::Tensor.new(:int8,
|
263
|
-
data,
|
264
|
-
shape,
|
265
|
-
strides,
|
266
|
-
names)
|
267
|
-
end
|
268
|
-
|
269
|
-
sub_test_case("#==") do
|
270
|
-
test("Arrow::Tensor") do
|
271
|
-
assert do
|
272
|
-
@tensor == @tensor
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
test("not Arrow::Tensor") do
|
277
|
-
assert do
|
278
|
-
not (@tensor == 29)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
sub_test_case("#to_arrow_array") do
|
284
|
-
test("1 dimension") do
|
285
|
-
assert_equal(Arrow::UInt8Array.new([1, 2, 3]),
|
286
|
-
Arrow::Tensor.new([1, 2, 3]).to_arrow_array)
|
287
|
-
end
|
288
|
-
|
289
|
-
test("2 dimensions") do
|
290
|
-
message = "must be 1 dimensional tensor: [3, 1]"
|
291
|
-
assert_raise(RangeError.new(message)) do
|
292
|
-
Arrow::Tensor.new([[1], [2], [3]]).to_arrow_array
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|
297
|
-
end
|
data/test/test-time.rb
DELETED
@@ -1,288 +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 TimeTest < Test::Unit::TestCase
|
19
|
-
sub_test_case("#==") do
|
20
|
-
test("same unit") do
|
21
|
-
assert do
|
22
|
-
Arrow::Time.new(:second, 10) == Arrow::Time.new(:second, 10)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
test("different unit") do
|
27
|
-
assert do
|
28
|
-
Arrow::Time.new(:second, 10) == Arrow::Time.new(:milli, 10 * 1000)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
test("false") do
|
33
|
-
assert do
|
34
|
-
not(Arrow::Time.new(:second, 10) == Arrow::Time.new(:second, 11))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
sub_test_case("#cast") do
|
40
|
-
test("same unit") do
|
41
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
42
|
-
casted_time = time.cast(Arrow::TimeUnit::SECOND)
|
43
|
-
assert_equal([time.unit, time.value],
|
44
|
-
[casted_time.unit, casted_time.value])
|
45
|
-
end
|
46
|
-
|
47
|
-
test("second -> milli") do
|
48
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
49
|
-
casted_time = time.cast(Arrow::TimeUnit::MILLI)
|
50
|
-
assert_equal([
|
51
|
-
Arrow::TimeUnit::MILLI,
|
52
|
-
time.value * 1000,
|
53
|
-
],
|
54
|
-
[
|
55
|
-
casted_time.unit,
|
56
|
-
casted_time.value,
|
57
|
-
])
|
58
|
-
end
|
59
|
-
|
60
|
-
test("second -> micro") do
|
61
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
62
|
-
casted_time = time.cast(Arrow::TimeUnit::MICRO)
|
63
|
-
assert_equal([
|
64
|
-
Arrow::TimeUnit::MICRO,
|
65
|
-
time.value * 1000 * 1000,
|
66
|
-
],
|
67
|
-
[
|
68
|
-
casted_time.unit,
|
69
|
-
casted_time.value,
|
70
|
-
])
|
71
|
-
end
|
72
|
-
|
73
|
-
test("second -> nano") do
|
74
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
75
|
-
casted_time = time.cast(Arrow::TimeUnit::NANO)
|
76
|
-
assert_equal([
|
77
|
-
Arrow::TimeUnit::NANO,
|
78
|
-
time.value * 1000 * 1000 * 1000,
|
79
|
-
],
|
80
|
-
[
|
81
|
-
casted_time.unit,
|
82
|
-
casted_time.value,
|
83
|
-
])
|
84
|
-
end
|
85
|
-
|
86
|
-
test("milli -> second") do
|
87
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
|
88
|
-
casted_time = time.cast(Arrow::TimeUnit::SECOND)
|
89
|
-
assert_equal([
|
90
|
-
Arrow::TimeUnit::SECOND,
|
91
|
-
10,
|
92
|
-
],
|
93
|
-
[
|
94
|
-
casted_time.unit,
|
95
|
-
casted_time.value,
|
96
|
-
])
|
97
|
-
end
|
98
|
-
|
99
|
-
test("milli -> micro") do
|
100
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
|
101
|
-
casted_time = time.cast(Arrow::TimeUnit::MICRO)
|
102
|
-
assert_equal([
|
103
|
-
Arrow::TimeUnit::MICRO,
|
104
|
-
time.value * 1000,
|
105
|
-
],
|
106
|
-
[
|
107
|
-
casted_time.unit,
|
108
|
-
casted_time.value,
|
109
|
-
])
|
110
|
-
end
|
111
|
-
|
112
|
-
test("milli -> nano") do
|
113
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
|
114
|
-
casted_time = time.cast(Arrow::TimeUnit::NANO)
|
115
|
-
assert_equal([
|
116
|
-
Arrow::TimeUnit::NANO,
|
117
|
-
time.value * 1000 * 1000,
|
118
|
-
],
|
119
|
-
[
|
120
|
-
casted_time.unit,
|
121
|
-
casted_time.value,
|
122
|
-
])
|
123
|
-
end
|
124
|
-
|
125
|
-
test("micro -> second") do
|
126
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
|
127
|
-
casted_time = time.cast(Arrow::TimeUnit::SECOND)
|
128
|
-
assert_equal([
|
129
|
-
Arrow::TimeUnit::SECOND,
|
130
|
-
10,
|
131
|
-
],
|
132
|
-
[
|
133
|
-
casted_time.unit,
|
134
|
-
casted_time.value,
|
135
|
-
])
|
136
|
-
end
|
137
|
-
|
138
|
-
test("micro -> milli") do
|
139
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
|
140
|
-
casted_time = time.cast(Arrow::TimeUnit::MILLI)
|
141
|
-
assert_equal([
|
142
|
-
Arrow::TimeUnit::MILLI,
|
143
|
-
10_200,
|
144
|
-
],
|
145
|
-
[
|
146
|
-
casted_time.unit,
|
147
|
-
casted_time.value,
|
148
|
-
])
|
149
|
-
end
|
150
|
-
|
151
|
-
test("micro -> nano") do
|
152
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
|
153
|
-
casted_time = time.cast(Arrow::TimeUnit::NANO)
|
154
|
-
assert_equal([
|
155
|
-
Arrow::TimeUnit::NANO,
|
156
|
-
time.value * 1000,
|
157
|
-
],
|
158
|
-
[
|
159
|
-
casted_time.unit,
|
160
|
-
casted_time.value,
|
161
|
-
])
|
162
|
-
end
|
163
|
-
|
164
|
-
test("nano -> second") do
|
165
|
-
time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
|
166
|
-
casted_time = time.cast(Arrow::TimeUnit::SECOND)
|
167
|
-
assert_equal([
|
168
|
-
Arrow::TimeUnit::SECOND,
|
169
|
-
10,
|
170
|
-
],
|
171
|
-
[
|
172
|
-
casted_time.unit,
|
173
|
-
casted_time.value,
|
174
|
-
])
|
175
|
-
end
|
176
|
-
|
177
|
-
test("nano -> milli") do
|
178
|
-
time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
|
179
|
-
casted_time = time.cast(Arrow::TimeUnit::MILLI)
|
180
|
-
assert_equal([
|
181
|
-
Arrow::TimeUnit::MILLI,
|
182
|
-
10_200,
|
183
|
-
],
|
184
|
-
[
|
185
|
-
casted_time.unit,
|
186
|
-
casted_time.value,
|
187
|
-
])
|
188
|
-
end
|
189
|
-
|
190
|
-
test("nano -> micro") do
|
191
|
-
time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
|
192
|
-
casted_time = time.cast(Arrow::TimeUnit::MICRO)
|
193
|
-
assert_equal([
|
194
|
-
Arrow::TimeUnit::MICRO,
|
195
|
-
10_200_300,
|
196
|
-
],
|
197
|
-
[
|
198
|
-
casted_time.unit,
|
199
|
-
casted_time.value,
|
200
|
-
])
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
sub_test_case("#to_f") do
|
205
|
-
test("second") do
|
206
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
207
|
-
assert_in_delta(10.0, time.to_f)
|
208
|
-
end
|
209
|
-
|
210
|
-
test("milli") do
|
211
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MILLI, 10_200)
|
212
|
-
assert_in_delta(10.2, time.to_f)
|
213
|
-
end
|
214
|
-
|
215
|
-
test("micro") do
|
216
|
-
time = Arrow::Time.new(Arrow::TimeUnit::MICRO, 10_200_300)
|
217
|
-
assert_in_delta(10.2003, time.to_f)
|
218
|
-
end
|
219
|
-
|
220
|
-
test("nano") do
|
221
|
-
time = Arrow::Time.new(Arrow::TimeUnit::NANO, 10_200_300_400)
|
222
|
-
assert_in_delta(10.2003004, time.to_f)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
sub_test_case("#positive?") do
|
227
|
-
test("true") do
|
228
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
229
|
-
assert do
|
230
|
-
time.positive?
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
test("false") do
|
235
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, -10)
|
236
|
-
assert do
|
237
|
-
not time.positive?
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
sub_test_case("#negative?") do
|
243
|
-
test("true") do
|
244
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, -10)
|
245
|
-
assert do
|
246
|
-
time.negative?
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
test("false") do
|
251
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND, 10)
|
252
|
-
assert do
|
253
|
-
not time.negative?
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
test("#hour") do
|
259
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
|
260
|
-
(5 * 60 * 60) + (12 * 60) + 10)
|
261
|
-
assert_equal(5, time.hour)
|
262
|
-
end
|
263
|
-
|
264
|
-
test("#minute") do
|
265
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
|
266
|
-
(5 * 60 * 60) + (12 * 60) + 10)
|
267
|
-
assert_equal(12, time.minute)
|
268
|
-
end
|
269
|
-
|
270
|
-
test("#second") do
|
271
|
-
time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
|
272
|
-
(5 * 60 * 60) + (12 * 60) + 10)
|
273
|
-
assert_equal(10, time.second)
|
274
|
-
end
|
275
|
-
|
276
|
-
test("#nano_second") do
|
277
|
-
time = Arrow::Time.new(Arrow::TimeUnit::NANO, 1234)
|
278
|
-
assert_equal(1234, time.nano_second)
|
279
|
-
end
|
280
|
-
|
281
|
-
test("#to_s") do
|
282
|
-
time = Arrow::Time.new(Arrow::TimeUnit::NANO,
|
283
|
-
-(((5 * 60 * 60) + (12 * 60) + 10) * 1_000_000_000 +
|
284
|
-
1234))
|
285
|
-
assert_equal("-05:12:10.000001234",
|
286
|
-
time.to_s)
|
287
|
-
end
|
288
|
-
end
|
data/test/test-time32-array.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 Time32ArrayTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
sub_test_case("unit") do
|
21
|
-
test("Arrow::TimeUnit") do
|
22
|
-
values = [1000 * 10, nil]
|
23
|
-
array = Arrow::Time32Array.new(Arrow::TimeUnit::MILLI, values)
|
24
|
-
assert_equal([
|
25
|
-
"time32[ms]",
|
26
|
-
[
|
27
|
-
Arrow::Time.new(Arrow::TimeUnit::MILLI,
|
28
|
-
1000 * 10),
|
29
|
-
nil,
|
30
|
-
],
|
31
|
-
],
|
32
|
-
[
|
33
|
-
array.value_data_type.to_s,
|
34
|
-
array.to_a,
|
35
|
-
])
|
36
|
-
end
|
37
|
-
|
38
|
-
test("Symbol") do
|
39
|
-
values = [60 * 10, nil]
|
40
|
-
array = Arrow::Time32Array.new(:second, values)
|
41
|
-
assert_equal([
|
42
|
-
"time32[s]",
|
43
|
-
[
|
44
|
-
Arrow::Time.new(Arrow::TimeUnit::SECOND,
|
45
|
-
60 * 10),
|
46
|
-
nil,
|
47
|
-
],
|
48
|
-
],
|
49
|
-
[
|
50
|
-
array.value_data_type.to_s,
|
51
|
-
array.to_a,
|
52
|
-
])
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
sub_test_case("values") do
|
57
|
-
test("Arrow::Time") do
|
58
|
-
data_type = Arrow::Time32DataType.new(:second)
|
59
|
-
values = [
|
60
|
-
Arrow::Time.new(Arrow::TimeUnit::SECOND,
|
61
|
-
60 * 10),
|
62
|
-
nil,
|
63
|
-
]
|
64
|
-
array = Arrow::Time32Array.new(data_type, values)
|
65
|
-
assert_equal(values, array.to_a)
|
66
|
-
end
|
67
|
-
|
68
|
-
test("Integer") do
|
69
|
-
data_type = Arrow::Time32DataType.new(:second)
|
70
|
-
values = [60 * 10, nil]
|
71
|
-
array = Arrow::Time32Array.new(data_type, values)
|
72
|
-
assert_equal([
|
73
|
-
Arrow::Time.new(Arrow::TimeUnit::SECOND,
|
74
|
-
60 * 10),
|
75
|
-
nil,
|
76
|
-
],
|
77
|
-
array.to_a)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,42 +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 Time32DataTypeTest < Test::Unit::TestCase
|
19
|
-
sub_test_case(".new") do
|
20
|
-
test("Arrow::TimeUnit") do
|
21
|
-
assert_equal("time32[ms]",
|
22
|
-
Arrow::Time32DataType.new(Arrow::TimeUnit::MILLI).to_s)
|
23
|
-
end
|
24
|
-
|
25
|
-
test("Symbol") do
|
26
|
-
assert_equal("time32[ms]",
|
27
|
-
Arrow::Time32DataType.new(:milli).to_s)
|
28
|
-
end
|
29
|
-
|
30
|
-
test("unit: Arrow::TimeUnit") do
|
31
|
-
data_type = Arrow::Time32DataType.new(unit: Arrow::TimeUnit::MILLI)
|
32
|
-
assert_equal("time32[ms]",
|
33
|
-
data_type.to_s)
|
34
|
-
end
|
35
|
-
|
36
|
-
test("unit: Symbol") do
|
37
|
-
data_type = Arrow::Time32DataType.new(unit: :milli)
|
38
|
-
assert_equal("time32[ms]",
|
39
|
-
data_type.to_s)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|