visad.data
Class FlatFieldCache

java.lang.Object
  extended by visad.data.FlatFieldCache

public class FlatFieldCache
extends Object

Memory cache for FlatFields. Maintains a fixed number of cache arrays in memory. When a cache member is requested which is not currently available in the cache it is loaded directly into one of the cache arrays. This prevents the allocation or garbage collection of data arrays when they are created. This allows caching to happen close to the data, rather than the rendering and is intended to allow for large animation loops with as little an affect as possible on rendering. This can however lead to large latency at startup due to reading data sources and copying them to the cache arrays.

Most of this class was modeled after the FileFlatField. This cache, however, is not a static cache, it is a instance cache. The affect of this is that if you create several large caches you can very quickly run out of memory.


Constructor Summary
FlatFieldCache(int cacheSize)
          Create a cache with a fixed size and the default strategy.
FlatFieldCache(int cacheSize, visad.data.FlatFieldCacheStrategy strategy)
          Initialize cache.
 
Method Summary
 void flushCache(visad.data.FlatFieldCache.Entry entry, FlatFieldCacheAccessor fileAccessor)
          Not currently implemented.
protected  float[][] getData(AreaImageCacheAdapter owner, FlatFieldCacheAccessor fileAccessor)
          Does the work of getting data from the cache.
 int getSize()
           
 void setDirty(AreaImageCacheAdapter owner, boolean dirty)
          Don't do this.
 String toString()
           
protected  void updateEntry(visad.data.FlatFieldCache.Entry entry, float[][] data, visad.data.FlatFieldCache.CacheOwner owner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlatFieldCache

public FlatFieldCache(int cacheSize)
Create a cache with a fixed size and the default strategy.

Parameters:
cacheSize -

FlatFieldCache

public FlatFieldCache(int cacheSize,
                      visad.data.FlatFieldCacheStrategy strategy)
Initialize cache.

Parameters:
cacheSize - Number of FlatFields to maintain in cache, >= 1.
strategy - How cache allocation is performed.
Method Detail

updateEntry

protected void updateEntry(visad.data.FlatFieldCache.Entry entry,
                           float[][] data,
                           visad.data.FlatFieldCache.CacheOwner owner)

getData

protected float[][] getData(AreaImageCacheAdapter owner,
                            FlatFieldCacheAccessor fileAccessor)
Does the work of getting data from the cache.

Parameters:
owner -
fileAccessor -
Returns:
cache data array

flushCache

public void flushCache(visad.data.FlatFieldCache.Entry entry,
                       FlatFieldCacheAccessor fileAccessor)
                throws VisADException
Not currently implemented.

Parameters:
entry -
fileAccessor -
Throws:
UnsupportedOperationException - All the time.
VisADException

setDirty

public void setDirty(AreaImageCacheAdapter owner,
                     boolean dirty)
Don't do this.

Parameters:
owner - The owner of the cache entry to mark as dirty.
dirty -

toString

public String toString()
Overrides:
toString in class Object

getSize

public int getSize()