red-arrow-format 25.0.0 → 26.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/Rakefile +3 -1
- data/lib/arrow-format/array-builder.rb +140 -0
- data/lib/arrow-format/array.rb +541 -22
- data/lib/arrow-format/bitmap-builder.rb +89 -0
- data/lib/arrow-format/bitmap.rb +26 -5
- data/lib/arrow-format/error.rb +1 -0
- data/lib/arrow-format/field.rb +3 -1
- data/lib/arrow-format/record-batch.rb +167 -6
- data/lib/arrow-format/record.rb +60 -0
- data/lib/arrow-format/schema.rb +25 -0
- data/lib/arrow-format/type.rb +284 -89
- data/lib/arrow-format/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a59d8373c7b6c127b088d1445d2ead7a7a47eb31d775a2fc015a269d28d60c1f
|
|
4
|
+
data.tar.gz: 353eabcf9bfdc8224b3668c97eed985190b09e489a70ec20f02ce8ef2945c69a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67b833d6630a7f411569a5a5cb62e21e6e6a570da7e99d7ec53ff780c20c84334ba5e93363e13edc38b17d405fe23123ef0608de4cbc4c18c7402461ebb6ad95
|
|
7
|
+
data.tar.gz: de2b184bcb715512acaf66ed6a5ce08d198cdcb8c923cef08a0de317d104dd1d7b5962b264f804a07fe071f18952787c38a3201c32ef8dd52ed59dcff96ca26a
|
data/Rakefile
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
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 ArrowFormat
|
|
19
|
+
class ArrayBuilder
|
|
20
|
+
def initialize(values)
|
|
21
|
+
@values = values
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def build
|
|
25
|
+
target = nil
|
|
26
|
+
@values.each do |value|
|
|
27
|
+
target = detect_target(value, target)
|
|
28
|
+
break if target and target[:detected]
|
|
29
|
+
end
|
|
30
|
+
if target
|
|
31
|
+
array_class = target[:array_class]
|
|
32
|
+
array_class ||= finalize_array_class(target)
|
|
33
|
+
type = target[:type]
|
|
34
|
+
if type
|
|
35
|
+
array_class.new(type, @values)
|
|
36
|
+
else
|
|
37
|
+
array_class.new(@values)
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
UTF8Array.new(@values)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
def detect_target(value, target)
|
|
46
|
+
case value
|
|
47
|
+
when nil
|
|
48
|
+
target
|
|
49
|
+
when true, false
|
|
50
|
+
{
|
|
51
|
+
array_class: BooleanArray,
|
|
52
|
+
detected: true,
|
|
53
|
+
}
|
|
54
|
+
when String
|
|
55
|
+
{
|
|
56
|
+
array_class: UTF8Array,
|
|
57
|
+
detected: true,
|
|
58
|
+
}
|
|
59
|
+
when Float
|
|
60
|
+
{
|
|
61
|
+
array_class: Float64Array,
|
|
62
|
+
detected: true,
|
|
63
|
+
}
|
|
64
|
+
when Integer
|
|
65
|
+
target ||= {}
|
|
66
|
+
min = target[:min] || value
|
|
67
|
+
max = target[:max] || value
|
|
68
|
+
min = value if value < min
|
|
69
|
+
max = value if value > max
|
|
70
|
+
|
|
71
|
+
if target[:value_type] == :int or value < 0
|
|
72
|
+
{
|
|
73
|
+
value_type: :int,
|
|
74
|
+
min: min,
|
|
75
|
+
max: max,
|
|
76
|
+
}
|
|
77
|
+
else
|
|
78
|
+
{
|
|
79
|
+
value_type: :uint,
|
|
80
|
+
min: min,
|
|
81
|
+
max: max,
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
when Time
|
|
85
|
+
{
|
|
86
|
+
array_class: TimestampArray,
|
|
87
|
+
type: TimestampType.new(:nanosecond),
|
|
88
|
+
detected: true,
|
|
89
|
+
}
|
|
90
|
+
when Date
|
|
91
|
+
{
|
|
92
|
+
array_class: Date32Array,
|
|
93
|
+
detected: true,
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
{
|
|
97
|
+
array_class: UTF8Array,
|
|
98
|
+
detected: true,
|
|
99
|
+
}
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def finalize_array_class(target)
|
|
104
|
+
value_type = target[:value_type]
|
|
105
|
+
case value_type
|
|
106
|
+
when :int
|
|
107
|
+
min = target[:min]
|
|
108
|
+
max = target[:max]
|
|
109
|
+
|
|
110
|
+
if Int8Type::MIN_VALUE <= min and max <= Int8Type::MAX_VALUE
|
|
111
|
+
Int8Array
|
|
112
|
+
elsif Int16Type::MIN_VALUE <= min and max <= Int16Type::MAX_VALUE
|
|
113
|
+
Int16Array
|
|
114
|
+
elsif Int32Type::MIN_VALUE <= min and max <= Int32Type::MAX_VALUE
|
|
115
|
+
Int32Array
|
|
116
|
+
elsif Int64Type::MIN_VALUE <= min and max <= Int64Type::MAX_VALUE
|
|
117
|
+
Int64Array
|
|
118
|
+
else
|
|
119
|
+
UTF8Array
|
|
120
|
+
end
|
|
121
|
+
when :uint
|
|
122
|
+
max = target[:max]
|
|
123
|
+
|
|
124
|
+
if max <= UInt8Type::MAX_VALUE
|
|
125
|
+
UInt8Array
|
|
126
|
+
elsif max <= UInt16Type::MAX_VALUE
|
|
127
|
+
UInt16Array
|
|
128
|
+
elsif max <= UInt32Type::MAX_VALUE
|
|
129
|
+
UInt32Array
|
|
130
|
+
elsif max <= UInt64Type::MAX_VALUE
|
|
131
|
+
UInt64Array
|
|
132
|
+
else
|
|
133
|
+
UTF8Array
|
|
134
|
+
end
|
|
135
|
+
else
|
|
136
|
+
UTF8Array
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|