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

Make AccessCountDiskArray <: AbstractDiskArray + fix zip bug #193

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
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
33 changes: 21 additions & 12 deletions src/DiskArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,28 @@ macro implement_diskarray(t)
end
end

# https://github.com/meggart/DiskArrays.jl/issues/175
macro implement_diskarray_skip_zip(t)
# Need to do this for dispatch ambiguity
t = esc(t)
quote
@implement_getindex $t
@implement_setindex $t
@implement_broadcast $t
@implement_iteration $t
@implement_mapreduce $t
@implement_reshape $t
@implement_array_methods $t
@implement_permutedims $t
@implement_subarray $t
@implement_cat $t
@implement_show $t
@implement_generator $t
end
end

# We need to skip the `implement_zip` macro for dispatch
@implement_getindex AbstractDiskArray
@implement_setindex AbstractDiskArray
@implement_broadcast AbstractDiskArray
@implement_iteration AbstractDiskArray
@implement_mapreduce AbstractDiskArray
@implement_reshape AbstractDiskArray
@implement_array_methods AbstractDiskArray
@implement_permutedims AbstractDiskArray
@implement_subarray AbstractDiskArray
@implement_cat AbstractDiskArray
@implement_generator AbstractDiskArray
@implement_show AbstractDiskArray
@implement_diskarray_skip_zip AbstractDiskArray

#And we define the test types
include("util/testtypes.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/util/testtypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and optimise chunk access.
`getindex_count(A)` and `setindex_count(A)` can be used to check the
the counters.
"""
struct AccessCountDiskArray{T,N,A<:AbstractArray{T,N},RS} <: AbstractArray{T,N}
struct AccessCountDiskArray{T,N,A<:AbstractArray{T,N},RS} <: DiskArrays.AbstractDiskArray{T,N}
getindex_log::Vector{Any}
setindex_log::Vector{Any}
parent::A
Expand All @@ -28,7 +28,7 @@ AccessCountDiskArray(a; chunksize=size(a),batchstrategy=DiskArrays.ChunkRead(Dis
Base.size(a::AccessCountDiskArray) = size(a.parent)

# Apply the all in one macro rather than inheriting
DiskArrays.@implement_diskarray AccessCountDiskArray
DiskArrays.@implement_diskarray_skip_zip AccessCountDiskArray
charleskawczynski marked this conversation as resolved.
Show resolved Hide resolved

DiskArrays.haschunks(::AccessCountDiskArray) = DiskArrays.Chunked()
DiskArrays.eachchunk(a::AccessCountDiskArray) = DiskArrays.GridChunks(a, a.chunksize)
Expand Down
Loading