edu.unh.sdb.datasource
Class DSArrayStencil

java.lang.Object
  extended by edu.unh.sdb.datasource.DSStencil
      extended by edu.unh.sdb.datasource.DSPartitionedStencil
          extended by edu.unh.sdb.datasource.DSArrayStencil

public class DSArrayStencil
extends DSPartitionedStencil

This is an implementation of a partitioned stencil that uses an array to maintain the record of active elements. As a result, the set and get methods are extremely fast, but iteration might be a little less efficient than the list implementation. However, it does not tax the garbage collector, so it may be more appropriate for repeated use.


Field Summary
protected  DataBlock block
           
protected  int dataBytesUsed
           
protected  boolean[] inStencil
           
protected  int lastActiveOffset
           
protected  int lastIndexRequested
           
protected  int size
           
 
Fields inherited from class edu.unh.sdb.datasource.DSPartitionedStencil
headerLength, partitioning, partitioningDimensionsArray, partitionListBytesLength
 
Fields inherited from class edu.unh.sdb.datasource.DSStencil
dimensionality, space
 
Constructor Summary
DSArrayStencil(RegularISPartitioning partitioning)
          Construct a stencil that identifies areas of interest using a partitioning.
 
Method Summary
 void clear()
          Clear this stencil of all elements.
 boolean get(IndexSpaceID id)
          Return true if the given id maps to an active stencil element, false otherwise.
 byte[] getData(byte[] data, DataSource ds)
          Fill the given byte array with the data contained in the active elements of this stencil.
 byte[] getData(byte[] data, PointOrderBFDS ds)
          Fill the given byte array with the data contained in the active elements of this stencil.
 int getDataBytesUsed()
          Return the number of bytes actually used in the last call to getData().
 ISBounds getIndexedBounds(ISBounds stencilBounds, int index)
          Sets the argument ISBounds to the bounds of the specified stencil element.
protected  long getIndexedOffset(int index)
          Return the partition offset corresponding to the given index.
static void main(java.lang.String[] argv)
           
 boolean set(IndexSpaceID id)
          Set the stencil element containing the id to "active".
 boolean setElement(IndexSpaceID pid)
          Set the stencil element with index corresponding to id to "active.
protected  void setElementFromOffset(int offset)
          Set the element corresponding to the 1D offset to be active.
 int size()
          return number of active elements contained by this stencil
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
           
 
Methods inherited from class edu.unh.sdb.datasource.DSPartitionedStencil
chooseBytesPerValue, getPartitionDimensions, getPartitionDimensionsArray, getPartitioningDimensions, getPartitionListBytes, getPartitionListBytesLength, inPartitioningBounds, inPartitioningBounds, partitionVolume, setPartitionListFromBytes, volume
 
Methods inherited from class edu.unh.sdb.datasource.DSStencil
dim, getIndexedBounds, getSpaceBounds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inStencil

protected boolean[] inStencil

size

protected int size

lastIndexRequested

protected int lastIndexRequested

lastActiveOffset

protected int lastActiveOffset

dataBytesUsed

protected int dataBytesUsed

block

protected DataBlock block
Constructor Detail

DSArrayStencil

public DSArrayStencil(RegularISPartitioning partitioning)
Construct a stencil that identifies areas of interest using a partitioning. The first argument is the dimensions of an element of the partitioning, meaning that the index space bounded by the second argument will be divided up into pieces of the shape described by the first argument. For example, if we build an 8x8 partitioning of a 128x128 index space, each element of the partitioning will have dimensions 16x16. In this situation, the first argument for this constructor should be [16,16] and the second argument should be {<0,0>, <127,127>}.

Method Detail

getData

public byte[] getData(byte[] data,
                      PointOrderBFDS ds)
Fill the given byte array with the data contained in the active elements of this stencil. If the given array is not long enough to contain the stencil data, a new array is allocated and returned. The number of bytes actually used in the array can be retrieved by calling getDataBytesUsed().


getData

public byte[] getData(byte[] data,
                      DataSource ds)
Fill the given byte array with the data contained in the active elements of this stencil. If the given array is not long enough to contain the stencil data, a new array is allocated and returned. The number of bytes actually used in the array can be retrieved by calling getDataBytesUsed().


getDataBytesUsed

public int getDataBytesUsed()
Return the number of bytes actually used in the last call to getData().


set

public boolean set(IndexSpaceID id)
Set the stencil element containing the id to "active". If it is already active, then the method returns false. Returns true otherwise.

Specified by:
set in class DSStencil

setElement

public boolean setElement(IndexSpaceID pid)
Set the stencil element with index corresponding to id to "active. id should already have been mapped to the partitioning space. If it is already active, then the method returns false. Returns true otherwise.

Specified by:
setElement in class DSStencil

get

public boolean get(IndexSpaceID id)
Return true if the given id maps to an active stencil element, false otherwise.

Specified by:
get in class DSStencil

getIndexedBounds

public ISBounds getIndexedBounds(ISBounds stencilBounds,
                                 int index)
Sets the argument ISBounds to the bounds of the specified stencil element. The ordering of the stencil elements is arbitrary. If the specified index is not less than the number of elements, then the bounds argument is not changed, and the method returns null. Otherwise, the bounds are modified and a reference to the argument bounds is returned.

Specified by:
getIndexedBounds in class DSStencil

getIndexedOffset

protected final long getIndexedOffset(int index)
Return the partition offset corresponding to the given index.

Specified by:
getIndexedOffset in class DSPartitionedStencil

setElementFromOffset

protected void setElementFromOffset(int offset)
Set the element corresponding to the 1D offset to be active.

Specified by:
setElementFromOffset in class DSPartitionedStencil

size

public int size()
return number of active elements contained by this stencil

Specified by:
size in class DSStencil

clear

public void clear()
Clear this stencil of all elements.

Specified by:
clear in class DSPartitionedStencil

toString

public java.lang.String toString()
Return a String representing the object.

Overrides:
toString in class DSPartitionedStencil

toString

public java.lang.String toString(java.lang.String indent)
Overrides:
toString in class DSPartitionedStencil

main

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