Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Commit

Permalink
fixed bug with fastby
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodaigh committed Jan 16, 2019
1 parent 4f0491b commit 040cd7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/fastby.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ end
Internal: single-function fastby, one by, one val
"""
function _fastby!(fn::Function, byvec::AbstractVector{T}, valvec::AbstractVector{S}) where {T <: Union{BaseRadixSortSafeTypes, Bool, String}, S}
l = length(byvec)
grouptwo!(byvec, valvec)
# l = length(byvec)
#grouptwo!(byvec, valvec)
SortingLab.sorttwo!(byvec, valvec)
#return _contiguousby(fn, byvec, valvec)
return _contiguousby_vec(fn, byvec, valvec)
end
Expand Down
6 changes: 3 additions & 3 deletions src/grouptwo.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Base: isbits, sizeof, similar
using SortingAlgorithms
import SortingAlgorithms: RADIX_SIZE, RADIX_MASK
import Base: getindex,setindex!, similar
import Base: getindex, setindex!, similar

function grouptwo!(vs::AbstractVector{T}, index) where {T <: BaseRadixSortSafeTypes}
l = length(vs)
Expand All @@ -11,7 +11,7 @@ function grouptwo!(vs::AbstractVector{T}, index) where {T <: BaseRadixSortSafeTy

# Init
# iters = ceil(Integer, sizeof(T)*8/RADIX_SIZE) # takes 2.954

bits_to_sort = sizeof(T)*8 - leading_zeros(T(reduce(|, vs)))
iters = ceil(Integer, bits_to_sort/RADIX_SIZE)

Expand Down Expand Up @@ -156,4 +156,4 @@ end
getindex(siv::ValIndexVector, inds::Integer) = siv.svec[inds], siv.index[inds]
getindex(siv::ValIndexVector, inds...) = ValIndexVector(siv.svec[inds...], siv.index[inds...])
similar(siv::ValIndexVector) = ValIndexVector(similar(siv.svec), similar(siv.index))
size(siv::ValIndexVector) = length(siv.svec)
size(siv::ValIndexVector) = length(siv.svec)

0 comments on commit 040cd7c

Please sign in to comment.