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

change item in existing collection #124

Open
romainvieme opened this issue Nov 18, 2018 · 3 comments
Open

change item in existing collection #124

romainvieme opened this issue Nov 18, 2018 · 3 comments

Comments

@romainvieme
Copy link

Hi,
I am using JLD2 to save the results of scientific computations and I wonder if there is a way to modify an array inside a JLD file.
Here is an example of what I would like to do

using JLD2
myarray= [1 2 3]
@save "testfile.jld2" myarray
jldopen("testfile.jld2", "r+") do myfile
    myfile["myarray"][2]=4
end
jldopen("testfile.jld2", "r") do myfile
    myfile["myarray"]
end

and I would like to get [1 4 3] instead of the current [1 2 3].
I found that it is possible to make the change persist by opening the file with h5open but not with jldopen.
Is there a way to make such persistent changes in JLD2 ?

@JonasIsensee
Copy link
Collaborator

Currently that is not possible but it would surely be nice to have.

@JonasIsensee
Copy link
Collaborator

Out of place modification is possible by deleting a dataset and writing to it again

A list of what is needed for this:

For modifying arrays:

  • contiguous storage (the simplest case): allow mmap backed array
  • compact storage: mmap backed (?), need to update checksum after write / at file close
  • chunked storage: currently that means compression, so not possible to modify
  • Allowed datatypes ? Anything should in principle be fine, turns out of place, if it contains references.

For scalars:

  • Need notion of Dataset. JLD2 currently has no memory repr of a dataset. For manipulation, need Dataset struct that knows location in file, size and julia type. Need explicit, separate API for this kind of stuff. Likely try this is JLD2DebugTools. Constraint, need to keep julia type and everything the same
  • Dictionaries: Cannot append to them, modifying values possible in principle but likely not worth the effort.

@koehlerson
Copy link
Contributor

koehlerson commented May 19, 2021

@JonasIsensee how would I delete the dataset? I'm trying to do the same right now as the author of the issue

edit: nvm its just the dictionary interface with delete!

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

No branches or pull requests

3 participants