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 ChecksumMode
checksummode
static boolean
DEBUG
protected DapDataset
dmr
protected D4DSP
dsp
protected Map<DapVariable,Long>
localchecksummap
protected Map<DapVariable,Long>
remotechecksummap
protected ByteOrder
remoteorder
protected DeChunkedInputStream
stream
-
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 void
compile()
The goal here is to process the serialized databuffer and pull out top-level variable positions in the serialized databuffer.protected Object
compileAtomicVar(DapVariable var)
Compile fixed-sized atomic types Storage =[] protected Object
compileOpaqueVar(DapVariable var)
Read and convert an opaque typed arrayObject
compileSequence(DapSequence dapseq)
Compile a sequence as a set of records.protected Object
compileSequenceArray(DapVariable var)
Compile a sequence array.protected Object
compileStringVar(DapVariable var)
Read and convert a string typed arrayprotected Object
compileStructure(DapStructure dapstruct)
Compile a structure instance.protected Object
compileStructureArray(DapVariable var)
Compile a structure array.protected Object
compileVar(DapVariable dapvar)
Return a compiled version of the data for this variable.protected int
computeTypeSize(DapType daptype)
Compute the size in databuffer of the serialized formArray
createArray(DapVariable var, Object storage)
protected Array
createAtomicArray(DapVariable var, Object storage)
protected Array
createSequenceArray(DapVariable var, Object storage)
Create an Array object for a DAP4 Sequence.protected Array
createStructureArray(DapVariable var, Object storage)
protected long
extractChecksum()
Map<DapVariable,Long>
getChecksumMap(DapConstants.ChecksumSource src)
protected int
getCount()
protected void
setChecksum(DapConstants.ChecksumSource src, DapVariable dvar, Long csum)
protected void
skip(long count)
protected long
walkByteStrings(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 IOException
The 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:
DapException
IOException
-
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:
DapException
IOException
-
compileStringVar
protected Object compileStringVar(DapVariable var) throws IOException
Read and convert a string typed array- Parameters:
var
-- Returns:
- cursor
- Throws:
DapException
IOException
-
compileOpaqueVar
protected Object compileOpaqueVar(DapVariable var) throws IOException
Read and convert an opaque typed array- Parameters:
var
-- Returns:
- cursor
- Throws:
DapException
IOException
-
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:
DapException
IOException
-
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:
DapException
IOException
-
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:
DapException
IOException
-
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:
DapException
IOException
-
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 Array createArray(DapVariable var, Object storage)
-
createAtomicArray
protected Array createAtomicArray(DapVariable var, Object storage)
-
createStructureArray
protected Array createStructureArray(DapVariable var, Object storage)
-
createSequenceArray
protected 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:
-
-