org.das2.qds.buffer.BufferDataSet
rank 1, 2, 3, and 4 datasets backed by NIO buffers. These have the
advantage that data can be stored outside of the JVM, and in fact they
can be backed by a huge file on disk.
This code was copied from BinaryDataSource.
FLOAT
the data is in 4 byte floats.
TRUNCATEDFLOAT
the data is in 16 bit real that has exponent like a FLOAT but mantissa precision is reduced.
VAX_FLOAT
VAX floats.
INT24
three-byte ints.
UINT24
three-byte unsigned ints.
NYBBLE
four-bit unsigned ints.
INTEGER
4 byte signed integers, INT is canonical but INTEGER should be accepted.
UINT
4 byte unsigned integers. Note 4-byte signed ints are used to store the data
which is unpacked in the value() method.
SHORT
2 byte short integer.
USHORT
2 byte unsigned short.
BYTE
1 byte signed byte.
UBYTE
1 byte unsigned byte.
BYTES
constructor units are in bytes.
BITS
constructor units are in bits.
bitCount
bitCount( Object type ) → int
Returns:
int
search for examples
view on GitHub
view source
byteCount
byteCount( Object type ) → int
return the number of bytes of each type (double=8, etc).
Parameters
type - DOUBLE, FLOAT, UBYTE, TIME28, etc.
Returns:
8, 4, 1, etc.
search for examples
view on GitHub
view source
compact
compact( ) → BufferDataSet
get ride of extra spaces between records.
Returns:
new BufferDataSet without gaps.
search for examples
view on GitHub
view source
getCompatibleComponentType
getCompatibleComponentType( ) → Class
return the Java type that is capable of containing elements of this dataset.
For unsigned types, the next Java class is used, for example int.class is
used to store unsigned shorts.
Returns:
double.class, float.class, long.class, etc.
search for examples
view on GitHub
view source
getType
getType( ) → Object
return the type of this dataset, for example BufferDataSet.INT, BufferDataSet.DOUBLE, etc...
Returns:
the type of this dataset.
search for examples
view on GitHub
view source
isCompact
isCompact( ) → boolean
returns true if the dataset is compact, meaning that there
are no gaps between records, and no byte offset.
Returns:
true if the dataset is compact
search for examples
view on GitHub
view source
makeDataSet
makeDataSet( int rank, int reclen, int recoffs, int len0, int len1, int len2, int len3, java.nio.ByteBuffer buf, Object type ) → BufferDataSet
Make a BufferDataSet of the given type.
Parameters
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 record
len0 - number of elements in the first index
len1 - number of elements in the second index
len2 - number of elements in the third index
len3 - number of elements in the fourth index
buf - ByteBuffer containing the data, which should be at least recoffs + reclen * len0 bytes long.
type - BufferDataSet.INT, BufferDataSet.DOUBLE, etc...
Returns:
BufferDataSet of the given type.
search for examples
view on GitHub
view source
makeDataSetBits
makeDataSetBits( int rank, int reclenbits, int recoffsbits, int len0, int len1, int len2, int len3, java.nio.ByteBuffer buf, Object type ) → BufferDataSet
support binary types that are not a multiple of 8 bits. This was
added to support Nybbles, and 12-bit ints.
Parameters
rank -
reclenbits - number of bits per record
recoffsbits - number of bits offset. Note this must be a multiple of 8, for now.
len0 - number of elements in the first index
len1 - number of elements in the second index
len2 - number of elements in the third index
len3 - number of elements in the fourth index
buf - ByteBuffer containing the data, which should be at least recoffsbits/8 + reclenbits/8 * len0 bytes long.
type - BufferDataSet.NYBBLE, etc
Returns:
BufferDataSet of the given type.
search for examples
view on GitHub
view source
shouldAllocateDirect
shouldAllocateDirect( ) → int
return 1 if direct allocate should be used, 0 if not.
Direct allocations are memory allocations outside of the JVM heap memory.
(The internal variable has a -1 initial state, which is why this is
not boolean.) This looks for 32bit Javas, and if more than 1/2 Gig is
being used then it will allocate direct. This is because 32bit Javas
cannot access any memory outside of 1Gig.
Returns:
1 or 0 if direct allocations should not be made.
See Also:
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
http://stackoverflow.com/questions/3651737/why-the-odd-performance-curve-differential-between-bytebuffer-allocate-and-byt "How ByteBuffer works and why Direct (Byte) "How ByteBuffer works and why Direct (Byte)Buffers are the only truly useful now"
search for examples
view on GitHub
view source
typeFor
typeFor( java.lang.Class c ) → Object
Return the type for the given class. Note that there is a type for
each native type (Byte,Short,Float,etc), but not a class for each type.
(E.g. UBYTE is unsigned byte.)
Parameters
c - java class
Returns:
DOUBLE,FLOAT,etc.
search for examples
view on GitHub
view source