red-arrow 22.0.0 → 23.0.0
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/ext/arrow/converters.cpp +5 -0
- data/ext/arrow/converters.hpp +115 -0
- data/ext/arrow/values.cpp +1 -0
- data/lib/arrow/array-builder.rb +49 -8
- data/lib/arrow/array-statistics.rb +12 -0
- data/lib/arrow/column.rb +12 -0
- data/lib/arrow/csv-write-options.rb +53 -0
- data/lib/arrow/duration-array-builder.rb +27 -0
- data/lib/arrow/duration-array.rb +24 -0
- data/lib/arrow/duration-data-type.rb +32 -0
- data/lib/arrow/fixed-size-list-array-builder.rb +29 -0
- data/lib/arrow/large-list-array-builder.rb +29 -0
- data/lib/arrow/large-list-data-type.rb +83 -0
- data/lib/arrow/libraries.rb +11 -0
- data/lib/arrow/list-array-builder.rb +1 -69
- data/lib/arrow/list-data-type.rb +3 -33
- data/lib/arrow/list-field-resolvable.rb +50 -0
- data/lib/arrow/list-slice-options.rb +76 -0
- data/lib/arrow/list-values-appendable.rb +88 -0
- data/lib/arrow/make-struct-options.rb +38 -0
- data/lib/arrow/version.rb +1 -1
- data/red-arrow.gemspec +2 -2
- metadata +30 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5d8f71916813b1efc347972a6ad663bf84561dba641e61d8367e7bec67adbca
|
|
4
|
+
data.tar.gz: 4667c7515eb8662a734907348851ae557f982fb6ad534f6f18a3e8aa10dce15f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c18d5f0d79959d48fd69719350fa31636853c073a3e11743b52654eacf2d6e400a4cc0f7f4a058679d986ddf181cf207692cf0714b956a6490c2a0ceb290e938
|
|
7
|
+
data.tar.gz: 192614cfa849cacf28cdabf63727d648d421c795a4a6043ac77b3d5b4b1048440ad6dd2dc06fb5b02fe667efc0bf9c7f4eb177bde2b7b9414ddf4fb32269718c
|
data/ext/arrow/converters.cpp
CHANGED
|
@@ -25,6 +25,11 @@ namespace red_arrow {
|
|
|
25
25
|
return list_array_value_converter_->convert(array, i);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
VALUE ArrayValueConverter::convert(const arrow::LargeListArray& array,
|
|
29
|
+
const int64_t i) {
|
|
30
|
+
return large_list_array_value_converter_->convert(array, i);
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
VALUE ArrayValueConverter::convert(const arrow::StructArray& array,
|
|
29
34
|
const int64_t i) {
|
|
30
35
|
return struct_array_value_converter_->convert(array, i);
|
data/ext/arrow/converters.hpp
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
namespace red_arrow {
|
|
30
30
|
class ListArrayValueConverter;
|
|
31
|
+
class LargeListArrayValueConverter;
|
|
31
32
|
class StructArrayValueConverter;
|
|
32
33
|
class MapArrayValueConverter;
|
|
33
34
|
class UnionArrayValueConverter;
|
|
@@ -38,6 +39,7 @@ namespace red_arrow {
|
|
|
38
39
|
ArrayValueConverter()
|
|
39
40
|
: decimal_buffer_(),
|
|
40
41
|
list_array_value_converter_(nullptr),
|
|
42
|
+
large_list_array_value_converter_(nullptr),
|
|
41
43
|
struct_array_value_converter_(nullptr),
|
|
42
44
|
map_array_value_converter_(nullptr),
|
|
43
45
|
union_array_value_converter_(nullptr),
|
|
@@ -45,11 +47,13 @@ namespace red_arrow {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
inline void set_sub_value_converters(ListArrayValueConverter* list_array_value_converter,
|
|
50
|
+
LargeListArrayValueConverter* large_list_array_value_converter,
|
|
48
51
|
StructArrayValueConverter* struct_array_value_converter,
|
|
49
52
|
MapArrayValueConverter* map_array_value_converter,
|
|
50
53
|
UnionArrayValueConverter* union_array_value_converter,
|
|
51
54
|
DictionaryArrayValueConverter* dictionary_array_value_converter) {
|
|
52
55
|
list_array_value_converter_ = list_array_value_converter;
|
|
56
|
+
large_list_array_value_converter_ = large_list_array_value_converter;
|
|
53
57
|
struct_array_value_converter_ = struct_array_value_converter;
|
|
54
58
|
map_array_value_converter_ = map_array_value_converter;
|
|
55
59
|
union_array_value_converter_ = union_array_value_converter;
|
|
@@ -263,6 +267,9 @@ namespace red_arrow {
|
|
|
263
267
|
VALUE convert(const arrow::ListArray& array,
|
|
264
268
|
const int64_t i);
|
|
265
269
|
|
|
270
|
+
VALUE convert(const arrow::LargeListArray& array,
|
|
271
|
+
const int64_t i);
|
|
272
|
+
|
|
266
273
|
VALUE convert(const arrow::StructArray& array,
|
|
267
274
|
const int64_t i);
|
|
268
275
|
|
|
@@ -298,6 +305,7 @@ namespace red_arrow {
|
|
|
298
305
|
|
|
299
306
|
std::string decimal_buffer_;
|
|
300
307
|
ListArrayValueConverter* list_array_value_converter_;
|
|
308
|
+
LargeListArrayValueConverter* large_list_array_value_converter_;
|
|
301
309
|
StructArrayValueConverter* struct_array_value_converter_;
|
|
302
310
|
MapArrayValueConverter* map_array_value_converter_;
|
|
303
311
|
UnionArrayValueConverter* union_array_value_converter_;
|
|
@@ -359,6 +367,106 @@ namespace red_arrow {
|
|
|
359
367
|
VISIT(DayTimeInterval)
|
|
360
368
|
VISIT(MonthDayNanoInterval)
|
|
361
369
|
VISIT(List)
|
|
370
|
+
VISIT(LargeList)
|
|
371
|
+
VISIT(Struct)
|
|
372
|
+
VISIT(Map)
|
|
373
|
+
VISIT(SparseUnion)
|
|
374
|
+
VISIT(DenseUnion)
|
|
375
|
+
VISIT(Dictionary)
|
|
376
|
+
VISIT(Decimal128)
|
|
377
|
+
VISIT(Decimal256)
|
|
378
|
+
// TODO
|
|
379
|
+
// VISIT(Extension)
|
|
380
|
+
|
|
381
|
+
#undef VISIT
|
|
382
|
+
|
|
383
|
+
private:
|
|
384
|
+
template <typename ArrayType>
|
|
385
|
+
inline VALUE convert_value(const ArrayType& array,
|
|
386
|
+
const int64_t i) {
|
|
387
|
+
return array_value_converter_->convert(array, i);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
template <typename ArrayType>
|
|
391
|
+
arrow::Status visit_value(const ArrayType& array) {
|
|
392
|
+
if (array.null_count() > 0) {
|
|
393
|
+
for (int64_t i = 0; i < length_; ++i) {
|
|
394
|
+
auto value = Qnil;
|
|
395
|
+
if (!array.IsNull(i + offset_)) {
|
|
396
|
+
value = convert_value(array, i + offset_);
|
|
397
|
+
}
|
|
398
|
+
rb_ary_push(result_, value);
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
for (int64_t i = 0; i < length_; ++i) {
|
|
402
|
+
rb_ary_push(result_, convert_value(array, i + offset_));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return arrow::Status::OK();
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
ArrayValueConverter* array_value_converter_;
|
|
409
|
+
int32_t offset_;
|
|
410
|
+
int32_t length_;
|
|
411
|
+
VALUE result_;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
class LargeListArrayValueConverter : public arrow::ArrayVisitor {
|
|
415
|
+
public:
|
|
416
|
+
explicit LargeListArrayValueConverter(ArrayValueConverter* converter)
|
|
417
|
+
: array_value_converter_(converter),
|
|
418
|
+
offset_(0),
|
|
419
|
+
length_(0),
|
|
420
|
+
result_(Qnil) {}
|
|
421
|
+
|
|
422
|
+
VALUE convert(const arrow::LargeListArray& array, const int64_t index) {
|
|
423
|
+
auto values = array.values().get();
|
|
424
|
+
auto offset_keep = offset_;
|
|
425
|
+
auto length_keep = length_;
|
|
426
|
+
offset_ = array.value_offset(index);
|
|
427
|
+
length_ = array.value_length(index);
|
|
428
|
+
auto result_keep = result_;
|
|
429
|
+
result_ = rb_ary_new_capa(length_);
|
|
430
|
+
check_status(values->Accept(this),
|
|
431
|
+
"[raw-records][large-list-array]");
|
|
432
|
+
offset_ = offset_keep;
|
|
433
|
+
length_ = length_keep;
|
|
434
|
+
auto result_return = result_;
|
|
435
|
+
result_ = result_keep;
|
|
436
|
+
return result_return;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
#define VISIT(TYPE) \
|
|
440
|
+
arrow::Status Visit(const arrow::TYPE ## Array& array) override { \
|
|
441
|
+
return visit_value(array); \
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
VISIT(Null)
|
|
445
|
+
VISIT(Boolean)
|
|
446
|
+
VISIT(Int8)
|
|
447
|
+
VISIT(Int16)
|
|
448
|
+
VISIT(Int32)
|
|
449
|
+
VISIT(Int64)
|
|
450
|
+
VISIT(UInt8)
|
|
451
|
+
VISIT(UInt16)
|
|
452
|
+
VISIT(UInt32)
|
|
453
|
+
VISIT(UInt64)
|
|
454
|
+
VISIT(HalfFloat)
|
|
455
|
+
VISIT(Float)
|
|
456
|
+
VISIT(Double)
|
|
457
|
+
VISIT(Binary)
|
|
458
|
+
VISIT(String)
|
|
459
|
+
VISIT(FixedSizeBinary)
|
|
460
|
+
VISIT(Date32)
|
|
461
|
+
VISIT(Date64)
|
|
462
|
+
VISIT(Time32)
|
|
463
|
+
VISIT(Time64)
|
|
464
|
+
VISIT(Timestamp)
|
|
465
|
+
VISIT(MonthInterval)
|
|
466
|
+
VISIT(DayTimeInterval)
|
|
467
|
+
VISIT(MonthDayNanoInterval)
|
|
468
|
+
VISIT(List)
|
|
469
|
+
VISIT(LargeList)
|
|
362
470
|
VISIT(Struct)
|
|
363
471
|
VISIT(Map)
|
|
364
472
|
VISIT(SparseUnion)
|
|
@@ -465,6 +573,7 @@ namespace red_arrow {
|
|
|
465
573
|
VISIT(DayTimeInterval)
|
|
466
574
|
VISIT(MonthDayNanoInterval)
|
|
467
575
|
VISIT(List)
|
|
576
|
+
VISIT(LargeList)
|
|
468
577
|
VISIT(Struct)
|
|
469
578
|
VISIT(Map)
|
|
470
579
|
VISIT(SparseUnion)
|
|
@@ -567,6 +676,7 @@ namespace red_arrow {
|
|
|
567
676
|
VISIT(DayTimeInterval)
|
|
568
677
|
VISIT(MonthDayNanoInterval)
|
|
569
678
|
VISIT(List)
|
|
679
|
+
VISIT(LargeList)
|
|
570
680
|
VISIT(Struct)
|
|
571
681
|
VISIT(Map)
|
|
572
682
|
VISIT(SparseUnion)
|
|
@@ -670,6 +780,7 @@ namespace red_arrow {
|
|
|
670
780
|
VISIT(DayTimeInterval)
|
|
671
781
|
VISIT(MonthDayNanoInterval)
|
|
672
782
|
VISIT(List)
|
|
783
|
+
VISIT(LargeList)
|
|
673
784
|
VISIT(Struct)
|
|
674
785
|
VISIT(Map)
|
|
675
786
|
VISIT(SparseUnion)
|
|
@@ -781,6 +892,7 @@ namespace red_arrow {
|
|
|
781
892
|
VISIT(DayTimeInterval)
|
|
782
893
|
VISIT(MonthDayNanoInterval)
|
|
783
894
|
VISIT(List)
|
|
895
|
+
VISIT(LargeList)
|
|
784
896
|
VISIT(Struct)
|
|
785
897
|
VISIT(Map)
|
|
786
898
|
VISIT(SparseUnion)
|
|
@@ -810,12 +922,14 @@ namespace red_arrow {
|
|
|
810
922
|
explicit Converter()
|
|
811
923
|
: array_value_converter_(),
|
|
812
924
|
list_array_value_converter_(&array_value_converter_),
|
|
925
|
+
large_list_array_value_converter_(&array_value_converter_),
|
|
813
926
|
struct_array_value_converter_(&array_value_converter_),
|
|
814
927
|
map_array_value_converter_(&array_value_converter_),
|
|
815
928
|
union_array_value_converter_(&array_value_converter_),
|
|
816
929
|
dictionary_array_value_converter_(&array_value_converter_) {
|
|
817
930
|
array_value_converter_.
|
|
818
931
|
set_sub_value_converters(&list_array_value_converter_,
|
|
932
|
+
&large_list_array_value_converter_,
|
|
819
933
|
&struct_array_value_converter_,
|
|
820
934
|
&map_array_value_converter_,
|
|
821
935
|
&union_array_value_converter_,
|
|
@@ -830,6 +944,7 @@ namespace red_arrow {
|
|
|
830
944
|
|
|
831
945
|
ArrayValueConverter array_value_converter_;
|
|
832
946
|
ListArrayValueConverter list_array_value_converter_;
|
|
947
|
+
LargeListArrayValueConverter large_list_array_value_converter_;
|
|
833
948
|
StructArrayValueConverter struct_array_value_converter_;
|
|
834
949
|
MapArrayValueConverter map_array_value_converter_;
|
|
835
950
|
UnionArrayValueConverter union_array_value_converter_;
|
data/ext/arrow/values.cpp
CHANGED
data/lib/arrow/array-builder.rb
CHANGED
|
@@ -74,14 +74,23 @@ module Arrow
|
|
|
74
74
|
detected: true,
|
|
75
75
|
}
|
|
76
76
|
when Integer
|
|
77
|
-
|
|
77
|
+
builder_info ||= {}
|
|
78
|
+
min = builder_info[:min] || value
|
|
79
|
+
max = builder_info[:max] || value
|
|
80
|
+
min = value if value < min
|
|
81
|
+
max = value if value > max
|
|
82
|
+
|
|
83
|
+
if builder_info[:builder_type] == :int || value < 0
|
|
78
84
|
{
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
builder_type: :int,
|
|
86
|
+
min: min,
|
|
87
|
+
max: max,
|
|
81
88
|
}
|
|
82
89
|
else
|
|
83
90
|
{
|
|
84
|
-
|
|
91
|
+
builder_type: :uint,
|
|
92
|
+
min: min,
|
|
93
|
+
max: max,
|
|
85
94
|
}
|
|
86
95
|
end
|
|
87
96
|
when Time
|
|
@@ -150,17 +159,20 @@ module Arrow
|
|
|
150
159
|
end
|
|
151
160
|
end
|
|
152
161
|
when ::Array
|
|
153
|
-
sub_builder_info =
|
|
162
|
+
sub_builder_info = builder_info && builder_info[:value_builder_info]
|
|
154
163
|
value.each do |sub_value|
|
|
155
164
|
sub_builder_info = detect_builder_info(sub_value, sub_builder_info)
|
|
156
165
|
break if sub_builder_info and sub_builder_info[:detected]
|
|
157
166
|
end
|
|
158
|
-
if sub_builder_info
|
|
159
|
-
|
|
167
|
+
if sub_builder_info
|
|
168
|
+
sub_builder = sub_builder_info[:builder] || create_builder(sub_builder_info)
|
|
169
|
+
return sub_builder_info unless sub_builder
|
|
170
|
+
sub_value_data_type = sub_builder.value_data_type
|
|
160
171
|
field = Field.new("item", sub_value_data_type)
|
|
161
172
|
{
|
|
162
173
|
builder: ListArrayBuilder.new(ListDataType.new(field)),
|
|
163
|
-
|
|
174
|
+
value_builder_info: sub_builder_info,
|
|
175
|
+
detected: sub_builder_info[:detected],
|
|
164
176
|
}
|
|
165
177
|
else
|
|
166
178
|
builder_info
|
|
@@ -184,6 +196,35 @@ module Arrow
|
|
|
184
196
|
data_type = Decimal256DataType.new(builder_info[:precision],
|
|
185
197
|
builder_info[:scale])
|
|
186
198
|
Decimal256ArrayBuilder.new(data_type)
|
|
199
|
+
when :int
|
|
200
|
+
min = builder_info[:min]
|
|
201
|
+
max = builder_info[:max]
|
|
202
|
+
|
|
203
|
+
if GLib::MININT8 <= min && max <= GLib::MAXINT8
|
|
204
|
+
Int8ArrayBuilder.new
|
|
205
|
+
elsif GLib::MININT16 <= min && max <= GLib::MAXINT16
|
|
206
|
+
Int16ArrayBuilder.new
|
|
207
|
+
elsif GLib::MININT32 <= min && max <= GLib::MAXINT32
|
|
208
|
+
Int32ArrayBuilder.new
|
|
209
|
+
elsif GLib::MININT64 <= min && max <= GLib::MAXINT64
|
|
210
|
+
Int64ArrayBuilder.new
|
|
211
|
+
else
|
|
212
|
+
StringArrayBuilder.new
|
|
213
|
+
end
|
|
214
|
+
when :uint
|
|
215
|
+
max = builder_info[:max]
|
|
216
|
+
|
|
217
|
+
if max <= GLib::MAXUINT8
|
|
218
|
+
UInt8ArrayBuilder.new
|
|
219
|
+
elsif max <= GLib::MAXUINT16
|
|
220
|
+
UInt16ArrayBuilder.new
|
|
221
|
+
elsif max <= GLib::MAXUINT32
|
|
222
|
+
UInt32ArrayBuilder.new
|
|
223
|
+
elsif max <= GLib::MAXUINT64
|
|
224
|
+
UInt64ArrayBuilder.new
|
|
225
|
+
else
|
|
226
|
+
StringArrayBuilder.new
|
|
227
|
+
end
|
|
187
228
|
else
|
|
188
229
|
nil
|
|
189
230
|
end
|
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
|
|
18
18
|
module Arrow
|
|
19
19
|
class ArrayStatistics
|
|
20
|
+
if method_defined?(:null_count_exact)
|
|
21
|
+
alias_method :null_count_raw, :null_count
|
|
22
|
+
def null_count
|
|
23
|
+
return nil unless has_null_count?
|
|
24
|
+
if null_count_exact?
|
|
25
|
+
null_count_exact
|
|
26
|
+
else
|
|
27
|
+
null_count_approximate
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
20
32
|
if method_defined?(:distinct_count_exact)
|
|
21
33
|
alias_method :distinct_count_raw, :distinct_count
|
|
22
34
|
def distinct_count
|
data/lib/arrow/column.rb
CHANGED
|
@@ -30,6 +30,18 @@ module Arrow
|
|
|
30
30
|
@container.share_input(@data)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
def to_arrow
|
|
34
|
+
@data
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_arrow_array
|
|
38
|
+
@data.to_arrow_array
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_arrow_chunked_array
|
|
42
|
+
@data.to_arrow_chunked_array
|
|
43
|
+
end
|
|
44
|
+
|
|
33
45
|
def name
|
|
34
46
|
@field.name
|
|
35
47
|
end
|
|
@@ -0,0 +1,53 @@
|
|
|
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 Arrow
|
|
19
|
+
class CSVWriteOptions
|
|
20
|
+
class << self
|
|
21
|
+
def try_convert(value)
|
|
22
|
+
case value
|
|
23
|
+
when Hash
|
|
24
|
+
options = new
|
|
25
|
+
value.each do |k, v|
|
|
26
|
+
options.public_send("#{k}=", v)
|
|
27
|
+
end
|
|
28
|
+
options
|
|
29
|
+
else
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
alias_method :delimiter_raw, :delimiter
|
|
36
|
+
def delimiter
|
|
37
|
+
delimiter_raw.chr
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
alias_method :delimiter_raw=, :delimiter=
|
|
41
|
+
def delimiter=(delimiter)
|
|
42
|
+
case delimiter
|
|
43
|
+
when String
|
|
44
|
+
if delimiter.bytesize != 1
|
|
45
|
+
message = "delimiter must be 1 byte character: #{delimiter.inspect}"
|
|
46
|
+
raise ArgumentError, message
|
|
47
|
+
end
|
|
48
|
+
delimiter = delimiter.ord
|
|
49
|
+
end
|
|
50
|
+
self.delimiter_raw = delimiter
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
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 Arrow
|
|
19
|
+
class DurationArrayBuilder
|
|
20
|
+
class << self
|
|
21
|
+
def build(data_type, values)
|
|
22
|
+
builder = new(data_type)
|
|
23
|
+
builder.build(values)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
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 Arrow
|
|
19
|
+
class DurationArray
|
|
20
|
+
def unit
|
|
21
|
+
@unit ||= value_data_type.unit
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
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 Arrow
|
|
19
|
+
class DurationDataType
|
|
20
|
+
class << self
|
|
21
|
+
# @api private
|
|
22
|
+
def try_convert(value)
|
|
23
|
+
case value
|
|
24
|
+
when Symbol, Arrow::TimeUnit
|
|
25
|
+
new(value)
|
|
26
|
+
else
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
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 Arrow
|
|
19
|
+
class FixedSizeListArrayBuilder
|
|
20
|
+
class << self
|
|
21
|
+
def build(data_type, values)
|
|
22
|
+
builder = new(data_type)
|
|
23
|
+
builder.build(values)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
prepend ListValuesAppendable
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
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 Arrow
|
|
19
|
+
class LargeListArrayBuilder
|
|
20
|
+
class << self
|
|
21
|
+
def build(data_type, values)
|
|
22
|
+
builder = new(data_type)
|
|
23
|
+
builder.build(values)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
prepend ListValuesAppendable
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
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 Arrow
|
|
19
|
+
class LargeListDataType
|
|
20
|
+
include ListFieldResolvable
|
|
21
|
+
|
|
22
|
+
alias_method :initialize_raw, :initialize
|
|
23
|
+
private :initialize_raw
|
|
24
|
+
|
|
25
|
+
# Creates a new {Arrow::LargeListDataType}.
|
|
26
|
+
#
|
|
27
|
+
# @overload initialize(field)
|
|
28
|
+
#
|
|
29
|
+
# @param field [Arrow::Field, Hash] The field of the large list
|
|
30
|
+
# data type. You can also specify field description by `Hash`.
|
|
31
|
+
#
|
|
32
|
+
# See {Arrow::Field.new} how to specify field description.
|
|
33
|
+
#
|
|
34
|
+
# @example Create a large list data type with {Arrow::Field}
|
|
35
|
+
# visible_field = Arrow::Field.new("visible", :boolean)
|
|
36
|
+
# Arrow::LargeListDataType.new(visible_field)
|
|
37
|
+
#
|
|
38
|
+
# @example Create a large list data type with field description
|
|
39
|
+
# Arrow::LargeListDataType.new(name: "visible", type: :boolean)
|
|
40
|
+
#
|
|
41
|
+
# @overload initialize(description)
|
|
42
|
+
#
|
|
43
|
+
# @param description [Hash] The description of the large list data
|
|
44
|
+
# type. It must have `:field` value.
|
|
45
|
+
#
|
|
46
|
+
# @option description [Arrow::Field, Hash] :field The field of
|
|
47
|
+
# the large list data type. You can also specify field
|
|
48
|
+
# description by `Hash`.
|
|
49
|
+
#
|
|
50
|
+
# See {Arrow::Field.new} how to specify field description.
|
|
51
|
+
#
|
|
52
|
+
# @example Create a large list data type with {Arrow::Field}
|
|
53
|
+
# visible_field = Arrow::Field.new("visible", :boolean)
|
|
54
|
+
# Arrow::LargeListDataType.new(field: visible_field)
|
|
55
|
+
#
|
|
56
|
+
# @example Create a large list data type with field description
|
|
57
|
+
# Arrow::LargeListDataType.new(field: {name: "visible", type: :boolean})
|
|
58
|
+
#
|
|
59
|
+
# @overload initialize(data_type)
|
|
60
|
+
#
|
|
61
|
+
# @param data_type [Arrow::DataType, String, Symbol,
|
|
62
|
+
# ::Array<String>, ::Array<Symbol>, Hash] The element data
|
|
63
|
+
# type of the large list data type. A field is created with the
|
|
64
|
+
# default name `"item"` from the data type automatically.
|
|
65
|
+
#
|
|
66
|
+
# See {Arrow::DataType.resolve} how to specify data type.
|
|
67
|
+
#
|
|
68
|
+
# @example Create a large list data type with {Arrow::DataType}
|
|
69
|
+
# Arrow::LargeListDataType.new(Arrow::BooleanDataType.new)
|
|
70
|
+
#
|
|
71
|
+
# @example Create a large list data type with data type name as String
|
|
72
|
+
# Arrow::LargeListDataType.new("boolean")
|
|
73
|
+
#
|
|
74
|
+
# @example Create a large list data type with data type name as Symbol
|
|
75
|
+
# Arrow::LargeListDataType.new(:boolean)
|
|
76
|
+
#
|
|
77
|
+
# @example Create a large list data type with data type as Array
|
|
78
|
+
# Arrow::LargeListDataType.new([:time32, :milli])
|
|
79
|
+
def initialize(arg)
|
|
80
|
+
initialize_raw(resolve_field(arg))
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
data/lib/arrow/libraries.rb
CHANGED
|
@@ -21,6 +21,8 @@ require_relative "field-containable"
|
|
|
21
21
|
require_relative "generic-filterable"
|
|
22
22
|
require_relative "generic-takeable"
|
|
23
23
|
require_relative "input-referable"
|
|
24
|
+
require_relative "list-field-resolvable"
|
|
25
|
+
require_relative "list-values-appendable"
|
|
24
26
|
require_relative "record-containable"
|
|
25
27
|
require_relative "symbol-values-appendable"
|
|
26
28
|
|
|
@@ -37,6 +39,7 @@ require_relative "column"
|
|
|
37
39
|
require_relative "compression-type"
|
|
38
40
|
require_relative "csv-loader"
|
|
39
41
|
require_relative "csv-read-options"
|
|
42
|
+
require_relative "csv-write-options"
|
|
40
43
|
require_relative "data-type"
|
|
41
44
|
require_relative "date32-array"
|
|
42
45
|
require_relative "date32-array-builder"
|
|
@@ -57,6 +60,9 @@ require_relative "dense-union-array-builder"
|
|
|
57
60
|
require_relative "dense-union-data-type"
|
|
58
61
|
require_relative "dictionary-array"
|
|
59
62
|
require_relative "dictionary-data-type"
|
|
63
|
+
require_relative "duration-array"
|
|
64
|
+
require_relative "duration-array-builder"
|
|
65
|
+
require_relative "duration-data-type"
|
|
60
66
|
require_relative "equal-options"
|
|
61
67
|
require_relative "expression"
|
|
62
68
|
require_relative "field"
|
|
@@ -64,13 +70,18 @@ require_relative "file-output-stream"
|
|
|
64
70
|
require_relative "file-system"
|
|
65
71
|
require_relative "fixed-size-binary-array"
|
|
66
72
|
require_relative "fixed-size-binary-array-builder"
|
|
73
|
+
require_relative "fixed-size-list-array-builder"
|
|
67
74
|
require_relative "function"
|
|
68
75
|
require_relative "group"
|
|
69
76
|
require_relative "half-float"
|
|
70
77
|
require_relative "half-float-array"
|
|
71
78
|
require_relative "half-float-array-builder"
|
|
79
|
+
require_relative "large-list-array-builder"
|
|
80
|
+
require_relative "large-list-data-type"
|
|
72
81
|
require_relative "list-array-builder"
|
|
73
82
|
require_relative "list-data-type"
|
|
83
|
+
require_relative "list-slice-options"
|
|
84
|
+
require_relative "make-struct-options"
|
|
74
85
|
require_relative "map-array"
|
|
75
86
|
require_relative "map-array-builder"
|
|
76
87
|
require_relative "map-data-type"
|
|
@@ -24,74 +24,6 @@ module Arrow
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# @overload append_value
|
|
30
|
-
#
|
|
31
|
-
# Starts appending a list record. You also need to append list
|
|
32
|
-
# value by {#value_builder}.
|
|
33
|
-
#
|
|
34
|
-
# @overload append_value(list)
|
|
35
|
-
#
|
|
36
|
-
# Appends a list record including list value.
|
|
37
|
-
#
|
|
38
|
-
# @param value [nil, ::Array] The list value of the record.
|
|
39
|
-
#
|
|
40
|
-
# If this is `nil`, the list record is null.
|
|
41
|
-
#
|
|
42
|
-
# If this is `Array`, it's the list value of the record.
|
|
43
|
-
#
|
|
44
|
-
# @since 0.12.0
|
|
45
|
-
def append_value(*args)
|
|
46
|
-
n_args = args.size
|
|
47
|
-
|
|
48
|
-
case n_args
|
|
49
|
-
when 0
|
|
50
|
-
append_value_raw
|
|
51
|
-
when 1
|
|
52
|
-
value = args[0]
|
|
53
|
-
case value
|
|
54
|
-
when nil
|
|
55
|
-
append_null
|
|
56
|
-
when ::Array
|
|
57
|
-
append_value_raw
|
|
58
|
-
return if value.empty?
|
|
59
|
-
@value_builder ||= value_builder
|
|
60
|
-
@value_builder.append(*value)
|
|
61
|
-
else
|
|
62
|
-
message = "list value must be nil or Array: #{value.inspect}"
|
|
63
|
-
raise ArgumentError, message
|
|
64
|
-
end
|
|
65
|
-
else
|
|
66
|
-
message = "wrong number of arguments (given #{n_args}, expected 0..1)"
|
|
67
|
-
raise ArgumentError, message
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def append_values(lists, is_valids=nil)
|
|
72
|
-
if is_valids
|
|
73
|
-
is_valids.each_with_index do |is_valid, i|
|
|
74
|
-
if is_valid
|
|
75
|
-
append_value(lists[i])
|
|
76
|
-
else
|
|
77
|
-
append_null
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
else
|
|
81
|
-
lists.each do |list|
|
|
82
|
-
append_value(list)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# @since 0.12.0
|
|
88
|
-
def append(*values)
|
|
89
|
-
if values.empty?
|
|
90
|
-
# For backward compatibility
|
|
91
|
-
append_value
|
|
92
|
-
else
|
|
93
|
-
super
|
|
94
|
-
end
|
|
95
|
-
end
|
|
27
|
+
prepend ListValuesAppendable
|
|
96
28
|
end
|
|
97
29
|
end
|
data/lib/arrow/list-data-type.rb
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
module Arrow
|
|
19
19
|
class ListDataType
|
|
20
|
+
include ListFieldResolvable
|
|
21
|
+
|
|
20
22
|
alias_method :initialize_raw, :initialize
|
|
21
23
|
private :initialize_raw
|
|
22
24
|
|
|
@@ -75,39 +77,7 @@ module Arrow
|
|
|
75
77
|
# @example Create a list data type with data type as Array
|
|
76
78
|
# Arrow::ListDataType.new([:time32, :milli])
|
|
77
79
|
def initialize(arg)
|
|
78
|
-
|
|
79
|
-
if data_type
|
|
80
|
-
field = Field.new(default_field_name, data_type)
|
|
81
|
-
else
|
|
82
|
-
field = resolve_field(arg)
|
|
83
|
-
end
|
|
84
|
-
initialize_raw(field)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
private
|
|
88
|
-
def resolve_data_type(arg)
|
|
89
|
-
case arg
|
|
90
|
-
when DataType, String, Symbol, ::Array
|
|
91
|
-
DataType.resolve(arg)
|
|
92
|
-
when Hash
|
|
93
|
-
return nil if arg[:name]
|
|
94
|
-
return nil unless arg[:type]
|
|
95
|
-
DataType.resolve(arg)
|
|
96
|
-
else
|
|
97
|
-
nil
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def default_field_name
|
|
102
|
-
"item"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def resolve_field(arg)
|
|
106
|
-
if arg.is_a?(Hash) and arg.key?(:field)
|
|
107
|
-
description = arg
|
|
108
|
-
arg = description[:field]
|
|
109
|
-
end
|
|
110
|
-
arg
|
|
80
|
+
initialize_raw(resolve_field(arg))
|
|
111
81
|
end
|
|
112
82
|
end
|
|
113
83
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Arrow
|
|
19
|
+
module ListFieldResolvable
|
|
20
|
+
private
|
|
21
|
+
def resolve_data_type(arg)
|
|
22
|
+
case arg
|
|
23
|
+
when DataType, String, Symbol, ::Array
|
|
24
|
+
DataType.resolve(arg)
|
|
25
|
+
when Hash
|
|
26
|
+
return nil if arg[:name]
|
|
27
|
+
return nil unless arg[:type]
|
|
28
|
+
DataType.resolve(arg)
|
|
29
|
+
else
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def default_field_name
|
|
35
|
+
"item"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def resolve_field(arg)
|
|
39
|
+
data_type = resolve_data_type(arg)
|
|
40
|
+
if data_type
|
|
41
|
+
Field.new(default_field_name, data_type)
|
|
42
|
+
elsif arg.is_a?(Hash) and arg.key?(:field)
|
|
43
|
+
description = arg
|
|
44
|
+
description[:field]
|
|
45
|
+
else
|
|
46
|
+
arg
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
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 Arrow
|
|
19
|
+
class ListSliceOptions
|
|
20
|
+
alias_method :return_fixed_size_list_raw, :return_fixed_size_list
|
|
21
|
+
private :return_fixed_size_list_raw
|
|
22
|
+
|
|
23
|
+
RETURN_FIXED_SIZE_GLIB_TO_RUBY = {
|
|
24
|
+
ListSliceReturnFixedSizeList::AUTO => nil,
|
|
25
|
+
ListSliceReturnFixedSizeList::TRUE => true,
|
|
26
|
+
ListSliceReturnFixedSizeList::FALSE => false,
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
29
|
+
RETURN_FIXED_SIZE_RUBY_TO_GLIB = RETURN_FIXED_SIZE_GLIB_TO_RUBY.invert.freeze
|
|
30
|
+
|
|
31
|
+
# Whether to return a FixedSizeListArray. If true _and_ stop is after a
|
|
32
|
+
# list element’s length, nil values will be appended to create the requested
|
|
33
|
+
# slice size. The default of nil will return the same type which was passed in.
|
|
34
|
+
#
|
|
35
|
+
# @since 23.0.0
|
|
36
|
+
def return_fixed_size_list
|
|
37
|
+
RETURN_FIXED_SIZE_GLIB_TO_RUBY.fetch(
|
|
38
|
+
return_fixed_size_list_raw,
|
|
39
|
+
return_fixed_size_list_raw)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias_method :return_fixed_size_list_raw=, :return_fixed_size_list=
|
|
43
|
+
private :return_fixed_size_list_raw=
|
|
44
|
+
|
|
45
|
+
# Whether to return a FixedSizeListArray. If true _and_ stop is after a
|
|
46
|
+
# list element’s length, nil values will be appended to create the requested
|
|
47
|
+
# slice size. The default of nil will return the same type which was passed in.
|
|
48
|
+
#
|
|
49
|
+
# @since 23.0.0
|
|
50
|
+
def return_fixed_size_list=(return_fixed_size_list)
|
|
51
|
+
self.return_fixed_size_list_raw = RETURN_FIXED_SIZE_RUBY_TO_GLIB.fetch(
|
|
52
|
+
return_fixed_size_list,
|
|
53
|
+
return_fixed_size_list)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
alias_method :stop_raw, :stop
|
|
57
|
+
private :stop_raw
|
|
58
|
+
|
|
59
|
+
# Optional stop of list slicing. If set to nil, then slice to end.
|
|
60
|
+
#
|
|
61
|
+
# @since 23.0.0
|
|
62
|
+
def stop
|
|
63
|
+
stop_raw == LIST_SLICE_OPTIONS_STOP_UNSPECIFIED ? nil : stop_raw
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
alias_method :stop_raw=, :stop=
|
|
67
|
+
private :stop_raw=
|
|
68
|
+
|
|
69
|
+
# Optional stop of list slicing. If set to nil, then slice to end.
|
|
70
|
+
#
|
|
71
|
+
# @since 23.0.0
|
|
72
|
+
def stop=(stop)
|
|
73
|
+
self.stop_raw = stop.nil? ? LIST_SLICE_OPTIONS_STOP_UNSPECIFIED : stop
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
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 Arrow
|
|
19
|
+
module ListValuesAppendable
|
|
20
|
+
# @overload append_value
|
|
21
|
+
#
|
|
22
|
+
# Starts appending a list record. You also need to append list
|
|
23
|
+
# value by {#value_builder}.
|
|
24
|
+
#
|
|
25
|
+
# @overload append_value(list)
|
|
26
|
+
#
|
|
27
|
+
# Appends a list record including list value.
|
|
28
|
+
#
|
|
29
|
+
# @param value [nil, ::Array] The list value of the record.
|
|
30
|
+
#
|
|
31
|
+
# If this is `nil`, the list record is null.
|
|
32
|
+
#
|
|
33
|
+
# If this is `Array`, it's the list value of the record.
|
|
34
|
+
#
|
|
35
|
+
# @since 0.12.0
|
|
36
|
+
def append_value(*args)
|
|
37
|
+
n_args = args.size
|
|
38
|
+
|
|
39
|
+
case n_args
|
|
40
|
+
when 0
|
|
41
|
+
super()
|
|
42
|
+
when 1
|
|
43
|
+
value = args[0]
|
|
44
|
+
case value
|
|
45
|
+
when nil
|
|
46
|
+
append_null
|
|
47
|
+
when ::Array
|
|
48
|
+
super()
|
|
49
|
+
return if value.empty?
|
|
50
|
+
@value_builder ||= value_builder
|
|
51
|
+
@value_builder.append(*value)
|
|
52
|
+
else
|
|
53
|
+
message = "list value must be nil or Array: #{value.inspect}"
|
|
54
|
+
raise ArgumentError, message
|
|
55
|
+
end
|
|
56
|
+
else
|
|
57
|
+
message = "wrong number of arguments (given #{n_args}, expected 0..1)"
|
|
58
|
+
raise ArgumentError, message
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def append_values(lists, is_valids=nil)
|
|
63
|
+
if is_valids
|
|
64
|
+
is_valids.each_with_index do |is_valid, i|
|
|
65
|
+
if is_valid
|
|
66
|
+
append_value(lists[i])
|
|
67
|
+
else
|
|
68
|
+
append_null
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
else
|
|
72
|
+
lists.each do |list|
|
|
73
|
+
append_value(list)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @since 0.12.0
|
|
79
|
+
def append(*values)
|
|
80
|
+
if values.empty?
|
|
81
|
+
# For backward compatibility
|
|
82
|
+
append_value
|
|
83
|
+
else
|
|
84
|
+
super
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
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 Arrow
|
|
19
|
+
class MakeStructOptions
|
|
20
|
+
class << self
|
|
21
|
+
def try_convert(value)
|
|
22
|
+
case value
|
|
23
|
+
when Hash
|
|
24
|
+
options = new
|
|
25
|
+
field_names = value[:field_names] || []
|
|
26
|
+
field_nullability = value[:field_nullability] || []
|
|
27
|
+
field_metadata = value[:field_metadata] || []
|
|
28
|
+
field_names.zip(field_nullability, field_metadata) do |name, nullability, metadata|
|
|
29
|
+
options.add_field(name, nullability, metadata)
|
|
30
|
+
end
|
|
31
|
+
options
|
|
32
|
+
else
|
|
33
|
+
nil
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/arrow/version.rb
CHANGED
data/red-arrow.gemspec
CHANGED
|
@@ -33,13 +33,13 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
]
|
|
34
34
|
spec.version = version_components.compact.join(".")
|
|
35
35
|
spec.homepage = "https://arrow.apache.org/"
|
|
36
|
-
spec.authors = ["Apache
|
|
36
|
+
spec.authors = ["The Apache Software Foundation"]
|
|
37
37
|
spec.email = ["dev@arrow.apache.org"]
|
|
38
38
|
|
|
39
39
|
spec.summary = "Red Arrow is the Ruby bindings of Apache Arrow"
|
|
40
40
|
spec.description =
|
|
41
41
|
"Apache Arrow is a common in-memory columnar data store. " +
|
|
42
|
-
"It's useful to share and process large data."
|
|
42
|
+
"It's useful to share and process large data efficiently."
|
|
43
43
|
spec.license = "Apache-2.0"
|
|
44
44
|
spec.files = ["README.md", "Rakefile", "Gemfile", "#{spec.name}.gemspec"]
|
|
45
45
|
spec.files += ["LICENSE.txt", "NOTICE.txt"]
|
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: red-arrow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 23.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Apache
|
|
7
|
+
- The Apache Software Foundation
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
@@ -80,7 +80,7 @@ dependencies:
|
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
81
|
version: '0'
|
|
82
82
|
description: Apache Arrow is a common in-memory columnar data store. It's useful to
|
|
83
|
-
share and process large data.
|
|
83
|
+
share and process large data efficiently.
|
|
84
84
|
email:
|
|
85
85
|
- dev@arrow.apache.org
|
|
86
86
|
executables: []
|
|
@@ -122,6 +122,7 @@ files:
|
|
|
122
122
|
- lib/arrow/constructor-arguments-gc-guardable.rb
|
|
123
123
|
- lib/arrow/csv-loader.rb
|
|
124
124
|
- lib/arrow/csv-read-options.rb
|
|
125
|
+
- lib/arrow/csv-write-options.rb
|
|
125
126
|
- lib/arrow/data-type.rb
|
|
126
127
|
- lib/arrow/date32-array-builder.rb
|
|
127
128
|
- lib/arrow/date32-array.rb
|
|
@@ -142,6 +143,9 @@ files:
|
|
|
142
143
|
- lib/arrow/dense-union-data-type.rb
|
|
143
144
|
- lib/arrow/dictionary-array.rb
|
|
144
145
|
- lib/arrow/dictionary-data-type.rb
|
|
146
|
+
- lib/arrow/duration-array-builder.rb
|
|
147
|
+
- lib/arrow/duration-array.rb
|
|
148
|
+
- lib/arrow/duration-data-type.rb
|
|
145
149
|
- lib/arrow/equal-options.rb
|
|
146
150
|
- lib/arrow/expression.rb
|
|
147
151
|
- lib/arrow/field-containable.rb
|
|
@@ -150,6 +154,7 @@ files:
|
|
|
150
154
|
- lib/arrow/file-system.rb
|
|
151
155
|
- lib/arrow/fixed-size-binary-array-builder.rb
|
|
152
156
|
- lib/arrow/fixed-size-binary-array.rb
|
|
157
|
+
- lib/arrow/fixed-size-list-array-builder.rb
|
|
153
158
|
- lib/arrow/function.rb
|
|
154
159
|
- lib/arrow/generic-filterable.rb
|
|
155
160
|
- lib/arrow/generic-takeable.rb
|
|
@@ -177,10 +182,16 @@ files:
|
|
|
177
182
|
- lib/arrow/jruby/stream-listener-raw.rb
|
|
178
183
|
- lib/arrow/jruby/table.rb
|
|
179
184
|
- lib/arrow/jruby/writable.rb
|
|
185
|
+
- lib/arrow/large-list-array-builder.rb
|
|
186
|
+
- lib/arrow/large-list-data-type.rb
|
|
180
187
|
- lib/arrow/libraries.rb
|
|
181
188
|
- lib/arrow/list-array-builder.rb
|
|
182
189
|
- lib/arrow/list-data-type.rb
|
|
190
|
+
- lib/arrow/list-field-resolvable.rb
|
|
191
|
+
- lib/arrow/list-slice-options.rb
|
|
192
|
+
- lib/arrow/list-values-appendable.rb
|
|
183
193
|
- lib/arrow/loader.rb
|
|
194
|
+
- lib/arrow/make-struct-options.rb
|
|
184
195
|
- lib/arrow/map-array-builder.rb
|
|
185
196
|
- lib/arrow/map-array.rb
|
|
186
197
|
- lib/arrow/map-data-type.rb
|
|
@@ -246,7 +257,7 @@ homepage: https://arrow.apache.org/
|
|
|
246
257
|
licenses:
|
|
247
258
|
- Apache-2.0
|
|
248
259
|
metadata:
|
|
249
|
-
msys2_mingw_dependencies: arrow>=
|
|
260
|
+
msys2_mingw_dependencies: arrow>=23.0.0
|
|
250
261
|
rdoc_options: []
|
|
251
262
|
require_paths:
|
|
252
263
|
- lib
|
|
@@ -261,21 +272,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
261
272
|
- !ruby/object:Gem::Version
|
|
262
273
|
version: '0'
|
|
263
274
|
requirements:
|
|
264
|
-
- 'system: arrow-glib>=
|
|
265
|
-
- 'system: arrow-glib>=
|
|
266
|
-
- 'system: arrow-glib>=
|
|
267
|
-
- 'system: arrow-glib>=
|
|
268
|
-
- 'system: arrow-glib>=
|
|
269
|
-
- 'system: arrow-glib>=
|
|
270
|
-
- 'system: arrow-glib>=
|
|
271
|
-
- 'system: arrow-glib>=
|
|
272
|
-
- 'system: arrow-glib>=
|
|
273
|
-
- 'system: arrow-glib>=
|
|
274
|
-
- 'system: arrow-glib>=
|
|
275
|
-
- 'system: arrow-glib>=
|
|
276
|
-
- 'system: arrow-glib>=
|
|
277
|
-
- 'system: arrow-glib>=
|
|
278
|
-
rubygems_version:
|
|
275
|
+
- 'system: arrow-glib>=23.0.0: amazon_linux: arrow-glib-devel'
|
|
276
|
+
- 'system: arrow-glib>=23.0.0: amazon_linux: https://packages.apache.org/artifactory/arrow/amazon-linux/%{version}/apache-arrow-release-latest.rpm'
|
|
277
|
+
- 'system: arrow-glib>=23.0.0: amazon_linux: arrow-glib-devel'
|
|
278
|
+
- 'system: arrow-glib>=23.0.0: centos: arrow-glib-devel'
|
|
279
|
+
- 'system: arrow-glib>=23.0.0: centos: https://packages.apache.org/artifactory/arrow/centos/%{major_version}-stream/apache-arrow-release-latest.rpm'
|
|
280
|
+
- 'system: arrow-glib>=23.0.0: centos: arrow-glib-devel'
|
|
281
|
+
- 'system: arrow-glib>=23.0.0: conda: arrow-c-glib'
|
|
282
|
+
- 'system: arrow-glib>=23.0.0: debian: libarrow-glib-dev'
|
|
283
|
+
- 'system: arrow-glib>=23.0.0: debian: https://packages.apache.org/artifactory/arrow/%{distribution}/apache-arrow-apt-source-latest-%{code_name}.deb'
|
|
284
|
+
- 'system: arrow-glib>=23.0.0: debian: libarrow-glib-dev'
|
|
285
|
+
- 'system: arrow-glib>=23.0.0: fedora: libarrow-glib-devel'
|
|
286
|
+
- 'system: arrow-glib>=23.0.0: rhel: arrow-glib-devel'
|
|
287
|
+
- 'system: arrow-glib>=23.0.0: rhel: https://packages.apache.org/artifactory/arrow/almalinux/%{major_version}/apache-arrow-release-latest.rpm'
|
|
288
|
+
- 'system: arrow-glib>=23.0.0: rhel: arrow-glib-devel'
|
|
289
|
+
rubygems_version: 3.6.7
|
|
279
290
|
specification_version: 4
|
|
280
291
|
summary: Red Arrow is the Ruby bindings of Apache Arrow
|
|
281
292
|
test_files: []
|