Package dap4.dap4lib
Class D4DataCompiler
- java.lang.Object
-
- dap4.dap4lib.D4DataCompiler
-
public class D4DataCompiler extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected ChecksumModechecksummodestatic booleanDEBUGprotected DapDatasetdmrprotected D4DSPdspprotected Map<DapVariable,Long>localchecksummapprotected Map<DapVariable,Long>remotechecksummapprotected ByteOrderremoteorderprotected DeChunkedInputStreamstream
-
Constructor Summary
Constructors Constructor Description D4DataCompiler(D4DSP dsp, ChecksumMode checksummode, ByteOrder remoteorder)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompile()The goal here is to process the serialized databuffer and pull out top-level variable positions in the serialized databuffer.protected ObjectcompileAtomicVar(DapVariable var)Compile fixed-sized atomic types Storage =[] protected ObjectcompileOpaqueVar(DapVariable var)Read and convert an opaque typed arrayObjectcompileSequence(DapSequence dapseq)Compile a sequence as a set of records.protected ObjectcompileSequenceArray(DapVariable var)Compile a sequence array.protected ObjectcompileStringVar(DapVariable var)Read and convert a string typed arrayprotected ObjectcompileStructure(DapStructure dapstruct)Compile a structure instance.protected ObjectcompileStructureArray(DapVariable var)Compile a structure array.protected ObjectcompileVar(DapVariable dapvar)Return a compiled version of the data for this variable.protected intcomputeTypeSize(DapType daptype)Compute the size in databuffer of the serialized formucar.ma2.ArraycreateArray(DapVariable var, Object storage)protected ucar.ma2.ArraycreateAtomicArray(DapVariable var, Object storage)protected ucar.ma2.ArraycreateSequenceArray(DapVariable var, Object storage)Create an Array object for a DAP4 Sequence.protected ucar.ma2.ArraycreateStructureArray(DapVariable var, Object storage)protected longextractChecksum()Map<DapVariable,Long>getChecksumMap(DapConstants.ChecksumSource src)protected intgetCount()protected voidsetChecksum(DapConstants.ChecksumSource src, DapVariable dvar, Long csum)protected voidskip(long count)protected longwalkByteStrings(long[] positions, ByteBuffer databuffer)
-
-
-
Field Detail
-
DEBUG
public static boolean DEBUG
-
dmr
protected DapDataset dmr
-
checksummode
protected ChecksumMode checksummode
-
remoteorder
protected ByteOrder remoteorder
-
dsp
protected D4DSP dsp
-
stream
protected DeChunkedInputStream stream
-
localchecksummap
protected Map<DapVariable,Long> localchecksummap
-
remotechecksummap
protected Map<DapVariable,Long> remotechecksummap
-
-
Constructor Detail
-
D4DataCompiler
public D4DataCompiler(D4DSP dsp, ChecksumMode checksummode, ByteOrder remoteorder) throws DapException
Constructor- Parameters:
dsp- the D4DSPchecksummode-remoteorder-- Throws:
DapException
-
-
Method Detail
-
getChecksumMap
public Map<DapVariable,Long> getChecksumMap(DapConstants.ChecksumSource src)
-
setChecksum
protected void setChecksum(DapConstants.ChecksumSource src, DapVariable dvar, Long csum)
-
compile
public void compile() throws IOExceptionThe goal here is to process the serialized databuffer and pull out top-level variable positions in the serialized databuffer. In some cases -- String, Sequence, Structure -- significant transforms are applied to the data to make it usable with ucar.ma2.Array.- Throws:
DapExceptionIOException
-
compileVar
protected Object compileVar(DapVariable dapvar) throws IOException
Return a compiled version of the data for this variable. Possible return values are: 1. String - String[] 2. Opaque - Bytebuffer[] 3. Fixed atomic -[] 4. Structure - Object[][nfields] 5. Sequence - Object[][nfields] - Throws:
IOException
-
compileAtomicVar
protected Object compileAtomicVar(DapVariable var) throws IOException
Compile fixed-sized atomic types Storage =[] - Parameters:
var-- Returns:
- data
- Throws:
DapExceptionIOException
-
compileStringVar
protected Object compileStringVar(DapVariable var) throws IOException
Read and convert a string typed array- Parameters:
var-- Returns:
- cursor
- Throws:
DapExceptionIOException
-
compileOpaqueVar
protected Object compileOpaqueVar(DapVariable var) throws IOException
Read and convert an opaque typed array- Parameters:
var-- Returns:
- cursor
- Throws:
DapExceptionIOException
-
compileStructureArray
protected Object compileStructureArray(DapVariable var) throws IOException
Compile a structure array. Since we are using ArrayStructureMA, we need to capture Our storage is Object[dimproduct]; this will be converted properly when the D4Cursor Array is created.- Parameters:
var- the template- Returns:
- a StructureData[dimproduct] for the data for this struct.
- Throws:
DapExceptionIOException
-
compileStructure
protected Object compileStructure(DapStructure dapstruct) throws IOException
Compile a structure instance. Storage is Object[dapstruct.getFields().size()];- Parameters:
dapstruct- The template- Returns:
- A DataStructure for the databuffer for this struct.
- Throws:
DapExceptionIOException
-
compileSequenceArray
protected Object compileSequenceArray(DapVariable var) throws IOException
Compile a sequence array. Our storage is Object[dimproduct]- Parameters:
var- the template- Returns:
- Object[recordcount]
- Throws:
DapExceptionIOException
-
compileSequence
public Object compileSequence(DapSequence dapseq) throws IOException
Compile a sequence as a set of records. Our storage is Object[] where |storage| == nrecords- Parameters:
dapseq-- Returns:
- sequence
- Throws:
DapExceptionIOException
-
extractChecksum
protected long extractChecksum() throws IOException- Throws:
IOException
-
skip
protected void skip(long count) throws IOException- Throws:
IOException
-
getCount
protected int getCount() throws IOException- Throws:
IOException
-
computeTypeSize
protected int computeTypeSize(DapType daptype)
Compute the size in databuffer of the serialized form- Parameters:
daptype-- Returns:
- type's serialized form size
-
walkByteStrings
protected long walkByteStrings(long[] positions, ByteBuffer databuffer) throws IOException- Throws:
IOException
-
createArray
public ucar.ma2.Array createArray(DapVariable var, Object storage)
-
createAtomicArray
protected ucar.ma2.Array createAtomicArray(DapVariable var, Object storage)
-
createStructureArray
protected ucar.ma2.Array createStructureArray(DapVariable var, Object storage)
-
createSequenceArray
protected ucar.ma2.Array createSequenceArray(DapVariable var, Object storage)
Create an Array object for a DAP4 Sequence. Unfortunately, the whole CDM Sequence/VLEN mechanism is completely hosed, with no hope of a simple fix. It appears that the only thing we can do is support scalar sequences. However in useless hope, the code is written as if arrays of sequences can be supported.- Parameters:
var-storage-- Returns:
-
-