rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
271 stars 38 forks source link

Add an inner `StackLayers <: AbstractStackLayers` object #473

Open rafaqz opened 1 year ago

rafaqz commented 1 year ago

A few things have led me to this possible refactor. An inner wrapper for stack layers:

struct StackLayers{K,T<:Tuple,D<:Tuple,LD<:Union{Tuple,Nothing},LM<:Union{Tuple,Nothing}}
    data::T
    dims::D
    layerdims::LD
    layermetadata::LM
end

457 wants alternates storage mechanisms, and #471 is trying to fix performance of stacks.

Most performance problems are now in how the stack is rebuilt after map. The remaining fixes for that will involve simplifying the data, layerdims andf layermetadata fields.

This could all be handled in a StackLayers object. Meaning it could also be used inside other wrappers like RasterStack with very little work, protecting packages that extend AbstractDimStack from dealing with these internals and performance considerations.

Other benefits are:

mutable struct MStackLayers
    keys::Vector{Symbol}
    data::Vector{<:AbstractArray}
    dims::Tuple
    layerdims::Vector
    layermetadata::Vector
end

@sethaxen any thoughts on this?