Skip to content

Commit

Permalink
forward DiskArrays.cache
Browse files Browse the repository at this point in the history
  • Loading branch information
meggart committed Jul 25, 2024
1 parent 8307db1 commit 621ecc6
Showing 3 changed files with 155 additions and 131 deletions.
3 changes: 2 additions & 1 deletion src/Cubes/Cubes.jl
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ The functions provided by YAXArrays are supposed to work on different types of c
Data types that
"""
module Cubes
using DiskArrays: DiskArrays, eachchunk, approx_chunksize, max_chunksize, grid_offset, GridChunks
using DiskArrays: DiskArrays, eachchunk, approx_chunksize, max_chunksize, grid_offset, GridChunks, cache
using Distributed: myid
using Dates: TimeType, Date
using IntervalSets: Interval, (..)
@@ -179,6 +179,7 @@ function Base.permutedims(c::YAXArray, p)
newchunks = DiskArrays.GridChunks(eachchunk(c).chunks[collect(dimnums)])
YAXArray(newdims, newdata, c.properties, newchunks, c.cleaner)
end
DiskArrays.cache(a::YAXArray;maxsize=1000) = DD.rebuild(a,cache(a.data;maxsize))

# DimensionalData overloads

9 changes: 9 additions & 0 deletions src/DatasetAPI/Datasets.jl
Original file line number Diff line number Diff line change
@@ -145,6 +145,15 @@ function Base.getindex(x::Dataset, i::Vector{Symbol})
cubesnew = [j => x.cubes[j] for j in i]
Dataset(; cubesnew...)
end
function DiskArrays.cache(ds::Dataset;maxsize=1000)
#Distribute cache size equally across cubes
maxsize = maxsize ÷ length(ds.cubes)
cachedcubes = OrderedDict{Symbol,YAXArray}(
k => DiskArrays.cache(ds.cubes[k];maxsize) for k in keys(ds.cubes)
)
Dataset(cachedcubes,ds.axes,ds.properties)
end


function fuzzyfind(s::String, comp::Vector{String})
sl = lowercase(s)
Loading

0 comments on commit 621ecc6

Please sign in to comment.