-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathdiskarray.jl
More file actions
60 lines (48 loc) · 1.77 KB
/
Copy pathdiskarray.jl
File metadata and controls
60 lines (48 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
AbstractDiskArray <: AbstractArray
Abstract DiskArray type that can be inherited by Array-like data structures that
have a significant random access overhead and whose access pattern follows
n-dimensional (hyper)-rectangles.
"""
abstract type AbstractDiskArray{T,N} <: AbstractArray{T,N} end
"""
isdisk(a::AbstractArray)
Return `true` if `a` is a `AbstractDiskArray` or follows
the DiskArrays.jl interface via macros. Otherwise `false`.
"""
isdisk(a::AbstractArray) = isdisk(typeof(a))
isdisk(::Type{<:AbstractArray}) = false
"""
readblock!(A::AbstractDiskArray, A_ret, r::AbstractUnitRange...)
The only function that should be implemented by a `AbstractDiskArray`. This function
"""
function readblock! end
function readblock!(a::AbstractArray, aout, r...)
# Fallback implementation for arrays that are not DiskArrays
if isdisk(a)
@warn "Using fallback readblock! for array $(typeof(a)). This should not happen but there should be a custom implementation."
end
aout .= view(a, CartesianIndices(r))
nothing
end
"""
writeblock!(A::AbstractDiskArray, A_in, r::AbstractUnitRange...)
Function that should be implemented by a `AbstractDiskArray` if write operations
should be supported as well.
"""
function writeblock! end
"""
eachchunk(a)
Returns an iterator with `CartesianIndices` elements that mark the index range of each chunk within an array.
"""
function eachchunk end
# Here we implement a fallback chunking for a DiskArray although this should normally
# be over-ridden by the package that implements the interface
eachchunk(a::AbstractArray) = estimate_chunksize(a)
"""
haschunks(a)
Returns a trait for the chunk pattern of a dis array,
[`Chunked`](@ref) or [`Unchunked`](@ref).
"""
function haschunks end
haschunks(x) = Unchunked()