@@ -17,29 +17,29 @@ ArrayInitializer() = ArrayInitializer(t -> false)
17
17
_reshape (v, itr, :: Base.HasShape ) = reshape (v, axes (itr))
18
18
_reshape (v, itr, :: Union{Base.HasLength, Base.SizeUnknown} ) = v
19
19
20
- function collect_columns (itr; initializer = default_initializer)
20
+ function collect_fieldarrays (itr; initializer = default_initializer)
21
21
sz = Base. IteratorSize (itr)
22
- v = collect_columns (itr, sz, initializer = initializer)
22
+ v = collect_fieldarrays (itr, sz, initializer = initializer)
23
23
_reshape (v, itr, sz)
24
24
end
25
25
26
- function collect_empty_columns (itr:: T ; initializer = default_initializer) where {T}
26
+ function collect_empty_fieldarrays (itr:: T ; initializer = default_initializer) where {T}
27
27
S = Core. Compiler. return_type (first, Tuple{T})
28
28
initializer (S, (0 ,))
29
29
end
30
30
31
- function collect_columns (@nospecialize (itr), :: Union{Base.HasShape, Base.HasLength} ;
31
+ function collect_fieldarrays (@nospecialize (itr), :: Union{Base.HasShape, Base.HasLength} ;
32
32
initializer = default_initializer)
33
33
34
34
st = iterate (itr)
35
- st === nothing && return collect_empty_columns (itr, initializer = initializer)
35
+ st === nothing && return collect_empty_fieldarrays (itr, initializer = initializer)
36
36
el, i = st
37
37
dest = initializer (typeof (el), (length (itr),))
38
38
dest[1 ] = el
39
- collect_to_columns ! (dest, itr, 2 , i)
39
+ collect_to_fieldarrays ! (dest, itr, 2 , i)
40
40
end
41
41
42
- function collect_to_columns ! (dest:: AbstractArray{T} , itr, offs, st) where {T}
42
+ function collect_to_fieldarrays ! (dest:: AbstractArray{T} , itr, offs, st) where {T}
43
43
# collect to dest array, checking the type of each result. if a result does not
44
44
# match, widen the result type and re-dispatch.
45
45
i = offs
@@ -51,24 +51,24 @@ function collect_to_columns!(dest::AbstractArray{T}, itr, offs, st) where {T}
51
51
@inbounds dest[i] = el
52
52
i += 1
53
53
else
54
- new = widencolumns (dest, i, el)
54
+ new = widenfieldarrays (dest, i, el)
55
55
@inbounds new[i] = el
56
- return collect_to_columns ! (new, itr, i+ 1 , st)
56
+ return collect_to_fieldarrays ! (new, itr, i+ 1 , st)
57
57
end
58
58
end
59
59
return dest
60
60
end
61
61
62
- function collect_columns (itr, :: Base.SizeUnknown ; initializer = default_initializer)
62
+ function collect_fieldarrays (itr, :: Base.SizeUnknown ; initializer = default_initializer)
63
63
elem = iterate (itr)
64
- elem === nothing && return collect_empty_columns (itr; initializer = initializer)
64
+ elem === nothing && return collect_empty_fieldarrays (itr; initializer = initializer)
65
65
el, st = elem
66
66
dest = initializer (typeof (el), (1 ,))
67
67
dest[1 ] = el
68
- grow_to_columns ! (dest, itr, iterate (itr, st))
68
+ grow_to_fieldarrays ! (dest, itr, iterate (itr, st))
69
69
end
70
70
71
- function grow_to_columns ! (dest:: AbstractArray{T} , itr, elem = iterate (itr)) where {T}
71
+ function grow_to_fieldarrays ! (dest:: AbstractArray{T} , itr, elem = iterate (itr)) where {T}
72
72
# collect to dest array, checking the type of each result. if a result does not
73
73
# match, widen the result type and re-dispatch.
74
74
i = length (dest)+ 1
@@ -79,9 +79,9 @@ function grow_to_columns!(dest::AbstractArray{T}, itr, elem = iterate(itr)) wher
79
79
elem = iterate (itr, st)
80
80
i += 1
81
81
else
82
- new = widencolumns (dest, i, el)
82
+ new = widenfieldarrays (dest, i, el)
83
83
push! (new, el)
84
- return grow_to_columns ! (new, itr, iterate (itr, st))
84
+ return grow_to_fieldarrays ! (new, itr, iterate (itr, st))
85
85
end
86
86
end
87
87
return dest
@@ -92,18 +92,18 @@ function to_structarray(::Type{T}, nt::C) where {T, C}
92
92
StructArray {S} (nt)
93
93
end
94
94
95
- function widencolumns (dest:: StructArray{T} , i, el:: S ) where {T, S}
95
+ function widenfieldarrays (dest:: StructArray{T} , i, el:: S ) where {T, S}
96
96
fs = fields (S)
97
97
if fs === fields (T)
98
- new_cols = (widencolumns ( columns (dest)[ind], i, getfieldindex (el, f, ind)) for (ind, f) in enumerate (fs))
98
+ new_cols = (widenfieldarrays ( fieldarrays (dest)[ind], i, getfieldindex (el, f, ind)) for (ind, f) in enumerate (fs))
99
99
nt = NamedTuple {fs} (Tuple (new_cols))
100
100
v = to_structarray (T, nt)
101
101
else
102
102
widenarray (dest, i, el)
103
103
end
104
104
end
105
105
106
- widencolumns (dest:: AbstractArray , i, el) = widenarray (dest, i, el)
106
+ widenfieldarrays (dest:: AbstractArray , i, el) = widenarray (dest, i, el)
107
107
108
108
function widenarray (dest:: AbstractArray{T} , i, el:: S ) where {S, T}
109
109
S <: T && return dest
0 commit comments