Class DataSetSerialiser


  • public class DataSetSerialiser
    extends java.lang.Object
    Class to efficiently serialise and de-serialise DataSet objects into binary byte arrays. The performance can be tuned through:
    Author:
    rstein
    • Method Detail

      • isDataLablesSerialised

        public boolean isDataLablesSerialised()
      • isMetaDataSerialised

        public boolean isMetaDataSerialised()
      • read

        public de.gsi.dataset.DataSet read()
        Read a Dataset from a byte array containing comma separated values.
        The data format is a custom extension of csv with an additional #-commented Metadata Header and a $-commented column header. Expects the following columns in this order to be present: index, x, y, eyn, eyp.
        Returns:
        DataSet with the data and metadata read from the file
      • read

        public de.gsi.dataset.DataSet read​(de.gsi.dataset.DataSet dataSet)
        Read a Dataset from a byte array containing comma separated values.
        The data format is a custom extension of csv with an additional #-commented Metadata Header and a $-commented column header. Expects the following columns in this order to be present: index, x, y, eyn, eyp.
        Parameters:
        dataSet - inplace DataSet that is being overwritten if non-null and DataSet.set(DataSet, boolean) is implemented
        Returns:
        DataSet with the data and metadata read from the file
      • setDataLablesSerialised

        public DataSetSerialiser setDataLablesSerialised​(boolean state)
      • setMetaDataSerialised

        public DataSetSerialiser setMetaDataSerialised​(boolean state)
      • write

        public void write​(de.gsi.dataset.DataSet dataSet,
                          boolean asFloat)
        Write data set into byte buffer.
        Parameters:
        dataSet - The DataSet to export
        asFloat - true: encode data as binary floats (smaller size, performance), or false as double (better precision)
      • getDimIndex

        protected static int getDimIndex​(java.lang.String fieldName,
                                         java.lang.String prefix)
      • getDoubleArray

        protected static double[] getDoubleArray​(IoSerialiser ioSerialiser,
                                                 double[] origArray,
                                                 DataType dataType)
      • parseDataLabels

        protected void parseDataLabels​(de.gsi.dataset.spi.DataSetBuilder builder,
                                       FieldDescription fieldRoot)
      • parseHeaders

        protected void parseHeaders​(IoSerialiser ioSerialiser,
                                    de.gsi.dataset.spi.DataSetBuilder builder,
                                    FieldDescription fieldRoot)
      • parseMetaData

        protected void parseMetaData​(IoSerialiser ioSerialiser,
                                     de.gsi.dataset.spi.DataSetBuilder builder,
                                     FieldDescription rootField)
      • parseNumericData

        protected void parseNumericData​(IoSerialiser ioSerialiser,
                                        de.gsi.dataset.spi.DataSetBuilder builder,
                                        de.gsi.dataset.DataSet origDataSet,
                                        FieldDescription rootField)
      • writeDataLabelsToStream

        protected void writeDataLabelsToStream​(de.gsi.dataset.DataSet dataSet)
      • writeHeaderDataToStream

        protected void writeHeaderDataToStream​(de.gsi.dataset.DataSet dataSet)
      • writeMetaDataToStream

        protected void writeMetaDataToStream​(de.gsi.dataset.DataSet dataSet)
      • writeNumericBinaryDataToBufferDouble

        protected void writeNumericBinaryDataToBufferDouble​(de.gsi.dataset.DataSet dataSet)
        Parameters:
        dataSet - to be exported
      • writeNumericBinaryDataToBufferFloat

        protected void writeNumericBinaryDataToBufferFloat​(de.gsi.dataset.DataSet dataSet)
        Parameters:
        dataSet - to be exported