edu.unh.sdb.datasource
Class ThreadedBlockCacheDataSource

java.lang.Object
  extended by edu.unh.sdb.datasource.DataCollection
      extended by edu.unh.sdb.datasource.DataSource
          extended by edu.unh.sdb.datasource.CacheDataSource
              extended by edu.unh.sdb.datasource.BlockCacheDataSource
                  extended by edu.unh.sdb.datasource.ThreadedBlockCacheDataSource
All Implemented Interfaces:
Indexable

public class ThreadedBlockCacheDataSource
extends BlockCacheDataSource

The ThreadedBlockCacheDataSource provides cache service for an underlying datasource. CacheDataSources are typically created by the CacheMaker class, which tunes the size of the cache blocks to a particular iteration and underlying datasource. As its name implies, the ThreadedBlockCacheDataSource uses an IO thread to read cache blocks from disk before they are actually needed by the user. To accomplish this, this class actually creates two cache blocks. One is being accessed by the user, and the other is being preloaded. This scheme is especially effective if the user is doing substantial computation, so that the IO thread has time to completely read its block before it is needed. The IO thread is triggered whenever the lower bounds of a user query crosses into a new cache block. When this happens, it is assumed that the user is done with the old block, so new data can be loaded into it. Notice that if a subblock query straddles two cache blocks, the I/O thread will not be triggered, because the lower bounds of the query block are still within the old block. When a query is received, it will be satisfied from the two cache blocks if possible. Otherwise, the query is satisfied directly from the datasource, and the cache blocks remain unchanged.


Field Summary
protected  AxisOrdering iteratorOrdering
           
 
Fields inherited from class edu.unh.sdb.datasource.DataSource
fdlDescriptor, isActivated, name, wsName
 
Fields inherited from class edu.unh.sdb.datasource.DataCollection
attributeOrder, axisOrdering, axisWeights, bounds, dataOrder, dimensionality, numAttributes, pointOrder, recordDesc
 
Constructor Summary
ThreadedBlockCacheDataSource(java.lang.String name, DataSource ds, IndexSpaceID blockDimensions, AxisOrdering iteratorOrdering)
          Create a ThreadedBlockCacheDataSource with a single CacheBlock connected to the DataSource argument.
ThreadedBlockCacheDataSource(java.lang.String name, DataSource ds, ISBounds iterationSpace, IndexSpaceID blockDimensions, AxisOrdering iteratorOrdering)
          Create a ThreadedBlockCacheDataSource with a single CacheBlock connected to the DataSource argument.
 
Method Summary
 void activate()
          Calls activate() for the underlying datasource, and creates the actual cache, which allocates memory for the CacheBlock.
 void deactivate()
          Calls super.deactivate() for the underlying datasource, and waits for any lingering IO threads to terminate.
protected  void halt()
          Any lingering IO threads will have terminated after this method completes.
static void main(java.lang.String[] args)
          For debugging.
 
Methods inherited from class edu.unh.sdb.datasource.BlockCacheDataSource
getCacheBlockBounds, getCacheBlockBounds, getCacheBlockBounds, getCacheBlockBoundsIterator, getCacheBlockBoundsIterator, getCacheBlockDimensions, getCacheMemoryUsage
 
Methods inherited from class edu.unh.sdb.datasource.CacheDataSource
datum, datum, datum, getIterationSpace, getSource, subblock, subblock
 
Methods inherited from class edu.unh.sdb.datasource.DataSource
checkActivated, clearCache, copyBestID, create, create, create, createRemote, createRemote, createRemoteClient, createRemoteClient, createRemoteDataSource, createRemoteDataSource, createRemoteDataSourceUDP, createRemoteUDP, createRemoteUDP, dumpData, equals, getName, getValues, isActivated, toString, toString
 
Methods inherited from class edu.unh.sdb.datasource.DataCollection
byteSize, computeOffset, computeOffset, copyBounds, createDataBlock, createDataBlock, createDataBlock, createDatum, createDatum, createDatum, createDatum, createDatum, createDatum, datum, datum, datum, datum, dim, getAxisOrdering, getAxisWeight, getAxisWeights, getBounds, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytesByAttribute, getBytesByAttribute, getBytesByPoint, getBytesByPoint, getDataOrder, getDimensionsArray, getDouble, getDoubles, getDoubles, getDoubles, getDoubles, getDoubles, getDoubles, getDoublesByAttribute, getDoublesByAttribute, getDoublesByPoint, getDoublesByPoint, getFloat, getFloats, getFloats, getFloats, getFloats, getFloats, getFloats, getFloatsByAttribute, getFloatsByAttribute, getFloatsByPoint, getFloatsByPoint, getInt, getInts, getInts, getInts, getInts, getInts, getInts, getIntsByAttribute, getIntsByAttribute, getIntsByPoint, getIntsByPoint, getLowerBoundsArray, getNumAttributes, getRecordDescriptor, getShort, getShorts, getShorts, getShorts, getShorts, getShorts, getShorts, getShortsByAttribute, getShortsByAttribute, getShortsByPoint, getShortsByPoint, getStorageType, getValues, getValuesByAttribute, getValuesByPoint, longVolume, setAxisOrdering, setBounds, setRecordDescriptor, size, subblock, subblock, subblock, subblock, subblock, subblock, subblock, subblock, subblock, subblock, useBytesOnly, volume
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iteratorOrdering

protected AxisOrdering iteratorOrdering
Constructor Detail

ThreadedBlockCacheDataSource

public ThreadedBlockCacheDataSource(java.lang.String name,
                                    DataSource ds,
                                    ISBounds iterationSpace,
                                    IndexSpaceID blockDimensions,
                                    AxisOrdering iteratorOrdering)
Create a ThreadedBlockCacheDataSource with a single CacheBlock connected to the DataSource argument. The CacheBlock dimensions are specified by the last argument. The memory for the cache itself is not allocated until this datasource is activated.


ThreadedBlockCacheDataSource

public ThreadedBlockCacheDataSource(java.lang.String name,
                                    DataSource ds,
                                    IndexSpaceID blockDimensions,
                                    AxisOrdering iteratorOrdering)
Create a ThreadedBlockCacheDataSource with a single CacheBlock connected to the DataSource argument. The CacheBlock dimensions are specified by the last argument. The memory for the cache itself is not allocated until this datasource is activated.

Method Detail

activate

public void activate()
Calls activate() for the underlying datasource, and creates the actual cache, which allocates memory for the CacheBlock.

Overrides:
activate in class BlockCacheDataSource

deactivate

public void deactivate()
Calls super.deactivate() for the underlying datasource, and waits for any lingering IO threads to terminate.

Overrides:
deactivate in class CacheDataSource

halt

protected void halt()
Any lingering IO threads will have terminated after this method completes.


main

public static void main(java.lang.String[] args)
For debugging. Runs basic tests on the ThreadedBlockCacheDataSource class.