-
Notifications
You must be signed in to change notification settings - Fork 360
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
RFC: Added ref type parameter, compact
to PooledDataFrame
#227
Conversation
WIP because the additional parameterization of the default constructor has a severe conflict with construction from an array + pool (https://github.com/kmsquire/DataFrames.jl/pull/new/pooled_ref_parameterization#L6R120): julia> import DataFrames
Warning: New definition
PooledDataArray(Array{T,N},Array{T,1}) at /home/kmsquire/.julia/DataFrames/src/pooleddataarray.jl:120
is ambiguous with
PooledDataArray(Array{R<:Integer,N},Array{T,1}) at /home/kmsquire/.julia/DataFrames/src/pooleddataarray.jl:50.
Make sure
PooledDataArray(Array{T,N},Array{T,1})
is defined first. The parameterizations are slightly different, but not different enough, and moving things around doesn't help in this case. One of the function signatures really just needs to change. Some options
type DefaultPooledConstructor end
function PooledDataArray{T,R<:Integer,N}(refs::Array{R, N},
pool::Vector{T},
::Type{DefaultPooledConstructor})
PooledDataArray{T,R,N}(refs, pool)
end There may be other options. |
Just realize that I included #226 in this. That change is distinct from this one, and actually still needed even if these changes are accepted. I can remove it from here. |
More info/thoughts:
|
I prefer #2 out of the choices above.
|
I haven't actually tried it yet, but thinking a little more, I'm not sure choice 2 is going to work--it still might end up being ambiguous. But I'll try it and see. |
Yeah, that didn't work--still ambiguous. Do either of the other options look reasonable, or does anyone have any other suggestions? |
Okay, I think I came up with a reasonable solution. The problem is that we need to distinguish between normal arrays being converted to To do this, I added This latest version also adds a type parameter as an optional argument to all |
Removed #226 from this pull. I can squash the commits to clean things up, if that's preferable. Let me know. |
* Allows the user to specify the reference type for PooledDataArrays (default is still Uint16) * Added `compact` to take an existing PooledDataArray and change the reference type to the smallest size possible. Returns the same PooledDataArray if nothing has changed, and a new one if the size is reduced * Added RefType to distinguish refs arrays from normal arrays during PooledDataArray construction
Squashed and rebased. |
Kevin, in a brief look at the code and approach, it looks good to me.
|
Thanks for the feedback, Tom. I'll look at |
This is idential to the |
PooledDataArrays
(default is still
Uint16
)compact
to take an existingPooledDataArray
and change thereference type to the smallest size possible. Returns the same
PooledDataArray
if nothing has changed, and a new one if the sizeis reduced
The current
PooledDataArray
tests pass.Edit: example (from #241 (comment))