Skip to content

Commit

Permalink
make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Feb 2, 2024
1 parent 40d541f commit 2c4e584
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/cached.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ readblock!(A::CachedDiskArray, data, I::AbstractVector...) = _readblock_cached(A
haschunks(A::CachedDiskArray) = haschunks(parent(A))

Check warning on line 32 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L32

Added line #L32 was not covered by tests
eachchunk(A::CachedDiskArray) = eachchunk(parent(A))

function readblock!(A::CachedDiskArray{T,N}, data, I...) where {T,N}
chunks = eachchunk(A)
chunk_inds = findchunk.(chunks.chunks, I)

Check warning on line 37 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L35-L37

Added lines #L35 - L37 were not covered by tests

chunk_arrays = map(chunks[chunk_inds...]) do c
if haskey(A.cache, c)
A.cache[c]

Check warning on line 41 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L39-L41

Added lines #L39 - L41 were not covered by tests
else
chunk_data = Array{T,N}(undef, length.(I))
A.cache[c] = readblock!(A, chunk_data, I...)

Check warning on line 44 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L43-L44

Added lines #L43 - L44 were not covered by tests
end
end

out_chunks = ConcatDiskArray(chunk_arrays)
out_inds = map(i -> i .- first(i) + 1, I)

Check warning on line 49 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L48-L49

Added lines #L48 - L49 were not covered by tests

data .= view(out_chunks, out_inds...)

Check warning on line 51 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L51

Added line #L51 was not covered by tests

return data

Check warning on line 53 in src/cached.jl

View check run for this annotation

Codecov / codecov/patch

src/cached.jl#L53

Added line #L53 was not covered by tests
end

function _readblock_cached(A, data, I...)
if haskey(A.cache, I)
data .= A.cache[I]
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,5 +722,4 @@ end
@test sum(ca) == sum(ca)
# Read from the cache
@test ca[:, :] == ch
length(ca.cache)
end

0 comments on commit 2c4e584

Please sign in to comment.