Class Schema

    • Constructor Detail

      • Schema

        public Schema​(List<ColumnMetaData> columnMetaData)
        Create a schema based on the given metadata
        Parameters:
        columnMetaData - the metadata to create the schema from
    • Method Detail

      • sameTypes

        public boolean sameTypes​(Schema schema)
        Returns true if the given schema has the same types at each index
        Parameters:
        schema - the schema to compare the types to
        Returns:
        true if the schema has the same types at every index as this one,false otherwise
      • differences

        public List<ColumnMetaData> differences​(Schema schema)
        Compute the difference in ColumnMetaData between this schema and the passed in schema. This is useful during the TransformProcess to identify what a process will do to a given Schema.
        Parameters:
        schema - the schema to compute the difference for
        Returns:
        the metadata that is different (in order) between this schema and the other schema
      • newSchema

        public Schema newSchema​(List<ColumnMetaData> columnMetaData)
        Create a new schema based on the new metadata
        Parameters:
        columnMetaData - the new metadata to create the schema from
        Returns:
        the new schema
      • numColumns

        public int numColumns()
        Returns the number of columns or fields for this schema
        Returns:
        the number of columns or fields for this schema
      • getName

        public String getName​(int column)
        Returns the name of a given column at the specified index
        Parameters:
        column - the index of the column to get the name for
        Returns:
        the name of the column at the specified index
      • getType

        public ColumnType getType​(int column)
        Returns the ColumnType for the column at the specified index
        Parameters:
        column - the index of the column to get the type for
        Returns:
        the type of the column to at the specified inde
      • getType

        public ColumnType getType​(String columnName)
        Returns the ColumnType for the column at the specified index
        Parameters:
        columnName - the index of the column to get the type for
        Returns:
        the type of the column to at the specified inde
      • getMetaData

        public ColumnMetaData getMetaData​(int column)
        Returns the ColumnMetaData at the specified column index
        Parameters:
        column - the index to get the metadata for
        Returns:
        the metadata at ths specified index
      • getMetaData

        public ColumnMetaData getMetaData​(String column)
        Retrieve the metadata for the given column name
        Parameters:
        column - the name of the column to get metadata for
        Returns:
        the metadata for the given column name
      • getColumnNames

        public List<String> getColumnNames()
        Return a copy of the list column names
        Returns:
        a copy of the list of column names for this schema
      • getColumnTypes

        public List<ColumnType> getColumnTypes()
        A copy of the list of ColumnType for this schema
        Returns:
        the list of column types in order based on column index for this schema
      • getColumnMetaData

        public List<ColumnMetaData> getColumnMetaData()
        Returns a copy of the underlying schema ColumnMetaData
        Returns:
        the list of schema metadata
      • getIndexOfColumn

        public int getIndexOfColumn​(String columnName)
        Returns the index for the given column name
        Parameters:
        columnName - the column name to get the index for
        Returns:
        the index of the given column name for the schema
      • getIndexOfColumns

        public int[] getIndexOfColumns​(Collection<String> columnNames)
        Return the indices of the columns, given their namess
        Parameters:
        columnNames - Name of the columns to get indices for
        Returns:
        Column indexes
      • getIndexOfColumns

        public int[] getIndexOfColumns​(String... columnNames)
        Return the indices of the columns, given their namess
        Parameters:
        columnNames - Name of the columns to get indices for
        Returns:
        Column indexes
      • hasColumn

        public boolean hasColumn​(String columnName)
        Determine if the schema has a column with the specified name
        Parameters:
        columnName - Name to see if the column exists
        Returns:
        True if a column exists for that name, false otherwise
      • toJson

        public String toJson()
        Serialize this schema to json
        Returns:
        a json representation of this schema
      • toYaml

        public String toYaml()
        Serialize this schema to yaml
        Returns:
        the yaml representation of this schema
      • fromJson

        public static Schema fromJson​(String json)
        Create a schema from a given json string
        Parameters:
        json - the json to create the schema from
        Returns:
        the created schema based on the json
      • fromYaml

        public static Schema fromYaml​(String yaml)
        Create a schema from the given yaml string
        Parameters:
        yaml - the yaml to create the schema from
        Returns:
        the created schema based on the yaml
      • inferMultiple

        public static Schema inferMultiple​(List<List<Writable>> record)
        Infers a schema based on the record. The column names are based on indexing.
        Parameters:
        record - the record to infer from
        Returns:
        the infered schema
      • infer

        public static Schema infer​(List<Writable> record)
        Infers a schema based on the record. The column names are based on indexing.
        Parameters:
        record - the record to infer from
        Returns:
        the infered schema