@@ -4,7 +4,8 @@ export SerializedArray, disk, memory
44
55using Base. PermutedDimsArrays: genperm
66using ConstructionBase: constructorof
7- using DiskArrays: DiskArrays, AbstractDiskArray, Unchunked, readblock!, writeblock!
7+ using DiskArrays:
8+ DiskArrays, AbstractDiskArray, PermutedDiskArray, Unchunked, readblock!, writeblock!
89using Serialization: deserialize, serialize
910
1011adapt_serialized (to, x) = adapt_structure_serialized (to, x)
@@ -159,26 +160,31 @@ end
159160# PermutedSerializedArray
160161#
161162
162- struct PermutedSerializedArray{T,N,P<: PermutedDimsArray {T,N} } < :
163+ struct PermutedSerializedArray{T,N,perm,iperm, P<: AbstractArray {T,N} } < :
163164 AbstractSerializedArray{T,N}
164- permuted_parent :: P
165+ parent :: P
165166end
166- Base. parent (a:: PermutedSerializedArray ) = parent ( getfield (a, :permuted_parent ) )
167+ Base. parent (a:: PermutedSerializedArray ) = getfield (a, :parent )
167168
168169file (a:: PermutedSerializedArray ) = file (parent (a))
169170
170- perm (a:: PermutedSerializedArray ) = perm (a. permuted_parent)
171- perm (:: PermutedDimsArray{<:Any,<:Any,p} ) where {p} = p
172-
173- iperm (a:: PermutedSerializedArray ) = iperm (a. permuted_parent)
174- iperm (:: PermutedDimsArray{<:Any,<:Any,<:Any,ip} ) where {ip} = ip
171+ # TODO : Use `TypeParameterAccessors.jl`.
172+ perm (a:: PermutedDimsArray{<:Any,<:Any,p} ) where {p} = p
173+ perm (a:: PermutedDiskArray{<:Any,<:Any,p} ) where {p} = p
174+ perm (a:: PermutedSerializedArray{<:Any,<:Any,p} ) where {p} = p
175+ # TODO : Use `TypeParameterAccessors.jl`.
176+ iperm (a:: PermutedDimsArray{<:Any,<:Any,<:Any,ip} ) where {ip} = ip
177+ iperm (a:: PermutedDiskArray{<:Any,<:Any,ip} ) where {ip} = ip
178+ iperm (a:: PermutedSerializedArray{<:Any,<:Any,<:Any,ip} ) where {ip} = ip
175179
176180Base. axes (a:: PermutedSerializedArray ) = genperm (axes (parent (a)), perm (a))
177- Base. size (a:: PermutedSerializedArray ) = length .( axes (a))
181+ Base. size (a:: PermutedSerializedArray ) = map (length, axes (a))
178182
179- function PermutedSerializedArray (a:: AbstractArray , perm)
180- a′ = PermutedDimsArray (a, perm)
181- return PermutedSerializedArray {eltype(a),ndims(a),typeof(a′)} (a′)
183+ function PermutedSerializedArray (a:: AbstractArray , p)
184+ # This returns a `PermutedDiskArray` as of:
185+ # https://github.com/JuliaIO/DiskArrays.jl/pull/249
186+ a′ = PermutedDimsArray (a, p)
187+ return PermutedSerializedArray {eltype(a),ndims(a),perm(a′),iperm(a′),typeof(a)} (a)
182188end
183189
184190function Base. permutedims (a:: AbstractSerializedArray , perm)
0 commit comments