Skip to content

Commit

Permalink
define unsafe_load! first
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Aug 4, 2023
1 parent b967753 commit 5ec49f2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ function checkbuffer(len,data)
end
end

@inline function unsafe_load!(ncvar::Variable, data, indices::Union{Integer, UnitRange, StepRange, Colon}...)
sizes = size(ncvar)
normalizedindices = normalizeindexes(sizes, indices)
ind = to_indices(ncvar,normalizedindices)

start,count,stride,jlshape = ncsub(ind)

@boundscheck begin
checkbounds(ncvar,indices...)
checkbuffer(prod(count),data)
end

nc_get_vars!(ncvar.ds.ncid,ncvar.varid,start,count,stride,data)
end

"""
NCDatasets.load!(ncvar::Variable, data, indices)
Expand Down Expand Up @@ -130,21 +145,6 @@ end
@inline unsafe_load!(ncvar, data, indices...)
end

@inline function unsafe_load!(ncvar::Variable, data, indices::Union{Integer, UnitRange, StepRange, Colon}...)
sizes = size(ncvar)
normalizedindices = normalizeindexes(sizes, indices)
ind = to_indices(ncvar,normalizedindices)

start,count,stride,jlshape = ncsub(ind)

@boundscheck begin
checkbounds(ncvar,indices...)
checkbuffer(prod(count),data)
end

nc_get_vars!(ncvar.ds.ncid,ncvar.varid,start,count,stride,data)
end

@inline function load!(ncvar::Variable{T,2}, data::AbstractArray{T}, i::Colon,j::UnitRange) where T
# reversed and 0-based
start = [first(j)-1,0]
Expand Down

0 comments on commit 5ec49f2

Please sign in to comment.