Merge "Omaha #4425 Add DoubleDataRecord support" into omaha_16.1.1

Former-commit-id: 751a7aaace9fd14e7dcd6cd3b9585377139c1d83
This commit is contained in:
Nate Jensen 2015-04-29 08:55:46 -05:00 committed by Gerrit Code Review
commit c817145410
7 changed files with 196 additions and 52 deletions

View file

@ -1,19 +1,19 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
@ -28,6 +28,7 @@ import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
@ -46,6 +47,7 @@ import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.Request.Type;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.DoubleDataRecord;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
@ -85,6 +87,7 @@ import com.raytheon.uf.viz.core.data.BufferSlicer;
* ------------- -------- ----------- --------------------------
* Sep 18, 2013 2309 bsteffen Initial creation
* Dec 04, 2013 2600 bsteffen Fix typo in contains.
* Apr 27, 2015 4425 nabowle Handle DoubleDataRecord.
*
* </pre>
*
@ -110,7 +113,7 @@ public class DataStoreCache {
/**
* Construct a DataStoreCache that will store cache files in the given
* cacheDir.
*
*
* @param cacheDir
* directory for storing files. If the directory does not exist
* it will be created. If the directory cannot be created or
@ -127,7 +130,7 @@ public class DataStoreCache {
/**
* Gets the dataset names for a group from this cache.
*
*
* @param group
* the name of a group, must not be null
* @return an array of dataset names or null if they are not in this cache
@ -148,7 +151,7 @@ public class DataStoreCache {
/**
* Stores dataset names for a group in this cache. The names can be
* retrieved from the cache using {@link #getDatasetNames(String)}
*
*
* @param group
* the name of a group, must not be null
* @param datasetNames
@ -188,7 +191,7 @@ public class DataStoreCache {
/**
* Gets an {@link IDataRecord} for a specific dataset/group path and request
* from this cache.
*
*
* @param datasetGroupPath
* the group and dataset concatenated together with a
* {@link DataStoreFactory#DEF_SEPARATOR}, must not be null.
@ -228,7 +231,7 @@ public class DataStoreCache {
* Stores a portion of a dataset corresponding to request in this cache. The
* record can be retrieved from the cache using
* {@link #getDataset(String, Request)}
*
*
* @param datasetGroupPath
* the group and dataset concatenated together with a
* {@link DataStoreFactory#DEF_SEPARATOR}, must not be null.
@ -317,7 +320,7 @@ public class DataStoreCache {
/**
* Determine if the data returned by outer contains enough of the data to
* fulfill inner.
*
*
* @return true if outer has enough data for inner, false if not.
*/
private static boolean contains(Request outer, Request inner) {
@ -424,6 +427,9 @@ public class DataStoreCache {
return ShortBuffer.wrap(((ShortDataRecord) record).getShortData());
} else if (record instanceof ByteDataRecord) {
return ByteBuffer.wrap(((ByteDataRecord) record).getByteData());
} else if (record instanceof DoubleDataRecord) {
return DoubleBuffer.wrap(((DoubleDataRecord) record)
.getDoubleData());
}
return null;
}
@ -449,6 +455,9 @@ public class DataStoreCache {
} else if (buffer instanceof ByteBuffer) {
record = new ByteDataRecord(name, group,
((ByteBuffer) buffer).array());
} else if (buffer instanceof DoubleBuffer) {
record = new DoubleDataRecord(name, group,
((DoubleBuffer) buffer).array());
} else {
return null;
}
@ -486,7 +495,7 @@ public class DataStoreCache {
/**
* Load a java object from a cache file.
*
*
* @param file
* the file containing the object
* @param clazz

View file

@ -39,6 +39,7 @@ from struct import pack, unpack
# ------------ ---------- ----------- --------------------------
# 11/11/09 chammack Initial Creation.
# 06/09/10 njensen Added float, list methods
# Apr 24, 2015 4425 nabowle Add F64List support.
#
#
#
@ -52,6 +53,7 @@ floatList = numpy.dtype(numpy.float32).newbyteorder('>')
longList = numpy.dtype(numpy.int64).newbyteorder('>')
shortList = numpy.dtype(numpy.int16).newbyteorder('>')
byteList = numpy.dtype(numpy.int8).newbyteorder('>')
doubleList = numpy.dtype(numpy.float64).newbyteorder('>')
class SelfDescribingBinaryProtocol(TBinaryProtocol):
@ -64,7 +66,7 @@ class SelfDescribingBinaryProtocol(TBinaryProtocol):
return (name, type, id)
def readStructBegin(self):
return self.readString()
return self.readString()
def writeStructBegin(self, name):
self.writeString(name)
@ -84,49 +86,57 @@ class SelfDescribingBinaryProtocol(TBinaryProtocol):
dAsBytes = struct.pack('f', f)
i = struct.unpack('i', dAsBytes)
self.writeI32(i[0])
def readI32List(self, sz):
def readI32List(self, sz):
buff = self.trans.readAll(4*sz)
val = numpy.frombuffer(buff, dtype=intList, count=sz)
return val
def readF32List(self, sz):
buff = self.trans.readAll(4*sz)
val = numpy.frombuffer(buff, dtype=floatList, count=sz)
return val
def readF64List(self, sz):
buff = self.trans.readAll(8*sz)
val = numpy.frombuffer(buff, dtype=doubleList, count=sz)
return val
def readI64List(self, sz):
buff = self.trans.readAll(8*sz)
val = numpy.frombuffer(buff, dtype=longList, count=sz)
return val
def readI16List(self, sz):
buff = self.trans.readAll(2*sz)
val = numpy.frombuffer(buff, dtype=shortList, count=sz)
return val
def readI8List(self, sz):
buff = self.trans.readAll(sz)
val = numpy.frombuffer(buff, dtype=byteList, count=sz)
return val
def writeI32List(self, buff):
def writeI32List(self, buff):
b = numpy.asarray(buff, intList)
self.trans.write(numpy.getbuffer(b))
def writeF32List(self, buff):
def writeF32List(self, buff):
b = numpy.asarray(buff, floatList)
self.trans.write(numpy.getbuffer(b))
def writeI64List(self, buff):
def writeF64List(self, buff):
b = numpy.asarray(buff, doubleList)
self.trans.write(numpy.getbuffer(b))
def writeI64List(self, buff):
b = numpy.asarray(buff, longList)
self.trans.write(numpy.getbuffer(b))
def writeI16List(self, buff):
def writeI16List(self, buff):
b = numpy.asarray(buff, shortList)
self.trans.write(numpy.getbuffer(b))
def writeI8List(self, buff):
def writeI8List(self, buff):
b = numpy.asarray(buff, byteList)
self.trans.write(numpy.getbuffer(b))

View file

@ -36,6 +36,7 @@
# 06/09/10 njensen Initial Creation.
# 06/12/13 #2099 dgilling Implement readObject() and
# writeObject().
# Apr 24, 2015 4425 nabowle Add Double support
#
#
@ -86,7 +87,7 @@ pythonToThriftMap = {
numpy.int64: TType.I64
}
primitiveSupport = (TType.BYTE, TType.I16, TType.I32, TType.I64, SelfDescribingBinaryProtocol.FLOAT)
primitiveSupport = (TType.BYTE, TType.I16, TType.I32, TType.I64, SelfDescribingBinaryProtocol.FLOAT, TType.DOUBLE)
class ThriftSerializationContext(object):
@ -128,14 +129,16 @@ class ThriftSerializationContext(object):
TType.I16: self.protocol.readI16List,
TType.I32: self.protocol.readI32List,
TType.I64: self.protocol.readI64List,
SelfDescribingBinaryProtocol.FLOAT: self.protocol.readF32List
SelfDescribingBinaryProtocol.FLOAT: self.protocol.readF32List,
TType.DOUBLE: self.protocol.readF64List
}
self.listSerializationMethod = {
TType.BYTE: self.protocol.writeI8List,
TType.I16: self.protocol.writeI16List,
TType.I32: self.protocol.writeI32List,
TType.I64: self.protocol.writeI64List,
SelfDescribingBinaryProtocol.FLOAT: self.protocol.writeF32List
SelfDescribingBinaryProtocol.FLOAT: self.protocol.writeF32List,
TType.DOUBLE: self.protocol.writeF64List
}

View file

@ -0,0 +1,116 @@
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
# File auto-generated against equivalent DynamicSerialize Java class and
# modified.
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# Sep 8, 2014 kustert Initial Creation
# Apr 24, 2015 4425 nabowle Bring in.
class DoubleDataRecord(object):
def __init__(self):
self.sizes = None
self.dimension = None
self.maxChunkSize = None
self.name = None
self.fillValue = None
self.dataAttributes = None
self.group = None
self.minIndex = None
self.props = None
self.doubleData = None
self.maxSizes = None
def getSizes(self):
return self.sizes
def setSizes(self, sizes):
self.sizes = sizes
def getDimension(self):
return self.dimension
def setDimension(self, dimension):
self.dimension = dimension
def getMaxChunkSize(self):
return self.maxChunkSize
def setMaxChunkSize(self, maxChunkSize):
self.maxChunkSize = maxChunkSize
def getName(self):
return self.name
def setName(self, name):
self.name = name
def getFillValue(self):
return self.fillValue
def setFillValue(self, fillValue):
self.fillValue = fillValue
def getDataAttributes(self):
return self.dataAttributes
def setDataAttributes(self, dataAttributes):
self.dataAttributes = dataAttributes
def getGroup(self):
return self.group
def setGroup(self, group):
self.group = group
def getMinIndex(self):
return self.minIndex
def setMinIndex(self, minIndex):
self.minIndex = minIndex
def getProps(self):
return self.props
def setProps(self, props):
self.props = props
def getDoubleData(self):
return self.doubleData
def setDoubleData(self, doubleData):
self.doubleData = doubleData
def getMaxSizes(self):
return self.maxSizes
def setMaxSizes(self, maxSizes):
self.maxSizes = maxSizes
def retrieveDataObject(self):
return self.getDoubleData()
def putDataObject(self, obj):
self.setDoubleData(obj)

View file

@ -1,50 +1,53 @@
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
#
#
# U.S. EXPORT CONTROLLED TECHNICAL DATA
# This software product contains export-restricted data whose
# export/transfer/disclosure is restricted by U.S. law. Dissemination
# to non-U.S. persons whether in the United States or abroad requires
# an export license or other authorization.
#
#
# Contractor Name: Raytheon Company
# Contractor Address: 6825 Pine Street, Suite 340
# Mail Stop B8
# Omaha, NE 68106
# 402.291.0100
#
#
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
#
# Package definition for com.raytheon.uf.common.datastorage.records
#
#
#
#
# SOFTWARE HISTORY
#
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 08/31/10 njensen Initial Creation.
#
#
# 08/31/10 njensen Initial Creation.
# Apr 24, 2015 4425 nabowle Add DoubleDataRecord
#
#
#
__all__ = [
'ByteDataRecord',
'FloatDataRecord',
'IntegerDataRecord',
'LongDataRecord',
'ShortDataRecord',
'StringDataRecord',
]
__all__ = [
'ByteDataRecord',
'DoubleDataRecord',
'FloatDataRecord',
'IntegerDataRecord',
'LongDataRecord',
'ShortDataRecord',
'StringDataRecord'
]
from ByteDataRecord import ByteDataRecord
from DoubleDataRecord import DoubleDataRecord
from FloatDataRecord import FloatDataRecord
from IntegerDataRecord import IntegerDataRecord
from LongDataRecord import LongDataRecord
from ShortDataRecord import ShortDataRecord
from StringDataRecord import StringDataRecord
from StringDataRecord import StringDataRecord

View file

@ -30,8 +30,8 @@
# 07/21/10 njensen Initial Creation.
# 09/19/13 2309 bsteffen Fix group name in returned
# records.
# Nov 14, 2013 2393 bclement removed interpolation
#
# Nov 14, 2013 2393 bclement removed interpolation
# Apr 24, 2015 4425 nabowle Add DoubleDataRecord
#
#
@ -47,6 +47,7 @@ typeToClassMap = {
numpy.int32: IntegerDataRecord,
numpy.int64: LongDataRecord,
numpy.float32: FloatDataRecord,
numpy.float64: DoubleDataRecord,
numpy.object_: StringDataRecord,
numpy.string_: StringDataRecord
}

View file

@ -37,6 +37,7 @@
# Mar 19, 2014 2688 bgonzale added more subprocess logging. Return value from
# subprocess.check_output is not return code, but is
# process output. h5repack has no output without -v arg.
# Apr 24, 2015 4425 nabowle Add DoubleDataRecord
#
#
@ -63,6 +64,7 @@ dataRecordMap = {
IntegerDataRecord: numpy.int32,
LongDataRecord: numpy.int64,
FloatDataRecord: numpy.float32,
DoubleDataRecord: numpy.float64,
StringDataRecord: types.StringType,
}