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

Disallow mutable eltype in PooledArray #51

Closed
bkamins opened this issue Jan 31, 2021 · 3 comments · Fixed by #52
Closed

Disallow mutable eltype in PooledArray #51

bkamins opened this issue Jan 31, 2021 · 3 comments · Fixed by #52

Comments

@bkamins
Copy link
Member

bkamins commented Jan 31, 2021

I think we should disallow allowing mutable elements of PooledArray.

The reason of this proposal is the following problem:

julia> x = PooledArray([[1]])
1-element PooledArray{Array{Int64,1},UInt8,1,Array{UInt8,1}}:
 [1]

julia> push!(x[1], 2)
2-element Array{Int64,1}:
 1
 2

julia> x.invpool
Dict{Array{Int64,1},UInt8} with 1 entry:
  [1, 2] => 0x01

julia> x.invpool[[1,2]]
ERROR: KeyError: key [1, 2] not found

Alternatively we should change how invpool is handled if mutable objects are stored in PooledArray or explicitly warn that it is not allowed to mutate them.

@nalimilan
Copy link
Member

It would indeed be safer. As an alternative maybe we could use an ObjectIdDict for mutable objects, but that probably more work than it's worth.

@bkamins
Copy link
Member Author

bkamins commented Jan 31, 2021

Then, given we have tagged PooledArrays.jl as 1.0, maybe we just add a warning not to mutate the stored objects?

@quinnj
Copy link
Member

quinnj commented Jan 31, 2021

Hmmm, in Arrow.jl, you're allowed to dict-encode anything you want, but then again, everything is assumed immutable, so this isn't really an issue. On the one hand, no one has ever brought this up, so I wonder if people tend to not do this anyway, or just don't run into it. A warning might be fine, just as a way to see if anybody might be doing some mutating unintentionally. But I think we should keep allowing mutable eltypes for now.

bkamins added a commit that referenced this issue Jan 31, 2021
Fixes #51

@nalimilan - as usual - if you have comments on the language or in general how the docstring could be improved please let me know.
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 a pull request may close this issue.

3 participants