From 00c64fe92056588545bd744c78869a1dc540286b Mon Sep 17 00:00:00 2001 From: lupemba Date: Wed, 25 Jun 2025 11:04:12 +0200 Subject: [PATCH] Replace getindex and setindex with DiskArray readblock! and writeblock!. --- Project.toml | 2 +- src/ZarrDatasets.jl | 6 +++--- src/variable.jl | 17 ++++++++++++++--- test/Project.toml | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 3860479..a8d0269 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99" [compat] -CommonDataModel = "0.3.5" +CommonDataModel = "0.4" DataStructures = "0.17, 0.18" DiskArrays = "0.3.22, 0.4" JSON = "0.21" diff --git a/src/ZarrDatasets.jl b/src/ZarrDatasets.jl index d13dd57..b56f443 100644 --- a/src/ZarrDatasets.jl +++ b/src/ZarrDatasets.jl @@ -2,8 +2,6 @@ module ZarrDatasets import Base: checkbounds, - getindex, - setindex!, size import CommonDataModel: @@ -28,7 +26,9 @@ import CommonDataModel: import DiskArrays: eachchunk, - haschunks + haschunks, + readblock!, + writeblock! import CommonDataModel as CDM using DataStructures diff --git a/src/variable.jl b/src/variable.jl index 09866ef..c0e8893 100644 --- a/src/variable.jl +++ b/src/variable.jl @@ -1,8 +1,19 @@ -Base.getindex(v::ZarrVariable,ij::Union{Integer,Colon,AbstractVector{<:Integer}}...) = parent(v)[ij...] -function Base.setindex!(v::ZarrVariable,data,ij::Union{Integer,Colon,AbstractVector{<:Integer}}...) - parent(v)[ij...] = data +function readblock!(v::ZarrVariable{T, N}, + aout, + indexes::Vararg{OrdinalRange, N}) where {T, N} + + return readblock!(parent(v), aout, indexes...) +end + + +function writeblock!(v::ZarrVariable{T,N}, + data, + indexes::Vararg{OrdinalRange, N}) where {T, N} + + return writeblock!(parent(v), data, indexes...) end + Base.size(v::ZarrVariable) = size(parent(v)) Base.parent(v::ZarrVariable) = v.zarray diff --git a/test/Project.toml b/test/Project.toml index a54600a..695a1c6 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -9,7 +9,7 @@ Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99" [compat] Aqua = "0.8" -CommonDataModel = "0.3.6" +CommonDataModel = "0.4" NCDatasets = "0.14" julia = "1" Zarr = "0.9.2"