Skip to content

Custom storage for field arrays #175

@darsnack

Description

@darsnack

I am trying to figure out how to change what array backs a certain field of a StructArray. Here's a MWE to describe what I want:

julia> struct Foo{T}
         x::T
       end

julia> foos = StructArray(Foo(rand(100)) for _ in 1:10, _ in 1:20);

julia> typeof(foos.x)
Matrix{Vector{Float64}} (alias for Array{Array{Float64, 1}, 2})

Ideally, I would want to be able to specify that for any StructArray{Foo}, foos.x is a dense array. So, in the example, I would want a Array{Float64, 3} with the last dimension being the vector dimension. Assuming I have a special structure that makes a Array{T, 3} look like a Matrix{Vector{T}}, is it possible to tell StructArrays how to use this structure for foos.x?

I tried looking through the custom scheme docs, but it seemed like that was designed for a different purpose (rerouting getproperty?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions