edu.unh.sdb.datasource
Class MRDataSource

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

public class MRDataSource
extends DataSource

MRDataSource Serves as an interface to a MultiResolution hierarchy of DataSources representing the same data at different resolution levels. This implementation is a primitive one that uses file name and file directory structure conventions to define the hierarchy, rather than using complete metadata support for defining the hierarchy (as well as associated error datasources). For this version we'll encode the MR nature of the data in the xfdl file by prefixing the file name with with the "@" symbol. This will tell DataSource.create( ... ) that it should create an MRDataSource. FDL fileName format: @rootdir/level0DataFileName It is acceptable for the "rootdir" field to be '.'; it is acceptable for the "level0DataFileName" to be omitted; default is "data". The filename (with the "@" removed) from the .xfdl file should be the name of the root directory of the hierarchcy. This directory must have an entry named "data". root/data can be a plain file or it can be a directory that contains the data file. (This is especially intended for time series data sets that have many files, but could also be used for storing multiple attributes in separate files -- though there is no support for this yet.) If there is an error datasource associated with the data it should be in the file "error", or in a file (or series of files) in the directory called "error". Any lower resolution representations of this data must be stored in other directories. With time series data, there could be either a spatial wavelet or a time wavelet; eventually we want to support adaptive resolution representations for which there could be multiple versions for this data at different error tolerance levels. For the time being, this code supports the following conventions for the lower resolution data: 1. If there is just one subdirectory (other than "data" and "error"), we assume that it is the next lower resolution. 2. If the directory name begins with "space" or is "s", then it is a spatial wavelet directory (intended to be used for time series). 3. If the file name begins with "time" or is "t", then it is a time wavelet directory for a time series data source. Each lower resolution subdirectory must follow the same conventions as the root directory; i.e., it must contain a file or a directory named "data" and may contain a file or directory named "error" and a may contain a directory defining the next lower resolution of data. Each level of resolution must have its own xfdl file. It can be at the same level as the data/error file or directories or it can be in the data and error directories. One goal of this initial implementation is to allow a single .xfdl file to be used for an entire hierarchy. This may prove to be of marginal importance since new .xfdl files could be automatically generated by the wavelet program.

Author:
rdb ------------------ Edit history ------------------------------------ 11/29/05 rdb: revised file name handling; '@' is no longer part of filename url. 11/27/05 rdb: started basic error support, getErrorDataSource, not complete 10/21/05 rdb: added dumb code in main to reference things that cause compiler warnings, but I don't want to delete. 06/01/05 rdb: modified to match FDLDescriptor refactoring 03/29/05 rdb: created

Field Summary
 
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
MRDataSource(java.lang.String aname, FDLDescriptor fdld)
           
 
Method Summary
 void activate()
          The DataSource will perform any initialization required in order to begin reading/processing data.
protected  void addToLevel(int level, DataSource ds, java.io.File file)
          addToLevel( ds, level )
 boolean changeResolution(int changeCode)
          boolean changeResolution( int changeCode ) changeCode = 0 implies go to resolution level zero otherwise new resolution level = old level + changeCode changeCode < 0 implies make resolution finer by abs( changeCode ) levels changeCode > 0 implies make resolution coarser by changeCode levels
protected  boolean checkCoarser(int level)
          void checkCoarser( int level ) Try to open next coarser data representation.
 boolean coarser()
          boolean coarser( ) Move to next coarser data representation.
 void datum(Datum dtm, IndexSpaceID did)
          Given an IndexSpaceID, copy the values of the Datum at that position to the argument Datum.
 void datum(Datum dtm, IndexSpaceID did, FieldIDMapper mp)
          Given an IndexSpaceID and FieldIDMapper, copy the values of the Datum at that position to the argument Datum.
protected  int findCoarser(java.io.File parent, int level)
          For a particular directory at the specified level find all the coarser representations for that directory.
protected  int findCoarser(int level)
          int findCoarser( int level ) NOT YET IMPLEMENTED Try to find all next coarser data representations in file system for the next coarser level of resolution from that specified in the argument.
 boolean finer()
          boolean finer( ) Move next finer data representation.
 java.io.File getDataFile()
          getDataFile()
protected  java.io.File getDataFile(java.io.File root)
          Find data file
 java.io.File getDataFile(int level)
          getDataFile( int level )
 java.io.File getDataFile(int level, int which)
          getDataFile( int level, int which )
 DataSource getDataSource()
          getDataSource() -- return current data source
 DataSource getDataSource(int level)
          getDataSource( int level )
 DataSource getDataSource(int level, int which)
          getDataSource( int level, int which )
 int getLevel()
          int getLevel()
 int getNumResolutionLevels()
          int getNumResolutionLevels()
static void main(java.lang.String[] args)
           
protected  void openDS(int level)
          Swap datasources.
static void printData(java.lang.String header, float[] data)
           
protected  int setLevel(int newLevel)
          boolean setLevel( int newLevel ) Set resolution level to specified level, but don't open the datasource If the desired level does not exist, returns the level that is closest to that level that does exist.
 void subblock(DataBlock theBlock, ISBounds dstBounds, ISBounds srcBounds)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
 void subblock(DataBlock theBlock, ISBounds dstBounds, ISBounds srcBounds, FieldIDMapper mp)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
protected  void updateMembers()
          upDateMembers copies the key information from the current DS to data members of the MRDS.
 
Methods inherited from class edu.unh.sdb.datasource.DataSource
checkActivated, clearCache, copyBestID, create, create, create, createRemote, createRemote, createRemoteClient, createRemoteClient, createRemoteDataSource, createRemoteDataSource, createRemoteDataSourceUDP, createRemoteUDP, createRemoteUDP, deactivate, 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, 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
 

Constructor Detail

MRDataSource

public MRDataSource(java.lang.String aname,
                    FDLDescriptor fdld)
Parameters:
aname -
fdld -
Method Detail

updateMembers

protected void updateMembers()
upDateMembers copies the key information from the current DS to data members of the MRDS.


getDataFile

protected java.io.File getDataFile(java.io.File root)
Find data file


addToLevel

protected void addToLevel(int level,
                          DataSource ds,
                          java.io.File file)
addToLevel( ds, level )


getDataSource

public DataSource getDataSource()
getDataSource() -- return current data source


getDataSource

public DataSource getDataSource(int level)
getDataSource( int level )


getDataSource

public DataSource getDataSource(int level,
                                int which)
getDataSource( int level, int which )


getDataFile

public java.io.File getDataFile()
getDataFile()


getDataFile

public java.io.File getDataFile(int level)
getDataFile( int level )


getDataFile

public java.io.File getDataFile(int level,
                                int which)
getDataFile( int level, int which )


getLevel

public int getLevel()
int getLevel()


getNumResolutionLevels

public int getNumResolutionLevels()
int getNumResolutionLevels()


setLevel

protected int setLevel(int newLevel)
boolean setLevel( int newLevel ) Set resolution level to specified level, but don't open the datasource If the desired level does not exist, returns the level that is closest to that level that does exist. returns true if the set was successful


finer

public boolean finer()
boolean finer( ) Move next finer data representation. Returns false if no finer available.


changeResolution

public boolean changeResolution(int changeCode)
boolean changeResolution( int changeCode ) changeCode = 0 implies go to resolution level zero otherwise new resolution level = old level + changeCode changeCode < 0 implies make resolution finer by abs( changeCode ) levels changeCode > 0 implies make resolution coarser by changeCode levels


coarser

public boolean coarser()
boolean coarser( ) Move to next coarser data representation. Returns false if no coarser available


findCoarser

protected int findCoarser(int level)
int findCoarser( int level ) NOT YET IMPLEMENTED Try to find all next coarser data representations in file system for the next coarser level of resolution from that specified in the argument. The "base" argument is the directory of the parent in the hierarchy; the "level" argument is the level for the children, if any, of that parent. Returns number of children created.


findCoarser

protected int findCoarser(java.io.File parent,
                          int level)
For a particular directory at the specified level find all the coarser representations for that directory. NOT FINISHED Returns the number of coarser representations found.

Parameters:
parent -
level -

checkCoarser

protected boolean checkCoarser(int level)
void checkCoarser( int level ) Try to open next coarser data representation.


openDS

protected void openDS(int level)
Swap datasources. For now I'll deactivate and activate.


activate

public void activate()
Description copied from class: DataSource
The DataSource will perform any initialization required in order to begin reading/processing data. It is important that all child classes call super.activate()

Overrides:
activate in class DataSource
See Also:
DataSource.activate()

datum

public void datum(Datum dtm,
                  IndexSpaceID did)
Description copied from class: DataCollection
Given an IndexSpaceID, copy the values of the Datum at that position to the argument Datum. TODO Define error conditions

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection
See Also:
DataCollection.datum(edu.unh.sdb.common.Datum, edu.unh.sdb.datasource.IndexSpaceID)

datum

public void datum(Datum dtm,
                  IndexSpaceID did,
                  FieldIDMapper mp)
Description copied from class: DataCollection
Given an IndexSpaceID and FieldIDMapper, copy the values of the Datum at that position to the argument Datum. TODO Define error conditions

Specified by:
datum in interface Indexable
Specified by:
datum in class DataCollection
See Also:
DataCollection.datum(edu.unh.sdb.common.Datum, edu.unh.sdb.datasource.IndexSpaceID, edu.unh.sdb.common.FieldIDMapper)

subblock

public void subblock(DataBlock theBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds)
Description copied from class: DataCollection
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.

Specified by:
subblock in interface Indexable
Specified by:
subblock in class DataCollection
See Also:
DataCollection.subblock(edu.unh.sdb.datasource.DataBlock, edu.unh.sdb.datasource.ISBounds, edu.unh.sdb.datasource.ISBounds)

subblock

public void subblock(DataBlock theBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds,
                     FieldIDMapper mp)
Description copied from class: DataCollection
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds. The FieldIDMapper argument determines the mapping between datums in this DataBlock and datums in the argument DataBlock. It is legal to pass a null for the FieldIDMapper argument which means that all attributes are to be extracted.

Specified by:
subblock in interface Indexable
Specified by:
subblock in class DataCollection

main

public static void main(java.lang.String[] args)

printData

public static void printData(java.lang.String header,
                             float[] data)