NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Marius, > > CachedFlatFields: > That would be very nice :-) > > We've done a number of things with caching. We use the class: visad.data.DataCacheManager as a singleton to manage the cache. It can 1d and 2d arrays of all of the primitive types. The CachedFlatField just uses the DataCacheManager to store its range values. The DCM will hold the arrays in memory until a memory limit is exceeded then it writes the arrays out to disk and clears them from memory (least recently used strategy). The first thing you need to do is to set the directory to cache to, e.g., from the IDV: visad.data.DataCacheManager.getCacheManager().setCacheDir( new File(getDataCacheDirectory())); And set the memory threshold: visad.data.DataCacheManager.getCacheManager() .setMemoryPercent(dataContext.getIdv().getStateManager() .getPreferenceOrProperty(PROP_CACHE_PERCENT, 0.25)); Then just create the CachedFlatField like a regular FlatField. The IDV does some tricky things with delayed data reading. See, for example, ucar.visad.data.GeoGridFlatField to see how this is used. Using the CachedFlatField allows you to, for example, have lengthy time series of grids or images. If you do a lazy loading (like the IDV does) then you build up your FieldImpl of empty CachedFlatFields and pass it to the renderer. When a time step is rendered then the data is read. As the cache fills up the arrays are dumped to disk in case of subsequent accesses. Another way we use this is with the visad.data.CachedBufferedByteImage. This is a BufferedImage but plays tricks with the base class so the actual raster data is stored by the CacheManager. This is used by visad.java3d.VisADImageTile to render images. That way the image data in the scene graph is transparently cached though when animating and if your cached image is on disk it can take some time to load. To enable this the system property visad.java3d.imageByRef needs to be set to true. -Jeff
visad
archives: