Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Views for Dataset and Attribute; VirtualSource #946

Open
mkitti opened this issue May 29, 2022 · 1 comment
Open

Views for Dataset and Attribute; VirtualSource #946

mkitti opened this issue May 29, 2022 · 1 comment
Labels

Comments

@mkitti
Copy link
Member

mkitti commented May 29, 2022

I previously proposed DatasetView and AttributeView in #937. I removed it in bc8fe33 .

The design was as follows:

struct DatasetView
    parent::Dataset
    indices
end

function Base.view(obj::Dataset, I...)
    return DatasetView(obj, I)
end

Base.similar(view::DatasetView) = similar(view.parent, length.(view.indices)...)

struct AttributeView
    parent::Attribute
    indices
end

function Base.view(obj::Attribute, I...)
    return AttributeView(obj, I)
end

Base.similar(view::AttributeView) = similar(view.parent, length.(view.indices)...)

const DatasetOrAttributeView = Union{DatasetView, AttributeView}

function Base.copyto!(output_buffer::AbstractArray{T}, view::DatasetOrAttributeView) where T
    return Base.read!(view.parent, output_buffer, view.indices...)
end

@simonbyrne suggested that we store the hyperslab in DatasetView.

If we move forward with #930, do we still need DatasetView since SubArray might be sufficient? Or do we still need a specialized DatasetView that is a combination of Dataset and Dataspace?

A DatasetView that is a combination of Dataset and Dataspace could also be reused as a VirtualSource replacing the implementation in HDF5Utils.jl, especially in combination with h5p_set_virtual.

This would be more capable than the h5py design for VirtualSource which does not allow for an arbitrary hyperslab selection for a Dataspace. For example, one may want a non-unit stride in one dimension as a virtual source.

@simonbyrne
Copy link
Collaborator

It's not possible to supply a Dataspace to an attribute in h5a_read, so it probably doesn't make sense to define views for attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants