edu.unh.sdb.datasource
Class TextFileDataSource

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

public class TextFileDataSource
extends PhysicalDataSource

This class will read from a file of numeric ASCII data, providing an n-dimensional datasource view of that file. At the moment, it should only be used for small files, since it reads the entire file into an array.


Field Summary
protected  java.io.FileInputStream dataFile
           
protected  java.io.StreamTokenizer dataTokens
           
protected  Datum[] theData
           
 
Fields inherited from class edu.unh.sdb.datasource.PhysicalDataSource
BIG_ENDIAN, bufferBounds, bufferDimension, bufferSteps, byteBuffers, directMemoryLimit, endian, LITTLE_ENDIAN, maxBufferSize, maxGapSize, readCounter, readLength, url
 
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
TextFileDataSource(java.lang.String name, RecordDescriptor recordDesc, ISBounds ISBounds, AxisOrdering ordering, java.lang.String URL)
           
 
Method Summary
 void activate()
          Reads the contents of the file into an array.
 void datum(Datum dtm, IndexSpaceID did)
          Return by reference the Datum corresponding to the given IndexSpaceID.
 void datum(Datum dtm, IndexSpaceID did, FieldIDMapper mp)
          Get the Datum and fill its values in the passed Datum at positions specified by the corresponding FieldIDMapper.
 void datum(Datum dtm, IndexSpaceID did, RecordSpec recSpec)
          Get the Datum and fill its values in the passed Datum at positions specified by the corresponding RecordSpec.
 Datum datum(IndexSpaceID did)
          Return the Datum corresponding to the given IndexSpaceID.
 Datum datum(IndexSpaceID did, RecordSpec spec)
          Return the Datum corresponding to the given IndexSpaceID.
 void deactivate()
          Releases the datum array.
static void main(java.lang.String[] args)
           
 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.
 void subblock(DataBlock theBlock, ISBounds dstBounds, ISBounds srcBounds, RecordSpec rs)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
 DataBlock subblock(FloatDatum[] data, ISBounds srcdb)
           
 DataBlock subblock(ISBounds srcdb)
          Returns a spatial subset of the DataSource as delimited by the ISBounds argument.
 DataSource subset(ISBounds db)
           
 DataSource subset(RecordDescriptor rd)
           
 DataSource subset(RecordDescriptor rd, ISBounds db)
           
 java.lang.String toString()
          Print the data members of the DataSource in an easy to read fashion.
 
Methods inherited from class edu.unh.sdb.datasource.PhysicalDataSource
allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, allocateBuffer, deleteBuffer, deleteBuffer, deleteBuffers, equals, getBuffer, getBuffer, getBufferSize, getBufferSize, getByteOrder, getDataFileString, getMaxBufferSize, getReadCounter, getReadLength, getURL, initializeBuffers, isBigEndian, makeBestBuffer, resetReadCounter, setBufferByteOrder, setMaxBufferSize, setMaxGapSize, toString
 
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, getName, getValues, isActivated
 
Methods inherited from class edu.unh.sdb.datasource.DataCollection
byteSize, computeOffset, computeOffset, copyBounds, createDataBlock, createDataBlock, createDataBlock, createDatum, createDatum, createDatum, createDatum, createDatum, createDatum, 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, useBytesOnly, volume
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dataTokens

protected java.io.StreamTokenizer dataTokens

theData

protected Datum[] theData

dataFile

protected java.io.FileInputStream dataFile
Constructor Detail

TextFileDataSource

public TextFileDataSource(java.lang.String name,
                          RecordDescriptor recordDesc,
                          ISBounds ISBounds,
                          AxisOrdering ordering,
                          java.lang.String URL)
Method Detail

activate

public void activate()
Reads the contents of the file into an array.

Overrides:
activate in class DataSource

deactivate

public void deactivate()
Releases the datum array.

Overrides:
deactivate in class PhysicalDataSource

datum

public Datum datum(IndexSpaceID did)
Return the Datum corresponding to the given IndexSpaceID.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

datum

public Datum datum(IndexSpaceID did,
                   RecordSpec spec)
Return the Datum corresponding to the given IndexSpaceID. The Datum will only contain attributes specified by the RecordSpec argument.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

datum

public void datum(Datum dtm,
                  IndexSpaceID did)
Return by reference the Datum corresponding to the given IndexSpaceID.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

datum

public void datum(Datum dtm,
                  IndexSpaceID did,
                  FieldIDMapper mp)
Get the Datum and fill its values in the passed Datum at positions specified by the corresponding FieldIDMapper.

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

datum

public void datum(Datum dtm,
                  IndexSpaceID did,
                  RecordSpec recSpec)
Get the Datum and fill its values in the passed Datum at positions specified by the corresponding RecordSpec.

Specified by:
datum in interface Indexable
Overrides:
datum in class DataCollection

subblock

public void subblock(DataBlock theBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds)
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.

Specified by:
subblock in interface Indexable
Overrides:
subblock in class PhysicalDataSource

subblock

public 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. The FieldIDMapper argument determines the mapping between datums in the datasource and datums in the DataBlock.

Specified by:
subblock in interface Indexable
Overrides:
subblock in class PhysicalDataSource

subblock

public void subblock(DataBlock theBlock,
                     ISBounds dstBounds,
                     ISBounds srcBounds,
                     RecordSpec rs)
Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds. The RecordSpec argument specifies a subset of the DataSource attributes to be written into the DataBlock datums.

Specified by:
subblock in interface Indexable
Overrides:
subblock in class PhysicalDataSource

subblock

public DataBlock subblock(ISBounds srcdb)
Returns a spatial subset of the DataSource as delimited by the ISBounds argument. The DataSource data is copied when filling the DataBlock.

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

subblock

public DataBlock subblock(FloatDatum[] data,
                          ISBounds srcdb)

subset

public DataSource subset(RecordDescriptor rd)

subset

public DataSource subset(ISBounds db)

subset

public DataSource subset(RecordDescriptor rd,
                         ISBounds db)

toString

public java.lang.String toString()
Print the data members of the DataSource in an easy to read fashion.

Overrides:
toString in class PhysicalDataSource

main

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