Skip to content

Commit

Permalink
expand pool of pooled columns when needed by vcat
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Gustafsson committed Jun 8, 2016
1 parent fa09067 commit 6e83df9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/abstractdataframe/abstractdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ function _colinfo{T<:AbstractDataFrame}(dfs::Vector{T})
coltyps[idx] = promote_type(oldtyp, ct)
end
nonnull_ct[idx] += !_isnullable(col)
similars[idx] = expandsimilarpool(similars[idx], df[idx])
else # new column
push!(colindex, cn)
push!(coltyps, ct)
Expand All @@ -741,6 +742,20 @@ function _colinfo{T<:AbstractDataFrame}(dfs::Vector{T})
coltyps, colnams, similars
end

function expandsimilarpool{T,R<:Integer,N}(c1::PooledDataArray{T,R,N}, c2)
# expand pool to make room for all levels
pool = levels([levels(c1); levels(c2)])
# doesn't need any refs
norefs = DataArrays.RefArray(Array{DataArrays.DEFAULT_POOLED_REF_TYPE,N}())
# keep it compact (update the type of norefs)
compact(PooledDataArray(norefs, pool))
end

function expandsimilarpool(c1, c2)
c1
end


##############################################################################
##
## Hashing
Expand Down
4 changes: 4 additions & 0 deletions test/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ module TestGrouping
x = pool(collect(1:20))
df = DataFrame(v1=x, v2=x)
groupby(df, [:v1, :v2])

a = DataFrame(x=pool(1:200))
b = DataFrame(x=pool(100:300))
vcat(a,b)
end

0 comments on commit 6e83df9

Please sign in to comment.