public static StructType fromSchemaSequence(Schema schema) {
        StructField[] structFields = new StructField[schema.numColumns() + 2];

        structFields[0] = new StructField(SEQUENCE_UUID_COLUMN, DataTypes.StringType, false, Metadata.empty());
        structFields[1] = new StructField(SEQUENCE_INDEX_COLUMN, DataTypes.IntegerType, false, Metadata.empty());

        for (int i = 0; i < schema.numColumns(); i++) {
            switch (schema.getColumnTypes().get(i)) {
                case Double:
                    structFields[i + 2] =
                                    new StructField(schema.getName(i), DataTypes.DoubleType, false, Metadata.empty());
                    break;
                case Integer:
                    structFields[i + 2] =
                                    new StructField(schema.getName(i), DataTypes.IntegerType, false, Metadata.empty());
                    break;
                case Long:
                    structFields[i + 2] =
                                    new StructField(schema.getName(i), DataTypes.LongType, false, Metadata.empty());
                    break;
                case Float:
                    structFields[i + 2] =
                                    new StructField(schema.getName(i), DataTypes.FloatType, false, Metadata.empty());
                    break;
                default:
                    throw new IllegalStateException(
                                    "This api should not be used with strings , binary data or ndarrays. This is only for columnar data");
            }
        }
        return new StructType(structFields);
    }
public static StructType fromSchemaSequence ( Schema schema ) { StructField [ ] structFields = new StructField [ schema . numColumns ( ) + 2 ] ; structFields [ 0 ] = new StructField ( SEQUENCE_UUID_COLUMN , DataTypes . StringType , false , Metadata . empty ( ) ) ; structFields [ 1 ] = new StructField ( SEQUENCE_INDEX_COLUMN , DataTypes . IntegerType , false , Metadata . empty ( ) ) ; for ( int i = 0 ; i < schema . numColumns ( ) ; i ++ ) { switch ( schema . getColumnTypes ( ) . get ( i ) ) { case Double : structFields [ i + 2 ] = new StructField ( schema . getName ( i ) , DataTypes . DoubleType , false , Metadata . empty ( ) ) ; break ; case Integer : structFields [ i + 2 ] = new StructField ( schema . getName ( i ) , DataTypes . IntegerType , false , Metadata . empty ( ) ) ; break ; case Long : structFields [ i + 2 ] = new StructField ( schema . getName ( i ) , DataTypes . LongType , false , Metadata . empty ( ) ) ; break ; case Float : structFields [ i + 2 ] = new StructField ( schema . getName ( i ) , DataTypes . FloatType , false , Metadata . empty ( ) ) ; break ; default : throw new IllegalStateException ( "This api should not be used with strings , binary data or ndarrays. This is only for columnar data" ) ; } } return new StructType ( structFields ) ; }
Convert the DataVec sequence schema to a StructType for Spark, for example for use in
{@link #toDataFrameSequence(Schema, JavaRDD)}}
<b>Note</b>: as per {@link #toDataFrameSequence(Schema, JavaRDD)}}, the StructType has two additional columns added to it:<br>
- Column 0: Sequence UUID (name: {@link #SEQUENCE_UUID_COLUMN}) - a UUID for the original sequence<br>
- Column 1: Sequence index (name: {@link #SEQUENCE_INDEX_COLUMN} - an index (integer, starting at 0) for the position
of this record in the original time series.<br>
These two columns are required if the data is to be converted back into a sequence at a later point, for example
using {@link #toRecordsSequence(DataRowsFacade)}

@param schema Schema to convert
@return StructType for the schema