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

Add warning about using mmaparrays keyword #176

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

m-wells
Copy link
Contributor

@m-wells m-wells commented Jan 30, 2020

The current behavior is to silently accept the keyword.

import HDF5, JLD, JLD2

function writetest(f::Function, g::Function; kwargs...)
    y = f("foo", "w"; kwargs...) do j
        x = ones(Int,2)
        j["x"] = x
        @show x
        x
    end

    f("foo", "r+"; kwargs...) do j
        x = g(j["x"])
        x[2] = 10 
        @show x[:]
    end

    f("foo", "r"; kwargs...) do j
        x = g(j["x"])
        @show x[:]
    
       if y == x
           println("did NOT update")
       else
           println("did update")
       end
   end
end

function mmaptest()
    println("HDF5")
    writetest(HDF5.h5open, HDF5.readmmap)
    println("JLD")
    writetest(JLD.jldopen, x -> x; mmaparrays=true)
    println("JLD2")
    writetest(JLD2.jldopen, x -> x; mmaparrays=true)
end

And the result

julia> mmaptest()
HDF5
x = [1, 1]
x[:] = [1, 10]
x[:] = [1, 10]
did update
JLD
x = [1, 1]
x[:] = [1, 10]
x[:] = [1, 10]
did update
JLD2
x = [1, 1]
x[:] = [1, 10]
x[:] = [1, 1]
did NOT update

@JonasIsensee JonasIsensee merged commit e4b823b into JuliaIO:master Jul 22, 2020
@JonasIsensee
Copy link
Collaborator

This seems quite reasonable.
Thank you!

@m-wells m-wells deleted the mmaparray_warn branch July 27, 2020 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants