Class StructType

java.lang.Object
smile.data.type.StructType
All Implemented Interfaces:
Serializable, DataType

public class StructType extends Object 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.
  • Method Details

    • length

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

      public StructField[] fields()
      Returns the fields.
      Returns:
      the fields.
    • field

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

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

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

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

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

      public DataType type(int i)
      Returns the field data type.
      Parameters:
      i - the index of field.
      Returns:
      the field data type.
    • types

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

      public Measure measure(int i)
      Returns the field's level of measurements.
      Parameters:
      i - the index of field.
      Returns:
      the field's level of measurements.
    • 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.
    • boxed

      public StructType boxed(Collection<Tuple> rows)
      Updates the field type to the boxed one if the field has null/missing values in the data.
      Parameters:
      rows - a set of tuples.
      Returns:
      the new struct with boxed field types.
    • unboxed

      public StructType unboxed()
      Updates the field type to the primitive one.
      Specified by:
      unboxed in interface DataType
      Returns:
      the new struct with primitive field types.
    • 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()
      Overrides:
      toString in class 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)
      Overrides:
      equals in class Object