Record Class StructType

java.lang.Object
java.lang.Record
smile.data.type.StructType
Record Components:
fields - The struct fields.
index - The map of field name to index.
All Implemented Interfaces:
Serializable, DataType

public record StructType(List<StructField> fields, Map<String,Integer> index) extends Record implements DataType
Struct data type is determined by the fixed order of the fields of primitive data types in the struct. An instance of a struct type will be a tuple.
See Also:
  • Constructor Details

    • StructType

      public StructType(List<StructField> fields)
      Constructor.
      Parameters:
      fields - the struct fields.
    • StructType

      public StructType(StructField... fields)
      Constructor.
      Parameters:
      fields - the struct fields.
    • StructType

      public StructType(List<StructField> fields, Map<String,Integer> index)
      Creates an instance of a StructType record class.
      Parameters:
      fields - the value for the fields record component
      index - the value for the index record component
  • Method Details

    • of

      public static StructType of(ValueVector... columns)
      Returns the schema of a set of columns.
      Parameters:
      columns - the columns to form a data frame.
      Returns:
      the schema.
    • length

      public int length()
      Returns the number of fields.
      Returns:
      the number of fields.
    • field

      public StructField field(int i)
      Return the i-th field.
      Parameters:
      i - the field index.
      Returns:
      the field.
    • field

      public StructField field(String name)
      Return the field of given name.
      Parameters:
      name - the field name.
      Returns:
      the field.
    • apply

      public StructField apply(int i)
      Return the i-th field. This is an alias to field for Scala's convenience.
      Parameters:
      i - the field index.
      Returns:
      the field.
    • apply

      public StructField apply(String name)
      Return the field of given name. This is an alias to field for Scala's convenience.
      Parameters:
      name - the field name.
      Returns:
      the field.
    • set

      public void set(int i, StructField field)
      Sets a field.
      Parameters:
      i - the field index.
      field - the new field.
    • update

      public void update(int i, StructField field)
      Sets a field. This is an alias to set for Scala's convenience.
      Parameters:
      i - the field index.
      field - the new field.
    • rename

      public void rename(String name, String newName)
      Renames a field.
      Parameters:
      name - the field name.
      newName - the new name.
    • add

      public void add(StructField field)
      Adds a field.
      Parameters:
      field - a struct field.
    • indexOf

      public int indexOf(String field)
      Returns the ordinal index of a field.
      Parameters:
      field - the field name.
      Returns:
      the index of field.
    • names

      public String[] names()
      Returns the field names.
      Returns:
      the field names.
    • dtypes

      public DataType[] dtypes()
      Returns the field data types.
      Returns:
      the field data types.
    • measures

      public Measure[] measures()
      Returns the field's level of measurements.
      Returns:
      the field's level of measurements.
    • parser

      public List<Function<String,Object>> parser()
      Returns the lambda functions that parse field values.
      Returns:
      the lambda functions that parse field values.
    • name

      public String name()
      Description copied from interface: DataType
      Returns the type name used in external catalogs. DataType.of(name()) should return the same type.
      Specified by:
      name in interface DataType
      Returns:
      the type name used in external catalogs.
    • id

      public DataType.ID id()
      Description copied from interface: DataType
      Returns the type ID enum.
      Specified by:
      id in interface DataType
      Returns:
      the type ID enum.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • toString

      public String toString(Object o)
      Description copied from interface: DataType
      Returns the string representation of a value of the type.
      Specified by:
      toString in interface DataType
      Parameters:
      o - the value.
      Returns:
      the string representation
    • valueOf

      public Tuple valueOf(String s)
      Description copied from interface: DataType
      Returns the value from its string representation.
      Specified by:
      valueOf in interface DataType
      Parameters:
      s - the string representation of a value of this type.
      Returns:
      the value.
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • of

      public static StructType of(Class<?> clazz)
      Returns the struct type of record or bean class.
      Parameters:
      clazz - the class type of elements.
      Returns:
      the struct type.
    • of

      public static StructType of(Property[] props)
      Returns the struct type of record or bean class properties.
      Parameters:
      props - the record or bean class properties.
      Returns:
      the struct type.
    • of

      public static StructType of(ResultSet rs) throws SQLException
      Returns a struct data type from JDBC result set meta data.
      Parameters:
      rs - the JDBC result set.
      Returns:
      the struct data type.
      Throws:
      SQLException - when JDBC operation fails.
    • of

      public static StructType of(ResultSetMetaData meta, String dbms) throws SQLException
      Returns a struct data type from JDBC result set meta data.
      Parameters:
      meta - the JDBC result set meta data.
      dbms - the name of database management system.
      Returns:
      the struct data type.
      Throws:
      SQLException - when JDBC operation fails.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • fields

      public List<StructField> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component
    • index

      public Map<String,Integer> index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component