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.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arrow/array.rb +7 -4
  3. data/lib/arrow/column.rb +4 -4
  4. data/lib/arrow/jruby/array-builder.rb +114 -0
  5. data/lib/arrow/jruby/array.rb +109 -0
  6. data/{test/helper/fixture.rb → lib/arrow/jruby/chunked-array.rb} +14 -6
  7. data/lib/arrow/jruby/compression-type.rb +26 -0
  8. data/{test/test-boolean-scalar.rb → lib/arrow/jruby/csv-read-options.rb} +12 -6
  9. data/{test/test-map-data-type.rb → lib/arrow/jruby/data-type.rb} +24 -12
  10. data/lib/arrow/jruby/decimal128.rb +28 -0
  11. data/lib/arrow/jruby/decimal256.rb +28 -0
  12. data/{test/fixture/null-with-double-quote.csv → lib/arrow/jruby/error.rb} +7 -4
  13. data/lib/arrow/jruby/file-system.rb +24 -0
  14. data/{test/test-null-array.rb → lib/arrow/jruby/function.rb} +5 -4
  15. data/lib/arrow/jruby/record-batch-iterator.rb +24 -0
  16. data/{test/fixture/integer-float.csv → lib/arrow/jruby/record-batch.rb} +8 -4
  17. data/{test/fixture/float-integer.csv → lib/arrow/jruby/sort-key.rb} +8 -4
  18. data/lib/arrow/jruby/sort-options.rb +24 -0
  19. data/lib/arrow/jruby/stream-listener-raw.rb +25 -0
  20. data/{test/test-rolling-window.rb → lib/arrow/jruby/table.rb} +19 -19
  21. data/lib/arrow/jruby/writable.rb +24 -0
  22. data/lib/arrow/jruby.rb +52 -0
  23. data/lib/arrow/libraries.rb +126 -0
  24. data/lib/arrow/list-array-builder.rb +1 -0
  25. data/lib/arrow/loader.rb +3 -111
  26. data/{test/fixture/null-without-double-quote.csv → lib/arrow/ruby.rb} +6 -4
  27. data/lib/arrow/version.rb +1 -1
  28. data/lib/arrow.rb +2 -7
  29. data/red-arrow.gemspec +15 -6
  30. metadata +26 -229
  31. data/test/each-raw-record/test-basic-arrays.rb +0 -411
  32. data/test/each-raw-record/test-dense-union-array.rb +0 -566
  33. data/test/each-raw-record/test-dictionary-array.rb +0 -341
  34. data/test/each-raw-record/test-list-array.rb +0 -628
  35. data/test/each-raw-record/test-map-array.rb +0 -507
  36. data/test/each-raw-record/test-multiple-columns.rb +0 -72
  37. data/test/each-raw-record/test-sparse-union-array.rb +0 -528
  38. data/test/each-raw-record/test-struct-array.rb +0 -529
  39. data/test/each-raw-record/test-table.rb +0 -47
  40. data/test/fixture/TestOrcFile.test1.orc +0 -0
  41. data/test/fixture/with-header-float.csv +0 -20
  42. data/test/fixture/with-header.csv +0 -20
  43. data/test/fixture/without-header-float.csv +0 -19
  44. data/test/fixture/without-header.csv +0 -19
  45. data/test/helper/omittable.rb +0 -49
  46. data/test/helper.rb +0 -31
  47. data/test/raw-records/test-basic-arrays.rb +0 -405
  48. data/test/raw-records/test-dense-union-array.rb +0 -566
  49. data/test/raw-records/test-dictionary-array.rb +0 -341
  50. data/test/raw-records/test-list-array.rb +0 -628
  51. data/test/raw-records/test-map-array.rb +0 -507
  52. data/test/raw-records/test-multiple-columns.rb +0 -65
  53. data/test/raw-records/test-sparse-union-array.rb +0 -556
  54. data/test/raw-records/test-struct-array.rb +0 -529
  55. data/test/raw-records/test-table.rb +0 -47
  56. data/test/run-test.rb +0 -71
  57. data/test/test-array-builder.rb +0 -198
  58. data/test/test-array.rb +0 -332
  59. data/test/test-bigdecimal.rb +0 -40
  60. data/test/test-binary-dictionary-array-builder.rb +0 -103
  61. data/test/test-buffer.rb +0 -49
  62. data/test/test-chunked-array.rb +0 -198
  63. data/test/test-column.rb +0 -123
  64. data/test/test-csv-loader.rb +0 -297
  65. data/test/test-data-type.rb +0 -84
  66. data/test/test-date32-array.rb +0 -24
  67. data/test/test-date64-array.rb +0 -25
  68. data/test/test-decimal128-array-builder.rb +0 -126
  69. data/test/test-decimal128-array.rb +0 -47
  70. data/test/test-decimal128-data-type.rb +0 -31
  71. data/test/test-decimal128.rb +0 -126
  72. data/test/test-decimal256-array-builder.rb +0 -126
  73. data/test/test-decimal256-array.rb +0 -47
  74. data/test/test-decimal256-data-type.rb +0 -31
  75. data/test/test-decimal256.rb +0 -126
  76. data/test/test-dense-union-array.rb +0 -42
  77. data/test/test-dense-union-data-type.rb +0 -41
  78. data/test/test-dictionary-array.rb +0 -41
  79. data/test/test-dictionary-data-type.rb +0 -40
  80. data/test/test-expression.rb +0 -51
  81. data/test/test-feather.rb +0 -49
  82. data/test/test-field.rb +0 -117
  83. data/test/test-file-output-stream.rb +0 -54
  84. data/test/test-fixed-size-binary-array-builder.rb +0 -92
  85. data/test/test-fixed-size-binary-array.rb +0 -36
  86. data/test/test-float-scalar.rb +0 -46
  87. data/test/test-function.rb +0 -210
  88. data/test/test-group.rb +0 -193
  89. data/test/test-half-float-array.rb +0 -43
  90. data/test/test-half-float.rb +0 -130
  91. data/test/test-list-array-builder.rb +0 -79
  92. data/test/test-list-array.rb +0 -32
  93. data/test/test-list-data-type.rb +0 -69
  94. data/test/test-map-array-builder.rb +0 -110
  95. data/test/test-map-array.rb +0 -33
  96. data/test/test-memory-view.rb +0 -434
  97. data/test/test-orc.rb +0 -173
  98. data/test/test-ractor.rb +0 -34
  99. data/test/test-record-batch-builder.rb +0 -125
  100. data/test/test-record-batch-file-reader.rb +0 -136
  101. data/test/test-record-batch-iterator.rb +0 -37
  102. data/test/test-record-batch-reader.rb +0 -46
  103. data/test/test-record-batch-stream-reader.rb +0 -129
  104. data/test/test-record-batch.rb +0 -182
  105. data/test/test-scalar.rb +0 -65
  106. data/test/test-schema.rb +0 -134
  107. data/test/test-slicer.rb +0 -589
  108. data/test/test-sort-indices.rb +0 -40
  109. data/test/test-sort-key.rb +0 -81
  110. data/test/test-sort-options.rb +0 -58
  111. data/test/test-sparse-union-array.rb +0 -38
  112. data/test/test-sparse-union-data-type.rb +0 -41
  113. data/test/test-stream-listener.rb +0 -60
  114. data/test/test-string-dictionary-array-builder.rb +0 -103
  115. data/test/test-struct-array-builder.rb +0 -184
  116. data/test/test-struct-array.rb +0 -94
  117. data/test/test-struct-data-type.rb +0 -112
  118. data/test/test-table.rb +0 -1530
  119. data/test/test-tensor.rb +0 -297
  120. data/test/test-time.rb +0 -288
  121. data/test/test-time32-array.rb +0 -81
  122. data/test/test-time32-data-type.rb +0 -42
  123. data/test/test-time64-array.rb +0 -81
  124. data/test/test-time64-data-type.rb +0 -42
  125. data/test/test-timestamp-array.rb +0 -45
  126. data/test/test-timestamp-data-type.rb +0 -42
  127. data/test/values/test-basic-arrays.rb +0 -335
  128. data/test/values/test-dense-union-array.rb +0 -552
  129. data/test/values/test-dictionary-array.rb +0 -325
  130. data/test/values/test-list-array.rb +0 -587
  131. data/test/values/test-map-array.rb +0 -489
  132. data/test/values/test-sparse-union-array.rb +0 -543
  133. data/test/values/test-struct-array.rb +0 -524
@@ -1,46 +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 FloatScalarTest < Test::Unit::TestCase
19
- sub_test_case("#equal_scalar?") do
20
- test("no options") do
21
- scalar1 = Arrow::FloatScalar.new(1.1)
22
- scalar2 = Arrow::FloatScalar.new(1.1000001)
23
- assert do
24
- not scalar1.equal_scalar?(scalar2)
25
- end
26
- end
27
-
28
- test(":approx") do
29
- scalar1 = Arrow::FloatScalar.new(1.1)
30
- scalar2 = Arrow::FloatScalar.new(1.1000001)
31
- assert do
32
- scalar1.equal_scalar?(scalar2, approx: true)
33
- end
34
- end
35
-
36
- test(":absolute_tolerance") do
37
- scalar1 = Arrow::FloatScalar.new(1.1)
38
- scalar2 = Arrow::FloatScalar.new(1.1001)
39
- assert do
40
- scalar1.equal_scalar?(scalar2,
41
- approx: true,
42
- absolute_tolerance: 0.001)
43
- end
44
- end
45
- end
46
- end
@@ -1,210 +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 FunctionTest < Test::Unit::TestCase
19
- sub_test_case("#execute") do
20
- test("Arrow::Array") do
21
- or_function = Arrow::Function.find("or")
22
- args = [
23
- Arrow::BooleanArray.new([true, false, false]),
24
- Arrow::BooleanArray.new([true, false, true]),
25
- ]
26
- assert_equal([true, false, true],
27
- or_function.execute(args).value.to_a)
28
- end
29
-
30
- test("Array") do
31
- or_function = Arrow::Function.find("or")
32
- args = [
33
- [true, false, false],
34
- [true, false, true],
35
- ]
36
- assert_equal([true, false, true],
37
- or_function.execute(args).value.to_a)
38
- end
39
-
40
- test("Arrow::ChunkedArray") do
41
- or_function = Arrow::Function.find("or")
42
- args = [
43
- Arrow::ChunkedArray.new([
44
- Arrow::BooleanArray.new([true]),
45
- Arrow::BooleanArray.new([false, false]),
46
- ]),
47
- Arrow::ChunkedArray.new([
48
- Arrow::BooleanArray.new([true, false]),
49
- Arrow::BooleanArray.new([true]),
50
- ]),
51
- ]
52
- assert_equal([true, false, true],
53
- or_function.execute(args).value.to_a)
54
- end
55
-
56
- test("Arrow::Column") do
57
- or_function = Arrow::Function.find("or")
58
- table = Arrow::Table.new(a: [true, false, false],
59
- b: [true, false, true])
60
- assert_equal([true, false, true],
61
- or_function.execute([table.a, table.b]).value.to_a)
62
- end
63
-
64
- test("Arrow::Scalar") do
65
- add_function = Arrow::Function.find("add")
66
- args = [
67
- Arrow::Int8Array.new([1, 2, 3]),
68
- Arrow::Int8Scalar.new(5),
69
- ]
70
- assert_equal([6, 7, 8],
71
- add_function.execute(args).value.to_a)
72
- end
73
-
74
- test("Integer") do
75
- add_function = Arrow::Function.find("add")
76
- args = [
77
- [1, 2, 3],
78
- 5,
79
- ]
80
- assert_equal([6, 7, 8],
81
- add_function.execute(args).value.to_a)
82
- end
83
-
84
- test("Float") do
85
- add_function = Arrow::Function.find("add")
86
- args = [
87
- [1, 2, 3],
88
- 5.1,
89
- ]
90
- assert_equal([6.1, 7.1, 8.1],
91
- add_function.execute(args).value.to_a)
92
- end
93
-
94
- test("true") do
95
- and_function = Arrow::Function.find("and")
96
- args = [
97
- Arrow::BooleanArray.new([true, false, false]),
98
- true,
99
- ]
100
- assert_equal([true, false, false],
101
- and_function.execute(args).value.to_a)
102
- end
103
-
104
- test("false") do
105
- or_function = Arrow::Function.find("or")
106
- args = [
107
- Arrow::BooleanArray.new([true, false, false]),
108
- false,
109
- ]
110
- assert_equal([true, false, false],
111
- or_function.execute(args).value.to_a)
112
- end
113
-
114
- test("String") do
115
- ascii_upper_function = Arrow::Function.find("ascii_upper")
116
- args = [
117
- "Hello",
118
- ]
119
- assert_equal("HELLO",
120
- ascii_upper_function.execute(args).value.to_s)
121
- end
122
-
123
- test("Date") do
124
- cast_function = Arrow::Function.find("cast")
125
- date = Date.new(2021, 6, 12)
126
- args = [date]
127
- options = {
128
- to_data_type: Arrow::TimestampDataType.new(:second),
129
- }
130
- time = Time.utc(date.year,
131
- date.month,
132
- date.day)
133
- assert_equal(Arrow::TimestampScalar.new(options[:to_data_type],
134
- time.to_i),
135
- cast_function.execute(args, options).value)
136
- end
137
-
138
- test("Arrow::Time: second") do
139
- cast_function = Arrow::Function.find("cast")
140
- arrow_time = Arrow::Time.new(Arrow::TimeUnit::SECOND,
141
- # 00:10:00
142
- 60 * 10)
143
- args = [arrow_time]
144
- options = {
145
- to_data_type: Arrow::Time64DataType.new(:micro),
146
- }
147
- assert_equal(Arrow::Time64Scalar.new(options[:to_data_type],
148
- # 00:10:00.000000
149
- 60 * 10 * 1000 * 1000),
150
- cast_function.execute(args, options).value)
151
- end
152
-
153
- test("Arrow::Time: micro") do
154
- cast_function = Arrow::Function.find("cast")
155
- arrow_time = Arrow::Time.new(Arrow::TimeUnit::MICRO,
156
- # 00:10:00.000000
157
- 60 * 10 * 1000 * 1000)
158
- args = [arrow_time]
159
- options = {
160
- to_data_type: Arrow::Time32DataType.new(:second),
161
- allow_time_truncate: true,
162
- }
163
- assert_equal(Arrow::Time32Scalar.new(options[:to_data_type],
164
- # 00:10:00
165
- 60 * 10),
166
- cast_function.execute(args, options).value)
167
- end
168
-
169
- test("Time") do
170
- cast_function = Arrow::Function.find("cast")
171
- time = Time.utc(2021, 6, 12, 1, 2, 3, 1)
172
- args = [time]
173
- options = {
174
- to_data_type: Arrow::TimestampDataType.new(:second),
175
- allow_time_truncate: true,
176
- }
177
- time = Time.utc(time.year,
178
- time.month,
179
- time.day,
180
- time.hour,
181
- time.min,
182
- time.sec)
183
- assert_equal(Arrow::TimestampScalar.new(options[:to_data_type],
184
- time.to_i),
185
- cast_function.execute(args, options).value)
186
- end
187
-
188
- test("SetLookupOptions") do
189
- is_in_function = Arrow::Function.find("is_in")
190
- args = [
191
- Arrow::Int16Array.new([1, 0, 1, 2]),
192
- ]
193
- options = {
194
- value_set: Arrow::Int16Array.new([2, 0]),
195
- }
196
- assert_equal(Arrow::BooleanArray.new([false, true, false, true]),
197
- is_in_function.execute(args, options).value)
198
- end
199
- end
200
-
201
- def test_call
202
- or_function = Arrow::Function.find("or")
203
- args = [
204
- Arrow::BooleanArray.new([true, false, false]),
205
- Arrow::BooleanArray.new([true, false, true]),
206
- ]
207
- assert_equal([true, false, true],
208
- or_function.call(args).value.to_a)
209
- end
210
- end
data/test/test-group.rb DELETED
@@ -1,193 +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 GroupTest < Test::Unit::TestCase
19
- include Helper::Fixture
20
-
21
- def setup
22
- raw_table = {
23
- :group_key1 => Arrow::UInt8Array.new([1, 1, 2, 3, 3, 3]),
24
- :group_key2 => Arrow::UInt8Array.new([1, 1, 1, 1, 2, 2]),
25
- :int => Arrow::Int32Array.new([-1, -2, nil, -4, -5, -6]),
26
- :uint => Arrow::UInt32Array.new([1, nil, 3, 4, 5, 6]),
27
- :float => Arrow::FloatArray.new([nil, 2.2, 3.3, 4.4, 5.5, 6.6]),
28
- :string => Arrow::StringArray.new(["a", "b", "c", nil, "e", "f"]),
29
- }
30
- @table = Arrow::Table.new(raw_table)
31
- end
32
-
33
- sub_test_case("key") do
34
- test("Time") do
35
- time_values = [
36
- Time.parse("2018-01-29"),
37
- Time.parse("2018-01-30"),
38
- ]
39
- raw_table = {
40
- :time => Arrow::ArrayBuilder.build(time_values),
41
- :int => Arrow::Int32Array.new([-1, -2]),
42
- }
43
- table = Arrow::Table.new(raw_table)
44
- assert_equal(<<-TABLE, table.group(:time).count.to_s)
45
- time count(int)
46
- (timestamp) (int64)
47
- 0 #{time_values[0].iso8601} 1
48
- 1 #{time_values[1].iso8601} 1
49
- TABLE
50
- end
51
- end
52
-
53
- sub_test_case("#count") do
54
- test("single") do
55
- assert_equal(<<-TABLE, @table.group(:group_key1).count.to_s)
56
- group_key1 count(group_key2) count(int) count(uint) count(float) count(string)
57
- (uint8) (int64) (int64) (int64) (int64) (int64)
58
- 0 1 2 2 1 1 2
59
- 1 2 1 0 1 1 1
60
- 2 3 3 3 3 3 2
61
- TABLE
62
- end
63
-
64
- test("multiple") do
65
- assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).count.to_s)
66
- group_key1 group_key2 count(int) count(uint) count(float) count(string)
67
- (uint8) (uint8) (int64) (int64) (int64) (int64)
68
- 0 1 1 2 1 1 2
69
- 1 2 1 0 1 1 1
70
- 2 3 1 1 1 1 0
71
- 3 3 2 2 2 2 2
72
- TABLE
73
- end
74
-
75
- test("column") do
76
- group = @table.group(:group_key1, :group_key2)
77
- assert_equal(<<-TABLE, group.count(:int, :uint).to_s)
78
- group_key1 group_key2 count(int) count(uint)
79
- (uint8) (uint8) (int64) (int64)
80
- 0 1 1 2 1
81
- 1 2 1 0 1
82
- 2 3 1 1 1
83
- 3 3 2 2 2
84
- TABLE
85
- end
86
- end
87
-
88
- sub_test_case("#sum") do
89
- test("single") do
90
- assert_equal(<<-TABLE, @table.group(:group_key1).sum.to_s)
91
- group_key1 sum(group_key2) sum(int) sum(uint) sum(float)
92
- (uint8) (uint64) (int64) (uint64) (double)
93
- 0 1 2 -3 1 2.200000
94
- 1 2 1 (null) 3 3.300000
95
- 2 3 5 -15 15 16.500000
96
- TABLE
97
- end
98
-
99
- test("multiple") do
100
- assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).sum.to_s)
101
- group_key1 group_key2 sum(int) sum(uint) sum(float)
102
- (uint8) (uint8) (int64) (uint64) (double)
103
- 0 1 1 -3 1 2.200000
104
- 1 2 1 (null) 3 3.300000
105
- 2 3 1 -4 4 4.400000
106
- 3 3 2 -11 11 12.100000
107
- TABLE
108
- end
109
- end
110
-
111
- sub_test_case("#mean") do
112
- test("single") do
113
- assert_equal(<<-TABLE, @table.group(:group_key1).mean.to_s)
114
- group_key1 mean(group_key2) mean(int) mean(uint) mean(float)
115
- (uint8) (double) (double) (double) (double)
116
- 0 1 1.000000 -1.500000 1.000000 2.200000
117
- 1 2 1.000000 (null) 3.000000 3.300000
118
- 2 3 1.666667 -5.000000 5.000000 5.500000
119
- TABLE
120
- end
121
-
122
- test("multiple") do
123
- assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).mean.to_s)
124
- group_key1 group_key2 mean(int) mean(uint) mean(float)
125
- (uint8) (uint8) (double) (double) (double)
126
- 0 1 1 -1.500000 1.000000 2.200000
127
- 1 2 1 (null) 3.000000 3.300000
128
- 2 3 1 -4.000000 4.000000 4.400000
129
- 3 3 2 -5.500000 5.500000 6.050000
130
- TABLE
131
- end
132
- end
133
-
134
- sub_test_case("#min") do
135
- test("single") do
136
- assert_equal(<<-TABLE, @table.group(:group_key1).min.to_s)
137
- group_key1 min(group_key2) min(int) min(uint) min(float)
138
- (uint8) (uint8) (int32) (uint32) (float)
139
- 0 1 1 -2 1 2.200000
140
- 1 2 1 (null) 3 3.300000
141
- 2 3 1 -6 4 4.400000
142
- TABLE
143
- end
144
-
145
- test("multiple") do
146
- assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).min.to_s)
147
- group_key1 group_key2 min(int) min(uint) min(float)
148
- (uint8) (uint8) (int32) (uint32) (float)
149
- 0 1 1 -2 1 2.200000
150
- 1 2 1 (null) 3 3.300000
151
- 2 3 1 -4 4 4.400000
152
- 3 3 2 -6 5 5.500000
153
- TABLE
154
- end
155
- end
156
-
157
- sub_test_case("#max") do
158
- test("single") do
159
- assert_equal(<<-TABLE, @table.group(:group_key1).max.to_s)
160
- group_key1 max(group_key2) max(int) max(uint) max(float)
161
- (uint8) (uint8) (int32) (uint32) (float)
162
- 0 1 1 -1 1 2.200000
163
- 1 2 1 (null) 3 3.300000
164
- 2 3 2 -4 6 6.600000
165
- TABLE
166
- end
167
-
168
- test("multiple") do
169
- assert_equal(<<-TABLE, @table.group(:group_key1, :group_key2).max.to_s)
170
- group_key1 group_key2 max(int) max(uint) max(float)
171
- (uint8) (uint8) (int32) (uint32) (float)
172
- 0 1 1 -1 1 2.200000
173
- 1 2 1 (null) 3 3.300000
174
- 2 3 1 -4 4 4.400000
175
- 3 3 2 -5 6 6.600000
176
- TABLE
177
- end
178
- end
179
-
180
- sub_test_case("#aggregate") do
181
- test("function()") do
182
- group = @table.group(:group_key1, :group_key2)
183
- assert_equal(<<-TABLE, group.aggregate("count(int)", "sum(uint)").to_s)
184
- group_key1 group_key2 count(int) sum(uint)
185
- (uint8) (uint8) (int64) (uint64)
186
- 0 1 1 2 1
187
- 1 2 1 0 3
188
- 2 3 1 1 4
189
- 3 3 2 2 11
190
- TABLE
191
- end
192
- end
193
- end
@@ -1,43 +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 HalfFloatArrayTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("Float") do
21
- array = Arrow::HalfFloatArray.new([1.5])
22
- assert_equal([1.5], array.to_a)
23
- end
24
-
25
- test("Integer") do
26
- one_half = Arrow::HalfFloat.new(1.5)
27
- array = Arrow::HalfFloatArray.new([one_half.to_uint16])
28
- assert_equal([one_half.to_f], array.to_a)
29
- end
30
-
31
- test("HalfFloat") do
32
- one_half = Arrow::HalfFloat.new(1.5)
33
- array = Arrow::HalfFloatArray.new([one_half])
34
- assert_equal([one_half.to_f], array.to_a)
35
- end
36
- end
37
-
38
- test("#[]") do
39
- one_half = Arrow::HalfFloat.new(1.5)
40
- array = Arrow::HalfFloatArray.new([one_half.to_uint16])
41
- assert_equal(one_half.to_f, array[0])
42
- end
43
- end
@@ -1,130 +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 HalfFloatTest < Test::Unit::TestCase
19
- sub_test_case(".new") do
20
- test("Array") do
21
- positive_infinity = Arrow::HalfFloat.new(0b1, 0b11111, 0b0000000000)
22
- assert_equal([0b1, 0b11111, 0b0000000000],
23
- [
24
- positive_infinity.sign,
25
- positive_infinity.exponent,
26
- positive_infinity.fraction,
27
- ])
28
- end
29
-
30
- test("Integer - 0") do
31
- zero = Arrow::HalfFloat.new(0)
32
- assert_equal([0b0, 0b00000, 0b0000000000],
33
- [
34
- zero.sign,
35
- zero.exponent,
36
- zero.fraction,
37
- ])
38
- end
39
-
40
- test("Integer - +infinity") do
41
- positive_infinity = Arrow::HalfFloat.new(0x7c00)
42
- assert_equal([0b0, 0b11111, 0b0000000000],
43
- [
44
- positive_infinity.sign,
45
- positive_infinity.exponent,
46
- positive_infinity.fraction,
47
- ])
48
- end
49
-
50
- test("Integer - -infinity") do
51
- negative_infinity = Arrow::HalfFloat.new(0xfc00)
52
- assert_equal([0b1, 0b11111, 0b0000000000],
53
- [
54
- negative_infinity.sign,
55
- negative_infinity.exponent,
56
- negative_infinity.fraction,
57
- ])
58
- end
59
-
60
- test("Integer - 1/3") do
61
- one_thirds = Arrow::HalfFloat.new(0x3555)
62
- assert_equal([0b0, 0b01101, 0b0101010101],
63
- [
64
- one_thirds.sign,
65
- one_thirds.exponent,
66
- one_thirds.fraction,
67
- ])
68
- end
69
-
70
- test("Float - 0") do
71
- zero = Arrow::HalfFloat.new(0.0)
72
- assert_equal([0b0, 0b00000, 0b0000000000],
73
- [
74
- zero.sign,
75
- zero.exponent,
76
- zero.fraction,
77
- ])
78
- end
79
-
80
- test("Float - too large") do
81
- positive_infinity = Arrow::HalfFloat.new(65504.1)
82
- assert_equal([0b0, 0b11111, 0b0000000000],
83
- [
84
- positive_infinity.sign,
85
- positive_infinity.exponent,
86
- positive_infinity.fraction,
87
- ])
88
- end
89
-
90
- test("Float - +infinity") do
91
- positive_infinity = Arrow::HalfFloat.new(Float::INFINITY)
92
- assert_equal([0b0, 0b11111, 0b0000000000],
93
- [
94
- positive_infinity.sign,
95
- positive_infinity.exponent,
96
- positive_infinity.fraction,
97
- ])
98
- end
99
-
100
- test("Float - too small") do
101
- negative_infinity = Arrow::HalfFloat.new(-65504.1)
102
- assert_equal([0b1, 0b11111, 0b0000000000],
103
- [
104
- negative_infinity.sign,
105
- negative_infinity.exponent,
106
- negative_infinity.fraction,
107
- ])
108
- end
109
-
110
- test("Float - -infinity") do
111
- negative_infinity = Arrow::HalfFloat.new(-Float::INFINITY)
112
- assert_equal([0b1, 0b11111, 0b0000000000],
113
- [
114
- negative_infinity.sign,
115
- negative_infinity.exponent,
116
- negative_infinity.fraction,
117
- ])
118
- end
119
-
120
- test("Float - 1/3") do
121
- one_thirds = Arrow::HalfFloat.new((2 ** -2) * (1 + 341 / 1024.0))
122
- assert_equal([0b0, 0b01101, 0b0101010101],
123
- [
124
- one_thirds.sign,
125
- one_thirds.exponent,
126
- one_thirds.fraction,
127
- ])
128
- end
129
- end
130
- end
@@ -1,79 +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 ListArrayBuilderTest < Test::Unit::TestCase
19
- def setup
20
- @data_type = Arrow::ListDataType.new(name: "visible", type: :boolean)
21
- @builder = Arrow::ListArrayBuilder.new(@data_type)
22
- end
23
-
24
- sub_test_case("#append_value") do
25
- test("nil") do
26
- @builder.append_value(nil)
27
- array = @builder.finish
28
- assert_equal(nil, array[0])
29
- end
30
-
31
- test("Array") do
32
- @builder.append_value([true, false, true])
33
- array = @builder.finish
34
- assert_equal([true, false, true], array[0].to_a)
35
- end
36
- end
37
-
38
- sub_test_case("#append_values") do
39
- test("[nil, Array]") do
40
- @builder.append_values([[false], nil, [true, false, true]])
41
- array = @builder.finish
42
- assert_equal([
43
- [false],
44
- nil,
45
- [true, false, true],
46
- ],
47
- array.collect {|list| list ? list.to_a : nil})
48
- end
49
-
50
- test("is_valids") do
51
- @builder.append_values([[false], [true, true], [true, false, true]],
52
- [true, false, true])
53
- array = @builder.finish
54
- assert_equal([
55
- [false],
56
- nil,
57
- [true, false, true],
58
- ],
59
- array.collect {|list| list ? list.to_a : nil})
60
- end
61
- end
62
-
63
- sub_test_case("#append") do
64
- test("backward compatibility") do
65
- @builder.append
66
- @builder.value_builder.append(true)
67
- @builder.value_builder.append(false)
68
- @builder.append
69
- @builder.value_builder.append(true)
70
- array = @builder.finish
71
-
72
- assert_equal([
73
- [true, false],
74
- [true],
75
- ],
76
- array.collect(&:to_a))
77
- end
78
- end
79
- end