org.virbo.dataset
Class DDataSet

java.lang.Object
  extended by org.virbo.dataset.AbstractDataSet
      extended by org.virbo.dataset.DDataSet
All Implemented Interfaces:
MutablePropertyDataSet, QDataSet, WritableDataSet

public final class DDataSet
extends AbstractDataSet
implements WritableDataSet

rank 1,2,or 3 dataset backed by double array. Mutable datasets warning: No dataset should be mutable once it is accessible to the rest of the system. This would require clients make defensive copies which would seriously degrade performance.


Field Summary
static java.lang.String version
           
 
Fields inherited from class org.virbo.dataset.AbstractDataSet
properties
 
Fields inherited from interface org.virbo.dataset.QDataSet
CACHE_TAG, CADENCE, COORDINATE_FRAME, DELTA_MINUS, DELTA_PLUS, DEPEND_0, DEPEND_1, DEPEND_2, FILL_VALUE, LABEL, MAX_PLANE_COUNT, MAX_RANK, MONOTONIC, NAME, PLANE_0, QUBE, RENDER_TYPE, SCALE_TYPE, TITLE, TYPICAL_MAX, TYPICAL_MIN, UNITS, USER_PROPERTIES, VALID_MAX, VALID_MIN, WEIGHTS_PLANE
 
Method Summary
 void append(DDataSet ds)
          append the second dataset onto this dataset.
static DDataSet copy(QDataSet ds)
          copies the dataset into a writeable dataset, and all of its depend datasets as well.
static void copyElements(DDataSet src, int srcpos, DDataSet dest, int destpos, int len)
          copy elements of src DDataSet into dest DDataSet, with System.arraycopy.
static void copyElements(DDataSet src, int srcpos, DDataSet dest, int destpos, int len, boolean checkAlias)
          copy elements of src DDataSet into dest DDataSet, with System.arraycopy.
protected static java.util.Map copyProperties(QDataSet ds)
          copies the properties, copying depend datasets as well.
static DDataSet create(int[] qube)
          Makes an array from array of dimension sizes.
static DDataSet createRank1(int len0)
           
static DDataSet createRank2(int len0, int len1)
           
static DDataSet createRank3(int len0, int len1, int len2)
           
 void join(DDataSet ds)
          Deprecated. use append instead.
 int length()
          return the length of the first dimension
 int length(int i)
          return the length of the second dimension, for the ith element of the first dimension
 int length(int i0, int i1)
          return the length of the third dimension, for the ith element of the first dimension and jth element of the second dimension.
static DDataSet maybeCopy(QDataSet ds)
          Copy the dataset to a DDataSet only if the dataset is not already a DDataSet.
 void putLength(int len)
          Shorten the dataset by changing it's dim 0 length parameter.
 void putValue(int i0, double value)
           
 void putValue(int i0, int i1, double value)
           
 void putValue(int i0, int i1, int i2, double value)
           
 int rank()
          returns the rank of the dataset, which is the number of indeces used to access data.
 java.lang.String toString()
           
 double value(int i0)
          rank 1 accessor.
 double value(int i0, int i1)
          rank 2 accessor.
 double value(int i0, int i1, int i2)
          rank 3 accessor.
static DDataSet wrap(double[] back)
          creates a DDataSet by wrapping an existing double array.
static DDataSet wrap(double[] data, int[] qube)
          Wraps an array from array of dimension sizes.
static DDataSet wrap(double[] back, int nx, int ny)
          creates a DDataSet by wrapping an existing array, aliasing it to rank 2.
static DDataSet wrap(double[] back, int rank, int len0, int len1, int len2)
           
static DDataSet wrapRank2(double[] back, int n1)
          creates a DDataSet by wrapping an existing array, and aliasing it to rank2.
static DDataSet wrapRank3(double[] back, int n1, int n2)
          creates a DDataSet by wrapping an existing array, and aliasing it to rank2.
 
Methods inherited from class org.virbo.dataset.AbstractDataSet
property, property, property, putProperty, putProperty, putProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.virbo.dataset.WritableDataSet
putProperty, putProperty, putProperty
 
Methods inherited from interface org.virbo.dataset.QDataSet
property, property, property
 

Field Detail

version

public static final java.lang.String version
See Also:
Constant Field Values
Method Detail

createRank1

public static DDataSet createRank1(int len0)

createRank2

public static DDataSet createRank2(int len0,
                                   int len1)

createRank3

public static DDataSet createRank3(int len0,
                                   int len1,
                                   int len2)

create

public static DDataSet create(int[] qube)
Makes an array from array of dimension sizes. The result will have rank qube.length().

Parameters:
qube - array specifying the rank and size of each dimension
Returns:
DDataSet

wrap

public static DDataSet wrap(double[] data,
                            int[] qube)
Wraps an array from array of dimension sizes. The result will have rank qube.length().

Parameters:
data - array containing the data, with the last dimension contiguous in memory.
qube - array specifying the rank and size of each dimension
Returns:
DDataSet

rank

public int rank()
Description copied from interface: QDataSet
returns the rank of the dataset, which is the number of indeces used to access data. Only rank 1, 2, and 3 datasets are supported in the interface. When a dataset's rank is 4 or greater, it should implement the HighRankDataSet interface which affords a slice operation to reduce rank. When a dataset's rank is 0, it should implement the RankZeroDataSet interface, which has a no-argument accessor. (TODO: Note that rank 0 and rank N have very limited use, so many routines aren't coded to handle them.)

Specified by:
rank in interface QDataSet
Specified by:
rank in class AbstractDataSet

length

public int length()
Description copied from interface: QDataSet
return the length of the first dimension

Specified by:
length in interface QDataSet
Overrides:
length in class AbstractDataSet

length

public int length(int i)
Description copied from interface: QDataSet
return the length of the second dimension, for the ith element of the first dimension

Specified by:
length in interface QDataSet
Overrides:
length in class AbstractDataSet

length

public int length(int i0,
                  int i1)
Description copied from interface: QDataSet
return the length of the third dimension, for the ith element of the first dimension and jth element of the second dimension.

Specified by:
length in interface QDataSet
Overrides:
length in class AbstractDataSet

value

public double value(int i0)
Description copied from interface: QDataSet
rank 1 accessor.

Specified by:
value in interface QDataSet
Overrides:
value in class AbstractDataSet

value

public double value(int i0,
                    int i1)
Description copied from interface: QDataSet
rank 2 accessor.

Specified by:
value in interface QDataSet
Overrides:
value in class AbstractDataSet

value

public double value(int i0,
                    int i1,
                    int i2)
Description copied from interface: QDataSet
rank 3 accessor.

Specified by:
value in interface QDataSet
Overrides:
value in class AbstractDataSet

putValue

public void putValue(int i0,
                     double value)
Specified by:
putValue in interface WritableDataSet

putValue

public void putValue(int i0,
                     int i1,
                     double value)
Specified by:
putValue in interface WritableDataSet

putValue

public void putValue(int i0,
                     int i1,
                     int i2,
                     double value)
Specified by:
putValue in interface WritableDataSet

putLength

public void putLength(int len)
Shorten the dataset by changing it's dim 0 length parameter. The same backing array is used, so the element that remain ill be the same. can only shorten!


toString

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

copyProperties

protected static java.util.Map copyProperties(QDataSet ds)
copies the properties, copying depend datasets as well.

See Also:
DataSetUtil.copyProperties, which is a shallow copy.

maybeCopy

public static DDataSet maybeCopy(QDataSet ds)
Copy the dataset to a DDataSet only if the dataset is not already a DDataSet.

Parameters:
ds -
Returns:

copy

public static DDataSet copy(QDataSet ds)
copies the dataset into a writeable dataset, and all of its depend datasets as well. An optimized copy is used when the argument is a DDataSet.


wrap

public static DDataSet wrap(double[] back)
creates a DDataSet by wrapping an existing double array.


wrapRank2

public static DDataSet wrapRank2(double[] back,
                                 int n1)
creates a DDataSet by wrapping an existing array, and aliasing it to rank2. Note the last index is packed closest in memory.

Parameters:
n1 - the size of the second dimension.

wrapRank3

public static DDataSet wrapRank3(double[] back,
                                 int n1,
                                 int n2)
creates a DDataSet by wrapping an existing array, and aliasing it to rank2. Note the last index is packed closest in memory. The first index length is calculated from the size of the array.

Parameters:
n1 - the size of the second index.
n2 - the size of the third index.

wrap

public static DDataSet wrap(double[] back,
                            int nx,
                            int ny)
creates a DDataSet by wrapping an existing array, aliasing it to rank 2.


wrap

public static DDataSet wrap(double[] back,
                            int rank,
                            int len0,
                            int len1,
                            int len2)

copyElements

public static void copyElements(DDataSet src,
                                int srcpos,
                                DDataSet dest,
                                int destpos,
                                int len)
copy elements of src DDataSet into dest DDataSet, with System.arraycopy. src and dst must have the same geometry, except for dim 0. Allows for aliasing when higher dimension element count matches.

Parameters:
len - number of records to copy.
Throws:
java.lang.IllegalArgumentException - if the higher rank geometry doesn't match
java.lang.IndexOutOfBoundsException

copyElements

public static void copyElements(DDataSet src,
                                int srcpos,
                                DDataSet dest,
                                int destpos,
                                int len,
                                boolean checkAlias)
copy elements of src DDataSet into dest DDataSet, with System.arraycopy. src and dst must have the same geometry, except for dim 0. Allows for aliasing when higher dimension element count matches.

Parameters:
src - source dataset
srcpos - source dataset first dimension index.
dest - destination dataset
destpos - destination dataset first dimension index.
len - total number of elements to copy
checkAlias - bounds for aliased write (same number of elements, different geometry.)
Throws:
java.lang.IllegalArgumentException - if the higher rank geometry doesn't match
java.lang.IndexOutOfBoundsException

join

public void join(DDataSet ds)
Deprecated. use append instead.

append the second dataset onto this dataset. Not thread safe!!! TODO: this really should return a new dataset. Presumably this is to avoid copies, but currently it copies anyway! TODO: this will be renamed "concatentate" or "append" since "join" is the anti-slice.


append

public void append(DDataSet ds)
append the second dataset onto this dataset. Not thread safe!!! TODO: this really should return a new dataset. Presumably this is to avoid copies, but currently it copies anyway!