org.das2.qds.ReferenceCache

Provide a cache of datasets that are in memory, so that the same data is not loaded twice. This first implementation uses WeakReferences, so that this cache need not be emptied, but we will avoid the situation where the same data is loaded twice.


getDataSet

getDataSet( String uri ) → QDataSet

Query to see if the dataset exists in the cache. Null is returned if it is not, or a QDataSet is returned if it is.

Parameters

uri - the URI that can be resolved into a dataset.

Returns:

the dataset or null

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getDataSetOrLock

getDataSetOrLock( String uri, ProgressMonitor monitor ) → ReferenceCacheEntry

Get a ReferenceCacheEntry for the URI, which will indicate the thread which has been designated as the load thread.


rcent= ReferenceCache.getInstance().getDataSetOrLock( this.tsb.getURI(), mon);
if ( !rcent.shouldILoad( Thread.currentThread() ) ) { 
   QDataSet result= rcent.park( mon );

Be sure to use try/finally when using this cache!

Parameters

uri - the URI to load.
monitor - to monitor the load.

Returns:

the ReferenceCacheEntry

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getInstance

getInstance( ) → ReferenceCache

get the single instance of the ReferenceCache

Returns:

an org.das2.qds.ReferenceCache

[search for examples] [view on GitHub] [view on old javadoc] [view source]


park

park( org.das2.qds.ReferenceCache.ReferenceCacheEntry ent, ProgressMonitor monitor ) → void

park this thread until the other guy has finished loading.

Parameters

ent - a ReferenceCache.ReferenceCacheEntry
monitor - the monitor of the load.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


printStatus

printStatus( ) → void

display the status of all the entries.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


putDataSet

putDataSet( String uri, QDataSet ds ) → void

put the dataset into the ReferenceCache. If it is mutable, then a copy is made.

Parameters

uri - a String
ds - a QDataSet

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


reset

reset( ) → void

explicitly remove entries from the cache.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


tidy

tidy( ) → void

remove all the entries that have been garbage collected.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]