Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GroupedArrays"
uuid = "6407cd72-fade-4a84-8a1e-56e431fc1533"
authors = ["matthieugomez <gomez.matthieu@gmail.com>"]
version = "0.3.5"
version = "0.3.6"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Expand Down
19 changes: 12 additions & 7 deletions src/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ function _spawn_for_chunks_helper(iter, lbody, basesize)
nt = Threads.nthreads()
len = length(x)
if nt > 1 && len > basesize
tasks = [@spawn begin
for i in p
local $(esc(lidx)) = @inbounds x[i]
$(esc(lbody))
end
end
for p in split_indices(len, basesize)]
# a loop rather than a comprehension: collecting the generator compiles
# abstractly typed Base code that packages adding array methods
# (e.g. CategoricalArrays) invalidate
tasks = Task[]
for p in split_indices(len, basesize)
push!(tasks, @spawn begin
for i in p
local $(esc(lidx)) = @inbounds x[i]
$(esc(lbody))
end
end)
end
foreach(wait, tasks)
else
for i in eachindex(x)
Expand Down
11 changes: 10 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,16 @@ function row_group_slots!(cols::NTuple{N, AbstractVector},
newcols, refpools, refarrays, hash, groups, skipmissing, sort, compress)
end

strides = (cumprod(collect(reverse(ngroupstup)))[end-1:-1:1]..., 1)::NTuple{N, Int}
# strides[i] is the product of ngroupstup[i+1:N]. Computed with a loop rather than
# cumprod(collect(reverse(ngroupstup))), which compiles abstractly typed Base code
# that packages adding array methods (e.g. CategoricalArrays) invalidate
strides = ntuple(Val(N)) do i
stride = 1
for j in (i + 1):N
stride *= ngroupstup[j]::Int
end
stride
end
firstinds = map(firstindex, refpools)
if sort
nminds = map(refpools, missinginds) do refpool, missingind
Expand Down
Loading