edu.unh.sdb.datasource
Class ObliquePlaneIterator

java.lang.Object
  extended by edu.unh.sdb.datasource.DataCollection
      extended by edu.unh.sdb.datasource.DataBlock
          extended by edu.unh.sdb.datasource.ObliquePlaneIterator
All Implemented Interfaces:
SDBIterator, Indexable, ObliquePlaneIteratorInterface

public class ObliquePlaneIterator
extends DataBlock
implements ObliquePlaneIteratorInterface


Nested Class Summary
protected  class ObliquePlaneIterator.IOThread
           
 
Field Summary
protected  double[] absNormal
           
protected  IntegerIndexSpaceID block_plane_offset
           
protected  int[] blockDimensionsArray
           
protected  IntegerIndexSpaceID blockLocation
           
protected  RegularISPartitioning cachePartitioning
           
protected  double[] currentPoint
           
protected  int currentStep
           
protected  Datum datum
           
protected  int[] datumCoords1
           
protected  ISBounds dilatedFetchBounds
           
protected  IndexSpaceID externalScratchID
           
protected  ISBounds fetchBounds
           
protected  ISBoundsIterator fetchIterator
           
protected  edu.unh.sdb.datasource.CacheContext mainCacheContext
           
protected  IndexSpaceID mainScratchID2D
           
protected  IntegerIndexSpaceID mainSpaceLocation
           
protected  float[] normal
           
protected  int[] normalSigns
           
protected  int numSteps
           
protected  int plane0
           
protected  int plane1
           
protected  ISBounds planeBounds
           
protected  ISIterator planeIterator
           
protected  edu.unh.sdb.datasource.ObliquePlaneIterator.PlaneMapper planemapper
           
protected  RegularISPartitioning planePartitioning
           
protected  int prefetchInterval
           
protected  double[] prefetchPoint
           
protected  ObliquePlaneIterator.IOThread prefetchThread
           
protected  int projectionAxis
           
protected  IndexSpaceID scratchID2D
           
protected  IndexSpaceID scratchID3D
           
protected  int[] shiftDirections
           
protected  double[] shiftTotals
           
protected  ISBounds sourceQueryBounds
           
protected  int spaceDimensionality
           
protected  IntegerIndexSpaceID spaceLocation
           
protected  boolean SPBlockShape
           
protected  int[] sQBLowerInts
           
protected  int[] sQBUpperInts
           
protected  ISBounds startBounds
           
protected  double[] startPoint
           
protected  DSBlockStencil stencil
           
protected  boolean stoppedPrefetching
           
protected  BasicBlock theBlock
           
protected  DataSource theSource
           
protected  boolean threaded
           
protected  boolean valid
           
 
Fields inherited from class edu.unh.sdb.datasource.DataCollection
attributeOrder, axisOrdering, axisWeights, bounds, dataOrder, dimensionality, numAttributes, pointOrder, recordDesc
 
Constructor Summary
ObliquePlaneIterator(IndexSpaceID planeShape, IndexSpaceID startpoint, float[] normal, int numsteps, boolean threaded, DataSource source)
          Construct an ObliquePlaneIterator that represents data using a datablock with shape specified by the first argument.
ObliquePlaneIterator(IndexSpaceID planeShape, IndexSpaceID startpoint, float[] normal, int numsteps, DataSource source)
          Construct an ObliquePlaneIterator that represents data using a datablock with shape specified by the first argument.
 
Method Summary
protected static int chooseProjectionAxis(float[] vector)
          Return the axis along which the iterator will project the plane.
protected  ISBoundsIterator createPrefetchIterator(ISBounds planeBounds, ISBounds iterationSpace, IndexSpaceID blockDimensions)
           
 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.
 void datum(Datum d, int[] coordArray)
          Given an array of coordinates, copy the corresponding datum into the first parameter.
 Datum datum(IndexSpaceID did)
          Given an IndexSpaceID, return the corresponding datum.
 Datum datum(IndexSpaceID did, RecordSpec spec)
          Given an IndexSpaceID, return the corresponding datum with attributes specified in the RecordSpec.
 void deactivate()
           
 void end()
          Advance the iterator to the last valid value in the iteration.
protected  void fetch(double[] centerPoint, ISBoundsIterator planeIterator, boolean fetchCurrent, boolean fetchNext)
          This method assumes that the underlying datasource is a MultiBlockCache.
protected  void fetchCurrent(int step)
          This method assumes that the underlying datasource is a MultiBlockCache.
protected  void fetchCurrentandNext(int step)
          This method assumes that the underlying datasource is a MultiBlockCache.
protected  void fetchNext(int step)
          This method assumes that the underlying datasource is a MultiBlockCache.
protected  void fetchWorks(double[] centerPoint, ISBoundsIterator planeIterator, boolean fetchCurrent, boolean fetchNext)
          This method assumes that the underlying datasource is a MultiBlockCache.
protected  void fillBlock(boolean initial)
          This method fills the plane block with data read.
protected static int findMax(float[] vector)
          Return the index of the element with maximum magnitude
 float[] getCenterPoint()
          Return the current center point of the plane in space.
 float[] getCenterPoint(float[] point)
          Return the current center point of the plane in space.
 DataSource getDataSource()
          Return the datasource being iterated over.
 float[] getNormalArray()
          Return a copy of the normals array.
 IndexSpaceID[] getPlane3DVertices(IndexSpaceID[] vertices)
           
 int[] getPlaneShapeArray()
          Return an array indicating the 2D shape of the iteration plane.
 int getPlaneVolume()
          Return the volume of the iteration plane.
 float[] getProjectedNormalArray()
          Return a projection of the normals array onto the projection Axis.
 int getProjectionAxis()
          Return the axis along which the iterator will project the plane.
 ISBounds getSpaceBounds()
          Returns an ISBounds representing the dimensions of the space being iterated over.
 int[] getSpaceShapeArray()
          Returns an array of ints representing the dimensions of the space being iterated over.
 Values getValues()
          return the Values (data) stored in this basicBlock
 void init()
          Perform any necessary initialization, and set the iterator value to the first value in the iteration.
 boolean next()
          Advance the iterator by one step.
static void reduceByCoord(float[] vector, int axis)
          Divide all elements of the vector by the absolute value of the coordinate at the specified axis.
protected  void removePrefetchThread()
           
 void setDataSource(DataSource source)
          Set the datasource being iterated over.
 void setDatum(IndexSpaceID isid, Datum d)
          Set the location specified by the IndexSpaceID to the given datum.
static void setEffectiveZeros(float[] normal, int numSteps)
          Any component of the normal that is sufficiently small will be set to zero.
protected  void setFetchPlane(ISBoundsIterator planeIterator, double[] point, int step)
          Set the iteration space of the 2D plane iterator to correspond to the given 3D iteration step.
 void setSPCacheBlocks(boolean spBlockShape)
          Indicate to this iterator whether the underlying cache has blocks shaped according to the plane normal.
 int size()
          Deprecated. Use volume()
 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 spec)
          Reads a subblock defined by srcBounds into the region of the Datablock argument defined by dstBounds.
 DataBlock subblock(ISBounds db)
          Return a new DataBlock that is a subset of this datablock.
 java.lang.String toString()
          Write the values of the entire DataBlock index space to a string in a nice format.
 boolean valid()
          Return true if the iterator currently has a valid value, false otherwise.
 int volume()
          Return the number of elements in the datablock.
 
Methods inherited from class edu.unh.sdb.datasource.DataBlock
setByAttribute, setByte, setBytes, setBytes, setBytesByAttribute, setBytesByPoint, setDouble, setDoubles, setDoubles, setDoublesByAttribute, setDoublesByPoint, setFloat, setFloats, setFloats, setFloatsByAttribute, setFloatsByPoint, setInt, setInts, setInts, setIntsByAttribute, setIntsByPoint, setShort, setShorts, setShorts, setShortsByAttribute, setShortsByPoint, setValues, setValues, setValuesByAttribute, setValuesByPoint
 
Methods inherited from class edu.unh.sdb.datasource.DataCollection
byteSize, computeOffset, computeOffset, copyBounds, createDataBlock, createDataBlock, createDataBlock, createDatum, createDatum, createDatum, createDatum, createDatum, createDatum, 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, subblock, subblock, subblock, subblock, subblock, subblock, subblock, subblock, useBytesOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theBlock

protected BasicBlock theBlock

theSource

protected DataSource theSource

spaceDimensionality

protected int spaceDimensionality

currentStep

protected int currentStep

numSteps

protected int numSteps

valid

protected boolean valid

currentPoint

protected double[] currentPoint

startPoint

protected double[] startPoint

prefetchPoint

protected double[] prefetchPoint

normal

protected float[] normal

shiftTotals

protected double[] shiftTotals

projectionAxis

protected int projectionAxis

planeIterator

protected ISIterator planeIterator

planeBounds

protected ISBounds planeBounds

startBounds

protected ISBounds startBounds

fetchIterator

protected ISBoundsIterator fetchIterator

fetchBounds

protected ISBounds fetchBounds

blockDimensionsArray

protected int[] blockDimensionsArray

planemapper

protected edu.unh.sdb.datasource.ObliquePlaneIterator.PlaneMapper planemapper

plane0

protected int plane0

plane1

protected int plane1

planePartitioning

protected RegularISPartitioning planePartitioning

dilatedFetchBounds

protected ISBounds dilatedFetchBounds

spaceLocation

protected IntegerIndexSpaceID spaceLocation

mainSpaceLocation

protected IntegerIndexSpaceID mainSpaceLocation

blockLocation

protected IntegerIndexSpaceID blockLocation

block_plane_offset

protected IntegerIndexSpaceID block_plane_offset

scratchID2D

protected IndexSpaceID scratchID2D

mainScratchID2D

protected IndexSpaceID mainScratchID2D

scratchID3D

protected IndexSpaceID scratchID3D

absNormal

protected double[] absNormal

normalSigns

protected int[] normalSigns

shiftDirections

protected int[] shiftDirections

prefetchInterval

protected int prefetchInterval

threaded

protected boolean threaded

prefetchThread

protected ObliquePlaneIterator.IOThread prefetchThread

sQBLowerInts

protected int[] sQBLowerInts

sQBUpperInts

protected int[] sQBUpperInts

datumCoords1

protected int[] datumCoords1

sourceQueryBounds

protected ISBounds sourceQueryBounds

mainCacheContext

protected edu.unh.sdb.datasource.CacheContext mainCacheContext

cachePartitioning

protected RegularISPartitioning cachePartitioning

datum

protected Datum datum

stencil

protected DSBlockStencil stencil

externalScratchID

protected IndexSpaceID externalScratchID

SPBlockShape

protected boolean SPBlockShape

stoppedPrefetching

protected boolean stoppedPrefetching
Constructor Detail

ObliquePlaneIterator

public ObliquePlaneIterator(IndexSpaceID planeShape,
                            IndexSpaceID startpoint,
                            float[] normal,
                            int numsteps,
                            DataSource source)
Construct an ObliquePlaneIterator that represents data using a datablock with shape specified by the first argument. The initial configuration of the plane is defined by the starting point and normal vector. The starting point is conceptually in the middle of the quadrilateral plane subset. The iteration will continue from this initial configuration in the direction of the normal vector for the specified number of steps, reading data from the specified datasource at each step.


ObliquePlaneIterator

public ObliquePlaneIterator(IndexSpaceID planeShape,
                            IndexSpaceID startpoint,
                            float[] normal,
                            int numsteps,
                            boolean threaded,
                            DataSource source)
Construct an ObliquePlaneIterator that represents data using a datablock with shape specified by the first argument. The initial configuration of the plane is defined by the starting point and normal vector. The starting point is conceptually in the middle of the quadrilateral plane subset. The iteration will continue from this initial configuration in the direction of the normal vector for the specified number of steps, reading data from the specified datasource at each step.

Method Detail

setEffectiveZeros

public static void setEffectiveZeros(float[] normal,
                                     int numSteps)
Any component of the normal that is sufficiently small will be set to zero. A component is sufficiently small if setting it to zero will make no functional difference to the iteration.


init

public void init()
Perform any necessary initialization, and set the iterator value to the first value in the iteration.

Specified by:
init in interface SDBIterator

next

public boolean next()
Advance the iterator by one step. If the iterator cannot be advanced to produce a valid value, the value of the iterator is undefined, but the next() method will return false, as will a subsequent call to valid().

Specified by:
next in interface SDBIterator

valid

public boolean valid()
Return true if the iterator currently has a valid value, false otherwise.

Specified by:
valid in interface SDBIterator

end

public void end()
Advance the iterator to the last valid value in the iteration. (optional operation)

Specified by:
end in interface SDBIterator

fetch

protected void fetch(double[] centerPoint,
                     ISBoundsIterator planeIterator,
                     boolean fetchCurrent,
                     boolean fetchNext)
This method assumes that the underlying datasource is a MultiBlockCache. The method informs the cache of the data it will need in order to fill the plane block.


fetchWorks

protected void fetchWorks(double[] centerPoint,
                          ISBoundsIterator planeIterator,
                          boolean fetchCurrent,
                          boolean fetchNext)
This method assumes that the underlying datasource is a MultiBlockCache. The method informs the cache of the data it will need in order to fill the plane block.


fetchNext

protected void fetchNext(int step)
This method assumes that the underlying datasource is a MultiBlockCache. The method informs the cache of the data it will need in order to fill the plane block.


fetchCurrent

protected void fetchCurrent(int step)
This method assumes that the underlying datasource is a MultiBlockCache. The method informs the cache of the data it will need in order to fill the plane block.


fetchCurrentandNext

protected void fetchCurrentandNext(int step)
This method assumes that the underlying datasource is a MultiBlockCache. The method informs the cache of the data it will need in order to fill the plane block.


createPrefetchIterator

protected ISBoundsIterator createPrefetchIterator(ISBounds planeBounds,
                                                  ISBounds iterationSpace,
                                                  IndexSpaceID blockDimensions)

setFetchPlane

protected void setFetchPlane(ISBoundsIterator planeIterator,
                             double[] point,
                             int step)
Set the iteration space of the 2D plane iterator to correspond to the given 3D iteration step. Also set the point array so it correctly defines the plane (in conjunction with this.normal) for the given step of the 3D iteration. This iterator will be used to build a stencil for fetching required cache blocks.


fillBlock

protected void fillBlock(boolean initial)
This method fills the plane block with data read.


removePrefetchThread

protected void removePrefetchThread()

deactivate

public void deactivate()

findMax

protected static int findMax(float[] vector)
Return the index of the element with maximum magnitude


chooseProjectionAxis

protected static int chooseProjectionAxis(float[] vector)
Return the axis along which the iterator will project the plane.


getProjectionAxis

public int getProjectionAxis()
Return the axis along which the iterator will project the plane.


reduceByCoord

public static void reduceByCoord(float[] vector,
                                 int axis)
Divide all elements of the vector by the absolute value of the coordinate at the specified axis.


getDataSource

public DataSource getDataSource()
Return the datasource being iterated over.

Specified by:
getDataSource in interface ObliquePlaneIteratorInterface

setSPCacheBlocks

public void setSPCacheBlocks(boolean spBlockShape)
Indicate to this iterator whether the underlying cache has blocks shaped according to the plane normal.

Specified by:
setSPCacheBlocks in interface ObliquePlaneIteratorInterface

setDataSource

public void setDataSource(DataSource source)
Set the datasource being iterated over.

Specified by:
setDataSource in interface ObliquePlaneIteratorInterface

getNormalArray

public float[] getNormalArray()
Return a copy of the normals array.

Specified by:
getNormalArray in interface ObliquePlaneIteratorInterface

getProjectedNormalArray

public float[] getProjectedNormalArray()
Return a projection of the normals array onto the projection Axis.


getPlaneShapeArray

public int[] getPlaneShapeArray()
Return an array indicating the 2D shape of the iteration plane.

Specified by:
getPlaneShapeArray in interface ObliquePlaneIteratorInterface

getPlaneVolume

public int getPlaneVolume()
Return the volume of the iteration plane.


getPlane3DVertices

public IndexSpaceID[] getPlane3DVertices(IndexSpaceID[] vertices)

getSpaceBounds

public final ISBounds getSpaceBounds()
Returns an ISBounds representing the dimensions of the space being iterated over. This space is calculated as the bounding box of the path of the plane through space, so not all elements in this space are necessarily visited by the iterator.

Specified by:
getSpaceBounds in interface ObliquePlaneIteratorInterface

getSpaceShapeArray

public final int[] getSpaceShapeArray()
Returns an array of ints representing the dimensions of the space being iterated over. This space is calculated as the bounding box of the path of the plane through space, so not all elements in this space are necessarily visited by the iterator.

Specified by:
getSpaceShapeArray in interface ObliquePlaneIteratorInterface

getCenterPoint

public final float[] getCenterPoint()
Return the current center point of the plane in space.


getCenterPoint

public final float[] getCenterPoint(float[] point)
Return the current center point of the plane in space. The coordinates are copied into the argument array and returned.


size

public int size()
Deprecated. Use volume()

Return the number of elements in the datablock.

Overrides:
size in class DataCollection

volume

public int volume()
Return the number of elements in the datablock.

Overrides:
volume in class DataCollection

datum

public Datum datum(IndexSpaceID did)
Given an IndexSpaceID, return the corresponding datum.

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

datum

public void datum(Datum d,
                  int[] coordArray)
Given an array of coordinates, copy the corresponding datum into the first parameter.

Overrides:
datum in class DataCollection

datum

public Datum datum(IndexSpaceID did,
                   RecordSpec spec)
Given an IndexSpaceID, return the corresponding datum with attributes specified in the RecordSpec.

Specified by:
datum in interface Indexable
Overrides:
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

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)
Return by reference the Datum corresponding to the given IndexSpaceID.

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

setDatum

public void setDatum(IndexSpaceID isid,
                     Datum d)
Set the location specified by the IndexSpaceID to the given datum.

Specified by:
setDatum in class DataBlock

subblock

public DataBlock subblock(ISBounds db)
Return a new DataBlock that is a subset of this datablock. The Data is shared between the two DataBlocks.

Specified by:
subblock in interface Indexable
Overrides:
subblock 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
Specified by:
subblock in class DataCollection

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 this DataBlock and datums in the argument DataBlock.

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

getValues

public Values getValues()
return the Values (data) stored in this basicBlock

Overrides:
getValues in class DataBlock

subblock

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

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

toString

public java.lang.String toString()
Description copied from class: DataBlock
Write the values of the entire DataBlock index space to a string in a nice format. Uses the default axisOrdering.

Overrides:
toString in class DataBlock