Skip to content

Commit

Permalink
Fix type instabilities in _innerjoin!
Browse files Browse the repository at this point in the history
Innerjoin is 3x faster on simple test case
  • Loading branch information
andyferris committed Aug 4, 2020
1 parent 269f6d8 commit 95c56c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Andy Ferris <ferris.andy@gmail.com>"]
name = "SplitApplyCombine"
uuid = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
version = "1.1.1"
version = "1.1.2"

[deps]
Indexing = "313cdc1a-70c2-5d6a-ae34-0150d3930a38"
Expand Down
7 changes: 5 additions & 2 deletions src/innerjoin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,25 @@ function _innerjoin!(out, l::AbstractArray, r::AbstractArray, v::AbstractArray,
V = eltype(rkeys)
dict = Dict{eltype(r), Vector{V}}()
@inbounds for i_r rkeys
push!(get!(()->Vector{V}(), dict, r[i_r]), i_r)
push!(get!(Vector{V}, dict, r[i_r]), i_r)
end

@inbounds for i_l in keys(l)
l_value = l[i_l]
dict_index = Base.ht_keyindex(dict, l_value)
if dict_index > 0 # -1 if key not found
for i_r dict.vals[dict_index]
push!(out, v[Tuple(i_l)..., Tuple(i_r)...])
push!(out, v[_tuple(i_l)..., _tuple(i_r)...])
end
end
end

return out
end

_tuple(i::Integer) = (i,)
_tuple(i::Any) = Tuple(i)


# TODO more specialized methods for comparisons: ==, <, isless, etc - via sorting strategies

Expand Down

2 comments on commit 95c56c8

@andyferris
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/18942

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.2 -m "<description of version>" 95c56c8e006bf7dfbdd59b31641720bb68da7038
git push origin v1.1.2

Please sign in to comment.