public class DoublePackingScheme extends java.lang.Object implements PackingScheme
DoublePackingScheme
class implements a scale and offset
packing scheme for primitive double data. Double values are packed as
integer = double/scale + offset
and then rounded to the nearest
long integer.Modifier and Type | Field and Description |
---|---|
double |
offset
The offset for float data.
|
double |
scale
The scaling factor for double data.
|
Constructor and Description |
---|
DoublePackingScheme() |
Modifier and Type | Method and Description |
---|---|
void |
accept(PackingSchemeVisitor visitor)
Accepts a visitor in this scheme.
|
DataChunk.DataType |
getUnpackedType()
Gets the unpacked data type that values in this packing scheme will
be unpacked to.
|
static void |
main(java.lang.String[] argv)
Tests this class.
|
long |
packDouble(double value)
Packs a double value to an integer.
|
void |
packToByteData(double[] doubleData,
byte[] byteData,
java.lang.Byte missing,
boolean isUnsigned)
Packs primitive data from a double array into a byte array.
|
void |
packToIntData(double[] doubleData,
int[] intData,
java.lang.Integer missing,
boolean isUnsigned)
Packs primitive data from a double array into a int array.
|
void |
packToLongData(double[] doubleData,
long[] longData,
java.lang.Long missing)
Packs primitive data from a double array into a long array.
|
void |
packToShortData(double[] doubleData,
short[] shortData,
java.lang.Short missing,
boolean isUnsigned)
Packs primitive data from a double array into a short array.
|
double |
unpackDouble(long packed)
Unpacks a long integer value to a double.
|
void |
unpackFromByteData(byte[] byteData,
double[] doubleData,
java.lang.Byte missing,
boolean isUnsigned)
Unpacks primitive data from a byte array into a double array.
|
void |
unpackFromIntData(int[] intData,
double[] doubleData,
java.lang.Integer missing,
boolean isUnsigned)
Unpacks primitive data from a int array into a double array.
|
void |
unpackFromLongData(long[] longData,
double[] doubleData,
java.lang.Long missing)
Unpacks primitive data from a long array into a double array.
|
void |
unpackFromShortData(short[] shortData,
double[] doubleData,
java.lang.Short missing,
boolean isUnsigned)
Unpacks primitive data from a short array into a double array.
|
public double scale
public double offset
public DataChunk.DataType getUnpackedType()
PackingScheme
getUnpackedType
in interface PackingScheme
public void accept(PackingSchemeVisitor visitor)
PackingScheme
accept
in interface PackingScheme
visitor
- the visitor to accept.public void unpackFromByteData(byte[] byteData, double[] doubleData, java.lang.Byte missing, boolean isUnsigned)
byteData
- the source array to unpack.doubleData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Double.NaN in the destination array.isUnsigned
- the unsigned flag, true if the data is unsigned
or false if not.public void packToByteData(double[] doubleData, byte[] byteData, java.lang.Byte missing, boolean isUnsigned)
doubleData
- the source array to pack.byteData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.isUnsigned
- the unsigned flag, true if the destination data is
unsigned or false if not.public void unpackFromShortData(short[] shortData, double[] doubleData, java.lang.Short missing, boolean isUnsigned)
shortData
- the source array to unpack.doubleData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Double.NaN in the destination array.isUnsigned
- the unsigned flag, true if the data is unsigned
or false if not.public void packToShortData(double[] doubleData, short[] shortData, java.lang.Short missing, boolean isUnsigned)
doubleData
- the source array to pack.shortData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.isUnsigned
- the unsigned flag, true if the destination data is
unsigned or false if not.public void unpackFromIntData(int[] intData, double[] doubleData, java.lang.Integer missing, boolean isUnsigned)
intData
- the source array to unpack.doubleData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Double.NaN in the destination array.isUnsigned
- the unsigned flag, true if the data is unsigned
or false if not.public void packToIntData(double[] doubleData, int[] intData, java.lang.Integer missing, boolean isUnsigned)
doubleData
- the source array to pack.intData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.isUnsigned
- the unsigned flag, true if the destination data is
unsigned or false if not.public void unpackFromLongData(long[] longData, double[] doubleData, java.lang.Long missing)
longData
- the source array to unpack.doubleData
- the destination array to unpack into.missing
- the missing value to detect (or null for none).
Values in the source array that match the missing value will be
assigned Double.NaN in the destination array.public void packToLongData(double[] doubleData, long[] longData, java.lang.Long missing)
doubleData
- the source array to pack.longData
- the destination array to pack into.missing
- the missing value to detect (or null for none).
Non-finite (NaN and infinity values) in the source array will be
assigned the missing value in the destination array.public long packDouble(double value)
value
- the double value to pack.public double unpackDouble(long packed)
packed
- the long integer value to unpack.public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- the array of command line parameters.java.lang.Exception