public abstract class BufferDataSet extends AbstractDataSet implements WritableDataSet
Modifier and Type | Field and Description |
---|---|
protected java.nio.ByteBuffer |
back
the array backing the data
|
static java.lang.Object |
BITS
constructor units are in bits.
|
static java.lang.Object |
BYTE
1 byte signed byte.
|
static java.lang.Object |
BYTES
constructor units are in bytes.
|
static java.lang.Object |
DOUBLE
the data is in 8 byte doubles.
|
static java.lang.Object |
FLOAT
the data is in 4 byte floats.
|
static java.lang.Object |
INT
4 byte signed integers.
|
static java.lang.Object |
INT24
three-byte ints.
|
static java.lang.Object |
INTEGER
4 byte signed integers, INT is canonical but INTEGER should be accepted.
|
protected static java.util.logging.Logger |
logger |
static java.lang.Object |
LONG
8 byte signed longs.
|
static java.lang.Object |
NYBBLE
four-bit unsigned ints.
|
static java.lang.Object |
SHORT
2 byte short integer.
|
static java.lang.Object |
TRUNCATEDFLOAT
the data is in 16 bit real that has exponent like a FLOAT but mantissa precision is reduced.
|
static java.lang.Object |
UBYTE
1 byte unsigned byte.
|
static java.lang.Object |
UINT
4 byte unsigned integers.
|
static java.lang.Object |
UINT24
three-byte unsigned ints.
|
static java.lang.Object |
USHORT
2 byte unsigned short.
|
static java.lang.Object |
VAX_FLOAT
VAX floats.
|
properties
AVERAGE_TYPE, BIN_MAX, BIN_MAX_NAME, BIN_MIN, BIN_MIN_NAME, BIN_MINUS, BIN_MINUS_NAME, BIN_PLUS, BIN_PLUS_NAME, BINS_0, BINS_1, BUNDLE_0, BUNDLE_1, BUNDLE_2, BUNDLE_3, CACHE_TAG, CADENCE, CONTEXT_0, CONTEXT_1, COORDINATE_FRAME, DEFAULT_FILL_VALUE, DELTA_MINUS, DELTA_MINUS_NAME, DELTA_PLUS, DELTA_PLUS_NAME, DEPEND_0, DEPEND_1, DEPEND_2, DEPEND_3, DEPENDNAME_0, DEPENDNAME_1, DESCRIPTION, ELEMENT_DIMENSIONS, ELEMENT_LABEL, ELEMENT_NAME, FILL_VALUE, FORMAT, JOIN_0, LABEL, LIMIT_HUGE_DATASET, MAX_HIGH_RANK, MAX_PLANE_COUNT, MAX_RANK, MAX_UNIT_BUNDLE_COUNT, METADATA, METADATA_MODEL, MIN_WAVEFORM_LENGTH, MONOTONIC, NAME, NOTES, PLANE_0, QUBE, RENDER_TYPE, SCALE_TYPE, SOURCE, START_INDEX, TITLE, TYPICAL_MAX, TYPICAL_MIN, UNITS, USER_PROPERTIES, VALID_MAX, VALID_MIN, VALUE_AVERAGE_TYPE_GEOMETRIC, VALUE_AVERAGE_TYPE_LINEAR, VALUE_AVERAGE_TYPE_MOD24, VALUE_AVERAGE_TYPE_MOD360, VALUE_AVERAGE_TYPE_MODPI, VALUE_AVERAGE_TYPE_MODTAU, VALUE_AVERAGE_TYPE_NONE, VALUE_BINS_MIN_MAX, VALUE_BINS_MIN_MAX_INCLUSIVE, VALUE_COORDINATE_FRAME_COMPLEX_NUMBER, VALUE_METADATA_MODEL_ISTP, VALUE_METADATA_MODEL_SPASE, VALUE_RENDER_TYPE_COMPOSITE_IMAGE, VALUE_RENDER_TYPE_DIGITAL, VALUE_RENDER_TYPE_EVENTS_BAR, VALUE_RENDER_TYPE_NNSPECTROGRAM, VALUE_RENDER_TYPE_SERIES, VALUE_RENDER_TYPE_TRIANGLE_MESH, VALUE_SCALE_TYPE_LINEAR, VALUE_SCALE_TYPE_LOG, VERSION, WEIGHTS
Constructor and Description |
---|
BufferDataSet(int rank,
int reclen,
int recoffs,
int len0,
int len1,
int len2,
int len3,
java.lang.Object type,
java.nio.ByteBuffer back)
Create a new BufferDataSet of the given type.
|
BufferDataSet(int rank,
int reclen,
int recoffs,
int len0,
int len1,
int len2,
java.lang.Object type,
java.nio.ByteBuffer back)
Create a new BufferDataSet of the given type.
|
BufferDataSet(int rank,
int reclen,
int recoffs,
java.lang.Object bitByte,
int len0,
int len1,
int len2,
int len3,
java.lang.Object type,
java.nio.ByteBuffer back)
Create a new BufferDataSet of the given type.
|
Modifier and Type | Method and Description |
---|---|
void |
about()
print some info about this BufferDataSet.
|
void |
append(BufferDataSet ds)
append the dataset with the same geometry but different number of records (zeroth dim)
to this.
|
static BufferDataSet |
append(BufferDataSet ths,
BufferDataSet ds)
append the two datasets.
|
static int |
bitCount(java.lang.Object type) |
static int |
byteCount(java.lang.Object type)
return the number of bytes of each type (double=8, etc).
|
boolean |
canAppend(BufferDataSet ds)
return true if the dataset can be appended.
|
BufferDataSet |
compact()
get rid of extra spaces between records.
|
static BufferDataSet |
copy(java.lang.Object type,
QDataSet ds)
Copy to array of specific type.
|
static BufferDataSet |
copy(QDataSet ds)
return a copy of the data.
|
static BufferDataSet |
create(int rank,
java.lang.Object type,
int len0,
int[] size)
create a dataset backed by the given type.
|
static BufferDataSet |
createRank0(java.lang.Object type)
create a rank 0 dataset backed by the given type.
|
static BufferDataSet |
createRank1(java.lang.Object type,
int len0)
create a rank 1 dataset backed by the given type.
|
static BufferDataSet |
createRank2(java.lang.Object type,
int len0,
int len1)
create a rank 2 dataset backed by the given type.
|
static BufferDataSet |
createRank3(java.lang.Object type,
int len0,
int len1,
int len2)
create a rank 3 dataset backed by the given type.
|
static BufferDataSet |
createRank4(java.lang.Object type,
int len0,
int len1,
int len2,
int len3)
create a rank 4 dataset backed by the given type.
|
protected void |
ensureWritable()
copy the data to a writable buffer if it's not already writable.
|
java.lang.Class |
getCompatibleComponentType()
return the Java type that is capable of containing elements of this dataset.
|
int |
getFieldStride()
return the number of bytes to advance for each field.
|
int |
getRecordStride()
return the number of bytes to advance for each record.
|
java.lang.Object |
getType()
return the type of this dataset, for example BufferDataSet.INT, BufferDataSet.DOUBLE, etc...
|
void |
grow(int newRecCount)
grow the internal store so that append may be used to resize the
dataset.
|
static java.lang.Object |
guessBackingStore(QDataSet ds)
guess the type of the backing store, returning double.class
if it cannot be determined.
|
boolean |
isCompact()
returns true if the dataset is compact, meaning that there
are no gaps between records, and no byte offset.
|
protected static java.util.Map<java.lang.String,java.lang.Object> |
joinProperties(BufferDataSet ths,
BufferDataSet ds)
join the properties of the two datasets.
|
int |
jvmMemory()
estimate the jvmMemory occupied by this dataset, looking at the NIO buffer
to see if it is direct as has no JVM memory cost, or if it has been made into
an array.
|
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.
|
int |
length(int i0,
int i1,
int i2)
return the length of the fourth dimension for the ith, jth and kth elements of the first three dimensions.
|
static BufferDataSet |
makeDataSet(int rank,
int reclen,
int recoffs,
int[] qube,
java.nio.ByteBuffer buf,
java.lang.Object type)
Make a BufferDataSet of the given type.
|
static BufferDataSet |
makeDataSet(int rank,
int reclen,
int recoffs,
int len0,
int len1,
int len2,
int len3,
java.nio.ByteBuffer buf,
java.lang.Object type)
Make a BufferDataSet of the given type.
|
static BufferDataSet |
makeDataSetBits(int rank,
int reclenbits,
int recoffsbits,
int len0,
int len1,
int len2,
int len3,
java.nio.ByteBuffer buf,
java.lang.Object type)
support binary types that are not a multiple of 8 bits.
|
static BufferDataSet |
maybeCopy(QDataSet ds)
Copy the dataset to an BufferDataSet only if the dataset is not already an BufferDataSet.
|
protected int |
offset()
return the offset, in bytes, of the element.
|
protected int |
offset(int i0)
return the offset, in bytes, of the element.
|
protected int |
offset(int i0,
int i1)
return the offset, in bytes, of the element.
|
protected int |
offset(int i0,
int i1,
int i2)
return the offset, in bytes, of the element.
|
protected int |
offset(int i0,
int i1,
int i2,
int i3)
return the offset, in bytes, of the element.
|
protected void |
rangeCheck(int i0,
int i1,
int i2,
int i3)
for internal use, verify that the indeces are all within bounds.
|
int |
rank()
returns the rank of the dataset, which is the number of indeces used to access data.
|
void |
setFieldStride(int bytes)
allow clients to override the cadence of data.
|
void |
setLength(int len0)
reset the number of records.
|
void |
setLength1(int len1)
reset the length (in fields) of each record of the rank 2 dataset.
|
void |
setRecordStride(int bytes)
allow clients to override the cadece of the records.
|
static int |
shouldAllocateDirect()
return 1 if direct allocate should be used, 0 if not.
|
QDataSet |
slice(int i)
return a dataset that is a slice of this dataset, slicing on the zeroth
dimension.
|
QDataSet |
trim(int ist,
int ien)
return a dataset that is a subset of this dataset.
|
static java.lang.Object |
typeFor(java.lang.Class c)
Return the type for the given class.
|
abstract double |
value()
rank 0 accessor.
|
abstract double |
value(int i0)
rank 1 accessor.
|
abstract double |
value(int i0,
int i1)
rank 2 accessor.
|
abstract double |
value(int i0,
int i1,
int i2)
rank 3 accessor.
|
abstract double |
value(int i0,
int i1,
int i2,
int i3)
rank 4 accessor.
|
capability, checkImmutable, isImmutable, makeImmutable, property, property, putProperty, putProperty, svalue, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
putValue, putValue, putValue, putValue, putValue
isImmutable, makeImmutable, putProperty, putProperty
capability, property, property, svalue
protected static final java.util.logging.Logger logger
protected java.nio.ByteBuffer back
public static final java.lang.Object DOUBLE
public static final java.lang.Object FLOAT
public static final java.lang.Object TRUNCATEDFLOAT
public static final java.lang.Object VAX_FLOAT
public static final java.lang.Object INT24
public static final java.lang.Object UINT24
public static final java.lang.Object NYBBLE
public static final java.lang.Object LONG
public static final java.lang.Object INT
public static final java.lang.Object INTEGER
public static final java.lang.Object UINT
public static final java.lang.Object SHORT
public static final java.lang.Object USHORT
public static final java.lang.Object BYTE
public static final java.lang.Object UBYTE
public static final java.lang.Object BYTES
public static final java.lang.Object BITS
public BufferDataSet(int rank, int reclen, int recoffs, int len0, int len1, int len2, java.lang.Object type, java.nio.ByteBuffer back)
rank
- dataset rankreclen
- length in bytes of each recordrecoffs
- byte offet of each recordlen0
- number of elements in the first indexlen1
- number of elements in the second indexlen2
- number of elements in the third indexback
- ByteBuffer containing the data, which should be at least reclen * len0 bytes long.type
- BufferDataSet.INT, BufferDataSet.DOUBLE, etc...public BufferDataSet(int rank, int reclen, int recoffs, int len0, int len1, int len2, int len3, java.lang.Object type, java.nio.ByteBuffer back)
rank
- dataset rankreclen
- length in bytes of each recordrecoffs
- byte offset of each recordlen0
- number of elements in the first indexlen1
- number of elements in the second indexlen2
- number of elements in the third indexlen3
- number of elements in the fourth indexback
- ByteBuffer containing the data, which should be at least reclen * len0 bytes long.type
- BufferDataSet.INT, BufferDataSet.DOUBLE, etc...public BufferDataSet(int rank, int reclen, int recoffs, java.lang.Object bitByte, int len0, int len1, int len2, int len3, java.lang.Object type, java.nio.ByteBuffer back)
rank
- dataset rankreclen
- length in bytes/bits of each record.recoffs
- byte/bit offset of each record. For bits this must be multiple of 8.bitByte
- either BufferDataSet.BYTES or BufferDataSet.BITSlen0
- number of elements in the first indexlen1
- number of elements in the second indexlen2
- number of elements in the third indexlen3
- number of elements in the fourth indexback
- ByteBuffer containing the data, which should be at least reclen * len0 bytes long (when reclen is in bytes).type
- BufferDataSet.INT, BufferDataSet.DOUBLE, etc...public static int bitCount(java.lang.Object type)
public static int byteCount(java.lang.Object type)
type
- DOUBLE, FLOAT, UBYTE, TIME28, etc.java.lang.IllegalArgumentException
- for NYBBLE, which can only be used with bitCount.public static BufferDataSet makeDataSetBits(int rank, int reclenbits, int recoffsbits, int len0, int len1, int len2, int len3, java.nio.ByteBuffer buf, java.lang.Object type)
rank
- reclenbits
- number of bits per recordrecoffsbits
- number of bits offset. Note this must be a multiple of 8, for now.len0
- number of elements in the first indexlen1
- number of elements in the second indexlen2
- number of elements in the third indexlen3
- number of elements in the fourth indexbuf
- ByteBuffer containing the data, which should be at least recoffsbits/8 + reclenbits/8 * len0 bytes long.type
- BufferDataSet.NYBBLE, etcpublic static BufferDataSet makeDataSet(int rank, int reclen, int recoffs, int len0, int len1, int len2, int len3, java.nio.ByteBuffer buf, java.lang.Object type)
rank
- the rank (number of indeces) of the data.reclen
- length in bytes of each record. This may be longer than len1*len2*len3*byteCount(type)recoffs
- byte offset of each recordlen0
- number of elements in the first indexlen1
- number of elements in the second indexlen2
- number of elements in the third indexlen3
- number of elements in the fourth indexbuf
- ByteBuffer containing the data, which should be at least recoffs + reclen * len0 bytes long.type
- BufferDataSet.INT, BufferDataSet.DOUBLE, etc...public static BufferDataSet makeDataSet(int rank, int reclen, int recoffs, int[] qube, java.nio.ByteBuffer buf, java.lang.Object type)
rank
- the rank (number of indeces) of the data.reclen
- length in bytes of each recordrecoffs
- byte offset of each recordqube
- integer array of the number of elements in each index.
If rank is less than the number of elements, then ignore extra
trailing elements.buf
- ByteBuffer containing the data, which should be at least
recoffs + reclen * len0 bytes long.type
- BufferDataSet.INT, BufferDataSet.DOUBLE, etc...public void setFieldStride(int bytes)
bytes
- number of bytes between field beginnings.public int getFieldStride()
public void setRecordStride(int bytes)
bytes
- number of bytes between record beginnings.public int getRecordStride()
public void setLength(int len0)
len0
- the new number of records.public void setLength1(int len1)
len1
- the length of each record of the rank 2 dataset.Ops.decimateBufferDataSet(org.das2.qds.buffer.BufferDataSet, int, int)
public static BufferDataSet create(int rank, java.lang.Object type, int len0, int[] size)
rank
- the rank of the datatype
- DOUBLE, FLOAT, UINT, etclen0
- number of records (ignored for rank 0).size
- size of each recordpublic static BufferDataSet createRank0(java.lang.Object type)
type
- DOUBLE, FLOAT, UINT, etcpublic static BufferDataSet createRank1(java.lang.Object type, int len0)
type
- DOUBLE, FLOAT, UINT, etclen0
- length of the zeroth indexpublic static BufferDataSet createRank2(java.lang.Object type, int len0, int len1)
type
- DOUBLE, FLOAT, UINT, etclen0
- length of the zeroth indexlen1
- length of the first indexpublic static BufferDataSet createRank3(java.lang.Object type, int len0, int len1, int len2)
type
- DOUBLE, FLOAT, UINT, etclen0
- length of the zeroth indexlen1
- length of the first indexlen2
- length of the second indexpublic static BufferDataSet createRank4(java.lang.Object type, int len0, int len1, int len2, int len3)
type
- DOUBLE, FLOAT, UINT, etclen0
- length of the zeroth indexlen1
- length of the first indexlen2
- length of the second indexlen3
- length of the third indexpublic static BufferDataSet copy(QDataSet ds)
ds
- any qube dataset.public static java.lang.Object guessBackingStore(QDataSet ds)
ds
- the datasetpublic static BufferDataSet maybeCopy(QDataSet ds)
ds
- public boolean canAppend(BufferDataSet ds)
ds
- dataset of the same rank and len1, len2, and len3.public static int shouldAllocateDirect()
https://sourceforge.net/p/autoplot/bugs/1395/
,
http://stackoverflow.com/questions/807263/how-do-i-detect-which-kind-of-jre-is-installed-32bit-vs-64bit
,
"How ByteBuffer works and why Direct (Byte)Buffers are the only truly useful now"
public void append(BufferDataSet ds)
ds
- grow(int)
public static BufferDataSet append(BufferDataSet ths, BufferDataSet ds)
ths
- rank N datasetds
- rank N dataset of the same type and geometry as ths.protected static java.util.Map<java.lang.String,java.lang.Object> joinProperties(BufferDataSet ths, BufferDataSet ds)
ths
- ds
- public static java.lang.Object typeFor(java.lang.Class c)
c
- java classpublic static BufferDataSet copy(java.lang.Object type, QDataSet ds)
type
- the primitive type to use (e.g. double.class).ds
- the data to copy.public void grow(int newRecCount)
newRecCount
- the new record count, generally larger than the old rec count.append(org.das2.qds.buffer.BufferDataSet)
public java.lang.Object getType()
public int rank()
QDataSet
rank
in interface QDataSet
rank
in class AbstractDataSet
public int length()
QDataSet
length
in interface QDataSet
length
in class AbstractDataSet
public int length(int i)
QDataSet
length
in interface QDataSet
length
in class AbstractDataSet
i
- the indexpublic int length(int i0, int i1)
QDataSet
length
in interface QDataSet
length
in class AbstractDataSet
i0
- the indexi1
- the indexpublic int length(int i0, int i1, int i2)
QDataSet
length
in interface QDataSet
length
in class AbstractDataSet
i0
- the indexi1
- the indexi2
- the indexprotected void rangeCheck(int i0, int i1, int i2, int i3)
i0
- the zeroth index.i1
- the first indexi2
- the second indexi3
- the third indexwhich is used to turn on range checking.
protected int offset()
protected int offset(int i0)
i0
- protected int offset(int i0, int i1)
i0
- first indexi1
- second indexprotected int offset(int i0, int i1, int i2)
i0
- first indexi1
- second indexi2
- third indexprotected int offset(int i0, int i1, int i2, int i3)
i0
- first indexi1
- second indexi2
- third indexi3
- fourth indexpublic abstract double value()
QDataSet
value
in interface QDataSet
value
in class AbstractDataSet
public abstract double value(int i0)
QDataSet
value
in interface QDataSet
value
in class AbstractDataSet
i0
- the indexpublic abstract double value(int i0, int i1)
QDataSet
value
in interface QDataSet
value
in class AbstractDataSet
i0
- the indexi1
- the indexpublic abstract double value(int i0, int i1, int i2)
QDataSet
value
in interface QDataSet
value
in class AbstractDataSet
i0
- the indexi1
- the indexi2
- the indexpublic abstract double value(int i0, int i1, int i2, int i3)
QDataSet
value
in interface QDataSet
value
in class AbstractDataSet
i0
- the indexi1
- the indexi2
- the indexi3
- the indexpublic QDataSet trim(int ist, int ien)
QDataSet
ds= DDataSet.createRank1(100);
QDataSet trim= ds.trim(50,60);
assert( trim.length()==10 );
Note start and end must be positive. Negative indices,
referenced from the end of the dataset, are not supported here.trim
in interface QDataSet
trim
in class AbstractDataSet
ist
- the first index to be included in the new dataset.ien
- the exclusive index indicating the last index.public QDataSet slice(int i)
QDataSet
slice
in interface QDataSet
slice
in class AbstractDataSet
i
- the index to slice atprotected void ensureWritable()
public int jvmMemory()
public void about()
public java.lang.Class getCompatibleComponentType()
public boolean isCompact()
public BufferDataSet compact()