public abstract class ArrayStructure extends Array
StructureData getStructureData(Index index).For 1D arrays (or by calculating your own recnum for nD arrays), you can also use:
StructureData getStructureData(int recnum).Once you have a StructureData object, you can access data in a general way by using:
Array StructureData.getArray(Member m)When dealing with large arrays of Structures, there can be significant overhead in using the generic interfaces. A number of convenience routines may be able to avoid extra Object creation, and so are recommended for efficiency. The following may avoid the overhead of creating the StructureData object:
Array getArray(int recno, StructureMembers.Member m)The following can be convenient for accessing all the data in the ArrayStructure for one member, but its efficiency depends on the implementation:
Array getMemberArray(StructureMembers.Member m)These require that you know the data types of the member data, but they are the most efficent:
getScalarXXX(int recnum, Member m) getJavaArrayXXX(int recnum, Member m)where XXX is Byte, Char, Double, Float, Int, Long, Short, or String. For members that are themselves Structures, the equivilent is:
StructureData getScalarStructure(int recnum, Member m) ArrayStructure getArrayStructure(int recnum, Member m)These will return any compatible type as a double or float, but will have extra overhead when the types dont match:
convertScalarXXX(int recnum, Member m) convertJavaArrayXXX(int recnum, Member m)where XXX is Double or Float
Array
,
StructureData
Modifier and Type | Class and Description |
---|---|
class |
ArrayStructure.ArrayStructureIterator |
Modifier and Type | Field and Description |
---|---|
protected StructureMembers |
members |
protected int |
nelems |
protected StructureData[] |
sdata |
Modifier | Constructor and Description |
---|---|
protected |
ArrayStructure(StructureMembers members,
Index ima) |
protected |
ArrayStructure(StructureMembers members,
int[] shape)
Create a new Array of type StructureData and the given members and shape.
|
Modifier and Type | Method and Description |
---|---|
double |
convertScalarDouble(int recnum,
StructureMembers.Member m)
Get scalar value as a double, with conversion as needed.
|
float |
convertScalarFloat(int recnum,
StructureMembers.Member m)
Get scalar value as a float, with conversion as needed.
|
int |
convertScalarInt(int recnum,
StructureMembers.Member m)
Get scalar value as an int, with conversion as needed.
|
long |
convertScalarLong(int recnum,
StructureMembers.Member m) |
Array |
copy()
DO NOT USE, throws UnsupportedOperationException
|
protected void |
copyBytes(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyChars(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyDoubles(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyFloats(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyFrom1DJavaArray(IndexIterator iter,
java.lang.Object javaArray) |
protected void |
copyInts(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyLongs(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyObjects(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copySequences(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyShorts(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyStructures(int recnum,
StructureMembers.Member m,
IndexIterator result) |
protected void |
copyTo1DJavaArray(IndexIterator iter,
java.lang.Object javaArray) |
Array |
createView(Index index)
create new Array with given Index and the same backing store
|
Array |
extractMemberArray(StructureMembers.Member m)
Extract data for one member, over all structures.
|
StructureMembers.Member |
findMember(java.lang.String memberName)
Find a member by its name.
|
Array |
getArray(int recno,
StructureMembers.Member m)
Get member data of any type for a specific record as an Array.
|
ArrayObject |
getArrayObject(int recnum,
StructureMembers.Member m)
Get member data of type ArrayObject
|
ArraySequence |
getArraySequence(int recnum,
StructureMembers.Member m)
Get member data of type ArraySequence
|
ArrayStructure |
getArrayStructure(int recnum,
StructureMembers.Member m)
Get member data of type array of Structure.
|
boolean |
getBoolean(Index i)
DO NOT USE, throw ForbiddenConversionException
|
boolean |
getBoolean(int index) |
byte |
getByte(Index i)
DO NOT USE, throw ForbiddenConversionException
|
byte |
getByte(int index) |
char |
getChar(Index i)
DO NOT USE, throw ForbiddenConversionException
|
char |
getChar(int index) |
double |
getDouble(Index i)
DO NOT USE, throw ForbiddenConversionException
|
double |
getDouble(int index) |
java.lang.Class |
getElementType()
Get the element class type of this Array
|
float |
getFloat(Index i)
DO NOT USE, throw ForbiddenConversionException
|
float |
getFloat(int index) |
int |
getInt(Index i)
DO NOT USE, throw ForbiddenConversionException
|
int |
getInt(int index) |
byte[] |
getJavaArrayByte(int recnum,
StructureMembers.Member m)
Get member data of type byte as a 1D array.
|
char[] |
getJavaArrayChar(int recnum,
StructureMembers.Member m)
Get member data of type char as a 1D array.
|
double[] |
getJavaArrayDouble(int recnum,
StructureMembers.Member m)
Get member data of type double as a 1D array.
|
float[] |
getJavaArrayFloat(int recnum,
StructureMembers.Member m)
Get member data of type float as a 1D array.
|
int[] |
getJavaArrayInt(int recnum,
StructureMembers.Member m)
Get member data of type int as a 1D array.
|
long[] |
getJavaArrayLong(int recnum,
StructureMembers.Member m)
Get member data of type long as a 1D array.
|
short[] |
getJavaArrayShort(int recnum,
StructureMembers.Member m)
Get member data of type short as a 1D array.
|
java.lang.String[] |
getJavaArrayString(int recnum,
StructureMembers.Member m)
Get member data of type String as a 1D array.
|
long |
getLong(Index i)
DO NOT USE, throw ForbiddenConversionException
|
long |
getLong(int index) |
java.util.List<StructureMembers.Member> |
getMembers()
Get a list of structure members.
|
java.lang.Object |
getObject(Index i)
Get the index-th StructureData of this ArrayStructure.
|
java.lang.Object |
getObject(int index)
Get the index-th StructureData of this ArrayStructure.
|
byte |
getScalarByte(int recnum,
StructureMembers.Member m)
Get scalar member data of type byte.
|
char |
getScalarChar(int recnum,
StructureMembers.Member m)
Get scalar member data of type char.
|
double |
getScalarDouble(int recnum,
StructureMembers.Member m)
Get scalar member data of type double.
|
float |
getScalarFloat(int recnum,
StructureMembers.Member m)
Get scalar member data of type float.
|
int |
getScalarInt(int recnum,
StructureMembers.Member m)
Get scalar member data of type int.
|
long |
getScalarLong(int recnum,
StructureMembers.Member m)
Get scalar member data of type long.
|
java.lang.Object |
getScalarObject(int recno,
StructureMembers.Member m)
Get member data array of any type as an Object, eg, Float, Double, String, StructureData etc.
|
short |
getScalarShort(int recnum,
StructureMembers.Member m)
Get scalar member data of type short.
|
java.lang.String |
getScalarString(int recnum,
StructureMembers.Member m)
Get member data of type String or char.
|
StructureData |
getScalarStructure(int recnum,
StructureMembers.Member m)
Get member data of type Structure.
|
short |
getShort(Index i)
DO NOT USE, throw ForbiddenConversionException
|
short |
getShort(int index) |
long |
getSizeBytes()
Get the total number of bytes in the array.
|
java.lang.Object |
getStorage()
Get underlying primitive array storage.
|
StructureData |
getStructureData(Index i)
Get the index-th StructureData of this ArrayStructure.
|
StructureData |
getStructureData(int index)
Get the index-th StructureData of this ArrayStructure.
|
StructureDataIterator |
getStructureDataIterator() |
java.util.List<java.lang.String> |
getStructureMemberNames()
Get a list structure member names.
|
StructureMembers |
getStructureMembers()
Get the StructureMembers object.
|
int |
getStructureSize()
Get the size of each StructureData object in bytes.
|
protected abstract StructureData |
makeStructureData(ArrayStructure as,
int recno) |
Array |
sectionNoReduce(java.util.List<Range> ranges)
Create a new Array as a subsection of this Array, without rank reduction.
|
void |
setBoolean(Index i,
boolean value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setBoolean(int index,
boolean value) |
void |
setByte(Index i,
byte value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setByte(int index,
byte value) |
void |
setChar(Index i,
char value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setChar(int index,
char value) |
void |
setDouble(Index i,
double value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setDouble(int index,
double value) |
void |
setFloat(Index i,
float value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setFloat(int index,
float value) |
void |
setInt(Index i,
int value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setInt(int index,
int value) |
void |
setLong(Index i,
long value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setLong(int index,
long value) |
void |
setMemberArray(StructureMembers.Member m,
Array memberArray)
Set data for one member, over all structures.
|
void |
setObject(Index i,
java.lang.Object value)
Set one of the StructureData of this ArrayStructure.
|
void |
setObject(int index,
java.lang.Object value)
Set the index-th StructureData of this ArrayStructure.
|
void |
setShort(Index i,
short value)
DO NOT USE, throw ForbiddenConversionException
|
void |
setShort(int index,
short value) |
void |
showInternal(java.util.Formatter f,
Indent indent) |
void |
showInternalMembers(java.util.Formatter f,
Indent indent) |
arraycopy, copyTo1DJavaArray, copyToNDJavaArray, factory, factory, factory, factory, factory, factory, factoryConstant, flip, get1DJavaArray, getDataAsByteBuffer, getDataAsByteBuffer, getDataAsByteBuffer, getDataType, getIndex, getIndexIterator, getIndexIteratorFast, getIndexPrivate, getRangeIterator, getRank, getShape, getSize, hasNext, isConstant, isUnsigned, makeArray, makeArray, makeArray, makeArray, makeArrayRankPlusOne, next, nextBoolean, nextByte, nextChar, nextDouble, nextFloat, nextInt, nextLong, nextShort, permute, reduce, reduce, resetLocalIterator, reshape, reshapeNoCopy, section, section, section, sectionNoReduce, setUnsigned, shapeToString, slice, toString, transpose
protected StructureMembers members
protected int nelems
protected StructureData[] sdata
protected ArrayStructure(StructureMembers members, int[] shape)
members
- a description of the structure membersshape
- the shape of the Array.protected ArrayStructure(StructureMembers members, Index ima)
protected void copyFrom1DJavaArray(IndexIterator iter, java.lang.Object javaArray)
copyFrom1DJavaArray
in class Array
protected void copyTo1DJavaArray(IndexIterator iter, java.lang.Object javaArray)
copyTo1DJavaArray
in class Array
public java.lang.Class getElementType()
Array
getElementType
in class Array
public StructureMembers getStructureMembers()
public java.util.List<StructureMembers.Member> getMembers()
public java.util.List<java.lang.String> getStructureMemberNames()
public StructureMembers.Member findMember(java.lang.String memberName)
memberName
- find member with this namepublic long getSizeBytes()
Array
getSizeBytes
in class Array
public java.lang.Object getObject(Index i)
public void setObject(Index i, java.lang.Object value)
public java.lang.Object getObject(int index)
public void setObject(int index, java.lang.Object value)
public StructureData getStructureData(Index i)
i
- which one to get, specified by an Index.public StructureData getStructureData(int index)
index
- which one to get, specified by an integer.public java.lang.Object getStorage()
Array
getStorage
in class Array
protected abstract StructureData makeStructureData(ArrayStructure as, int recno)
public int getStructureSize()
public StructureDataIterator getStructureDataIterator()
public Array getArray(int recno, StructureMembers.Member m)
recno
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member.public void setMemberArray(StructureMembers.Member m, Array memberArray)
m
- set data for this StructureMembers.Member.memberArray
- Array values.public Array extractMemberArray(StructureMembers.Member m) throws java.io.IOException
m
- get data from this StructureMembers.Member.java.io.IOException
- on read error (only happens for Sequences, otherwise data is already read)protected void copyChars(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyDoubles(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyFloats(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyBytes(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyShorts(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyInts(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyLongs(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyObjects(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copyStructures(int recnum, StructureMembers.Member m, IndexIterator result)
protected void copySequences(int recnum, StructureMembers.Member m, IndexIterator result)
public java.lang.Object getScalarObject(int recno, StructureMembers.Member m)
recno
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member.public float convertScalarFloat(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- member Variable.ForbiddenConversionException
- if not convertible to float.public double convertScalarDouble(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- member Variable.ForbiddenConversionException
- if not convertible to double.public int convertScalarInt(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- member Variable.ForbiddenConversionException
- if not convertible to double.public long convertScalarLong(int recnum, StructureMembers.Member m)
public double getScalarDouble(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type double.public double[] getJavaArrayDouble(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type double.public float getScalarFloat(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type float.public float[] getJavaArrayFloat(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type float.public byte getScalarByte(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type byte.public byte[] getJavaArrayByte(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type byte.public short getScalarShort(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type short.public short[] getJavaArrayShort(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type float.public int getScalarInt(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type int.public int[] getJavaArrayInt(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type int.public long getScalarLong(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type long.public long[] getJavaArrayLong(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type long.public char getScalarChar(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type char.public char[] getJavaArrayChar(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type char.public java.lang.String getScalarString(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type String or char.public java.lang.String[] getJavaArrayString(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type String.public StructureData getScalarStructure(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type Structure.public ArrayStructure getArrayStructure(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type Structure.public ArraySequence getArraySequence(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type Structure.public ArrayObject getArrayObject(int recnum, StructureMembers.Member m)
recnum
- get data from the recnum-th StructureData of the ArrayStructure. Must be less than getSize();m
- get data from this StructureMembers.Member. Must be of type Structure.public void showInternal(java.util.Formatter f, Indent indent)
public void showInternalMembers(java.util.Formatter f, Indent indent)
public Array createView(Index index)
Array
createView
in class Array
index
- use this Indexpublic Array sectionNoReduce(java.util.List<Range> ranges) throws InvalidRangeException
Array
sectionNoReduce
in class Array
ranges
- list of Ranges that specify the array subset.
Must be same rank as original Array.
A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range.InvalidRangeException
- if ranges is invalidpublic Array copy()
public double getDouble(Index i)
public void setDouble(Index i, double value)
public float getFloat(Index i)
public void setFloat(Index i, float value)
public long getLong(Index i)
public void setLong(Index i, long value)
public int getInt(Index i)
public void setInt(Index i, int value)
public short getShort(Index i)
public void setShort(Index i, short value)
public byte getByte(Index i)
public void setByte(Index i, byte value)
public boolean getBoolean(Index i)
getBoolean
in class Array
i
- Index with current element setindex
cast to boolean if necessary.public void setBoolean(Index i, boolean value)
setBoolean
in class Array
i
- Index with current element setvalue
- the new value; cast to underlying data type if necessary.public char getChar(Index i)
public void setChar(Index i, char value)
public boolean getBoolean(int index)
getBoolean
in class Array
public void setBoolean(int index, boolean value)
setBoolean
in class Array