Reading data from HDF5 file to StaticArray

A matrix of size (3, 44843) is much too large for StaticArrays. The StaticArrays README says:

Note that in the current implementation, working with large StaticArray s puts a lot of stress on the compiler, and becomes slower than Base.Array as the size increases. A very rough rule of thumb is that you should consider using a normal Array for arrays larger than 100 elements.

I’m not sure what query is supposed to represent, but if it is a collection of x,y,z points, or something else along the columns that you want to use together, you could consider using a Vector of SVector:

julia> using StaticArrays

julia> query = rand(3, 44843)
3×44843 Matrix{Float64}:
 0.62791    0.376845  0.0319929  …  0.254759  0.748335
 0.392331   0.469574  0.622981      0.154285  0.673124
 0.0994297  0.132254  0.791781      0.251181  0.802184

julia> [SVector{3,Float64}(col) for col in eachcol(query)]
44843-element Vector{SVector{3, Float64}}:
 [0.6279103058302006, 0.3923314542013667, 0.09942971962927671]
 [0.3768454590435031, 0.469573741906429, 0.13225405391447298]
⋮
1 Like