Package uk.ac.starlink.ttools.plot2.data
Class CachedDataStoreFactory
java.lang.Object
uk.ac.starlink.ttools.plot2.data.CachedDataStoreFactory
- All Implemented Interfaces:
DataStoreFactory
DataStoreFactory implementation that reads columns and caches them
for later use.
The actual storage mechanism is provided by an externally supplied
CachedColumnFactory
.- Since:
- 11 Feb 2013
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCachedDataStoreFactory
(CachedColumnFactory colFact, TupleRunner tupleRunner) Constructs a default instance.protected
CachedDataStoreFactory
(CachedColumnFactory colFact, TupleRunner tupleRunner, uk.ac.starlink.table.RowRunner rowRunner) Constructs an instance with control over read paralellism. -
Method Summary
Modifier and TypeMethodDescriptionreadDataStore
(DataSpec[] dataSpecs, DataStore prevStore) Generates a DataStore capable of supplying the data for a given list of DataSpec objects.
-
Constructor Details
-
CachedDataStoreFactory
Constructs a default instance. This currently does not do cache reading in parallel.- Parameters:
colFact
- object which provides the storage for caching arrays of typed datatupleRunner
- tuple runner dispensed with DataStores
-
CachedDataStoreFactory
protected CachedDataStoreFactory(CachedColumnFactory colFact, TupleRunner tupleRunner, uk.ac.starlink.table.RowRunner rowRunner) Constructs an instance with control over read paralellism.Note the parallel cache population is a bit experimental. The reading is faster, but the contents are not guaranteed to be in the right order (most likely that doesn't matter for large datasets) and the resulting cached data can be a bit (20%?) slower to use.
- Parameters:
colFact
- object which provides the storage for caching arrays of typed datatupleRunner
- tuple runner dispensed with DataStoresrowRunner
- null for sequential cache population, non-null for potentially parallel
-
-
Method Details
-
readDataStore
public DataStore readDataStore(DataSpec[] dataSpecs, DataStore prevStore) throws IOException, InterruptedException Description copied from interface:DataStoreFactory
Generates a DataStore capable of supplying the data for a given list of DataSpec objects. TheprevStore
argument may optionally supply the result of a previous invocation of this method. The implementation may choose to make use of the internal state of such an instance for efficiency, for instance by re-using data that has already been read.Since the bulk data is managed by the DataStore object, care should be taken about what happens to the DataStore objects supplied to and returned from this method. In particular, code both invoking and implementing this method should usually make sure not to keep a reference to the
prevStore
argument.This method may perform the actual reading, and therefore take time. It is not intended to be invoked on the event dispatch thread.
- Specified by:
readDataStore
in interfaceDataStoreFactory
- Parameters:
dataSpecs
- data specifications; some elements may be nullprevStore
- previously obtained DataStore, or null- Returns:
- new data store
- Throws:
IOException
InterruptedException
-