@@ -187,16 +187,16 @@ like HDF5 (which can be used with memory-mapping).
187
187
"""
188
188
function mmap (io:: IO ,
189
189
:: Type{Array{T,N}} = Vector{UInt8},
190
- dims:: NTuple{N,Integer} = (div (filesize (io)- position (io),sizeof (T)),),
190
+ dims:: NTuple{N,Integer} = (div (filesize (io)- position (io),Base . aligned_sizeof (T)),),
191
191
offset:: Integer = position (io); grow:: Bool = true , shared:: Bool = true ) where {T,N}
192
192
# check inputs
193
193
isopen (io) || throw (ArgumentError (" $io must be open to mmap" ))
194
194
isbitstype (T) || throw (ArgumentError (" unable to mmap $T ; must satisfy isbitstype(T) == true" ))
195
195
196
- len = sizeof (T)
196
+ len = Base . aligned_sizeof (T)
197
197
for l in dims
198
198
len, overflow = Base. Checked. mul_with_overflow (promote (len, l)... )
199
- overflow && throw (ArgumentError (" requested size prod($((sizeof (T) , dims... )) ) too large, would overflow typeof(size(T)) == $(typeof (len)) " ))
199
+ overflow && throw (ArgumentError (" requested size prod($((len , dims... )) ) too large, would overflow typeof(size(T)) == $(typeof (len)) " ))
200
200
end
201
201
len >= 0 || throw (ArgumentError (" requested size must be ≥ 0, got $len " ))
202
202
len == 0 && return Array {T} (undef, ntuple (x-> 0 ,Val (N)))
267
267
268
268
mmap (file:: AbstractString ,
269
269
:: Type{T} = Vector{UInt8},
270
- dims:: NTuple{N,Integer} = (div (filesize (file),sizeof (eltype (T))),),
270
+ dims:: NTuple{N,Integer} = (div (filesize (file),Base . aligned_sizeof (eltype (T))),),
271
271
offset:: Integer = Int64 (0 ); grow:: Bool = true , shared:: Bool = true ) where {T<: Array ,N} =
272
272
open (io-> mmap (io, T, dims, offset; grow= grow, shared= shared), file, isfile (file) ? " r" : " w+" ):: Array{eltype(T),N}
273
273
0 commit comments