Skip to content
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

Bump #309

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Bump #309

Changes from 1 commit
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
Next Next commit
Use appropriate interface
  • Loading branch information
JoaoAparicio committed Nov 24, 2023
commit db01a49de5e5a47417c170fb70617de3e120f0d4
3 changes: 2 additions & 1 deletion src/IndexedTables.jl
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@ using PooledArrays, SparseArrays, Statistics, WeakRefStrings

using OnlineStatsBase: OnlineStat, fit!

using StructArrays: StructVector, StructArray, fieldarrays,
import StructArrays
using StructArrays: StructVector, StructArray,
refine_perm!, collect_structarray,
append!!, replace_storage, GroupPerm,
roweq, index_type
18 changes: 9 additions & 9 deletions src/columns.jl
Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ available selection options and syntax.
"""
function columns end

columns(c::Columns) = fieldarrays(c)
columns(c::Columns{<:Tuple}) = Tuple(fieldarrays(c))
columns(c::Columns) = StructArrays.components(c)
columns(c::Columns{<:Tuple}) = Tuple(StructArrays.components(c))
columns(c::Columns{<:Pair}) = c.first => c.second

"""
@@ -75,7 +75,7 @@ summary(c::Columns{D}) where {D<:Tuple} = "$(length(c))-element Columns{$D}"
_sizehint!(c::Columns, n::Integer) = (foreach(x->_sizehint!(x,n), columns(c)); c)

function _strip_pair(c::Columns{<:Pair})
f, s = map(columns, fieldarrays(c))
f, s = map(columns, StructArrays.components(c))
(f isa AbstractVector) && (f = (f,))
(s isa AbstractVector) && (s = (s,))
Columns((f..., s...))
@@ -104,15 +104,15 @@ pushrow!(to::AbstractArray, from::AbstractArray, i) = push!(to, from[i])
@generated function row_asof(c::Columns{D,C}, i, d::Columns{D,C}, j) where {D,C}
N = length(C.parameters)
if N == 1
ex = :(!isless(getfield(fieldarrays(c),1)[i], getfield(fieldarrays(d),1)[j]))
ex = :(!isless(getfield(StructArrays.components(c),1)[i], getfield(StructArrays.components(d),1)[j]))
else
ex = :(isequal(getfield(fieldarrays(c),1)[i], getfield(fieldarrays(d),1)[j]))
ex = :(isequal(getfield(StructArrays.components(c),1)[i], getfield(StructArrays.components(d),1)[j]))
end
for n in 2:N
if N == n
ex = :(($ex) && !isless(getfield(fieldarrays(c),$n)[i], getfield(fieldarrays(d),$n)[j]))
ex = :(($ex) && !isless(getfield(StructArrays.components(c),$n)[i], getfield(StructArrays.components(d),$n)[j]))
else
ex = :(($ex) && isequal(getfield(fieldarrays(c),$n)[i], getfield(fieldarrays(d),$n)[j]))
ex = :(($ex) && isequal(getfield(StructArrays.components(c),$n)[i], getfield(StructArrays.components(d),$n)[j]))
end
end
ex
@@ -222,7 +222,7 @@ column(c, x) = columns(c)[colindex(c, x)]

# optimized method
@inline function column(c::Columns, x::Union{Int, Symbol})
getfield(fieldarrays(c), x)
getfield(StructArrays.components(c), x)
end

column(t, a::AbstractArray) = a
@@ -624,5 +624,5 @@ function init_inputs(f::Tup, input, isvec)
end

# utils
refs(v::Columns) = Columns(map(refs, fieldarrays(v)))
refs(v::Columns) = Columns(map(refs, StructArrays.components(v)))
compact_mem(v::Columns) = replace_storage(compact_mem, v)
10 changes: 5 additions & 5 deletions src/join.jl
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ function rowcmp(tc::Tuple, i, td::Tuple, j)
end

function rowcmp(c::Columns, i, d::Columns, j)
tc = Tuple(fieldarrays(c))
td = Tuple(fieldarrays(d))
tc = Tuple(StructArrays.components(c))
td = Tuple(StructArrays.components(d))
return rowcmp(tc, i, td, j)
end

@@ -79,7 +79,7 @@ nullrow(T, M) = missing_instance(M)
nullrowtype(::Type{T}, ::Type{S}) where {T<:Tup, S} = map_params(t -> type2missingtype(t, S), T)
nullrowtype(::Type{T}, ::Type{S}) where {T, S} = type2missingtype(T, S)

nullablerows(s::Columns{C}, ::Type{S}) where {C, S} = Columns{nullrowtype(C, S)}(fieldarrays(s))
nullablerows(s::Columns{C}, ::Type{S}) where {C, S} = Columns{nullrowtype(C, S)}(StructArrays.components(s))
nullablerows(s::AbstractVector, ::Type{S}) where {S} = vec_missing(s, S)

function init_left_right(ldata::AbstractVector{L}, rdata::AbstractVector{R}) where {L, R}
@@ -247,8 +247,8 @@ function Base.join(f, left::Dataset, right::Dataset;
rdata = replace_placeholder(right, rdata)

KT = map_params(promote_type, eltype(lkey), eltype(rkey))
lkey = Columns{KT}(Tuple(fieldarrays(lkey)))
rkey = Columns{KT}(Tuple(fieldarrays(rkey)))
lkey = Columns{KT}(Tuple(StructArrays.components(lkey)))
rkey = Columns{KT}(Tuple(StructArrays.components(rkey)))
join_iter = GroupJoinPerm(GroupPerm(lkey, lperm), GroupPerm(rkey, rperm))
init = !group && f === concat_tup ? init_left_right(ldata, rdata) : nothing
typ, grp = Val{how}(), Val{group}()
2 changes: 1 addition & 1 deletion src/ndsparse.jl
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ _convert(::Type{<:Tuple}, tup::Tuple) = tup
_convert(::Type{T}, tup::Tuple) where {T<:NamedTuple} = T(tup)
convertkey(t::NDSparse{V,K,I}, tup::Tuple) where {V,K,I} = _convert(eltype(I), tup)

ndims(t::NDSparse) = length(fieldarrays(t.index))
ndims(t::NDSparse) = length(StructArrays.components(t.index))
length(t::NDSparse) = (flush!(t);length(t.index))
eltype(::Type{NDSparse{T,D,C,V}}) where {T,D,C,V} = T
Base.keytype(::Type{NDSparse{T,D,C,V}}) where {T,D,C,V} = D
2 changes: 1 addition & 1 deletion src/selection.jl
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ missing_indxs(v::AbstractVector) = findall(!_ismissing, v)

function missing_indxs(t::StructArray)
indxs = collect(1:length(t))
for vec in getfield(t, :fieldarrays)
for vec in StructArrays.components(t)
filter!(i -> !_ismissing(vec[i]), indxs)
end
indxs