Package smile.data.type
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface smile.data.type.DataType
DataType.ID
-
Constructor Summary
ConstructorsConstructorDescriptionStructType
(List<StructField> fields) Constructor.StructType
(List<StructField> fields, Map<String, Integer> index) Creates an instance of aStructType
record class.StructType
(StructField... fields) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(StructField field) Adds a field.apply
(int i) Return the i-th field.Return the field of given name.DataType[]
dtypes()
Returns the field data types.boolean
Indicates whether some other object is "equal to" this one.field
(int i) Return the i-th field.Return the field of given name.fields()
Returns the value of thefields
record component.final int
hashCode()
Returns a hash code value for this object.id()
Returns the type ID enum.index()
Returns the value of theindex
record component.int
Returns the ordinal index of a field.int
length()
Returns the number of fields.Measure[]
measures()
Returns the field's level of measurements.name()
Returns the type name used in external catalogs.String[]
names()
Returns the field names.static StructType
Returns the struct type of record or bean class.static StructType
Returns a struct data type from JDBC result set meta data.static StructType
of
(ResultSetMetaData meta, String dbms) Returns a struct data type from JDBC result set meta data.static StructType
Returns the struct type of record or bean class properties.static StructType
of
(ValueVector... columns) Returns the schema of a set of columns.parser()
Returns the lambda functions that parse field values.void
Renames a field.void
set
(int i, StructField field) Sets a field.toString()
Returns a string representation of this record class.Returns the string representation of a value of the type.void
update
(int i, StructField field) Sets a field.Returns the value from its string representation.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface smile.data.type.DataType
isBoolean, isByte, isChar, isDecimal, isDouble, isFloat, isFloating, isInt, isIntegral, isLong, isNullable, isNumeric, isObject, isPrimitive, isShort, isString
-
Constructor Details
-
StructType
Constructor.- Parameters:
fields
- the struct fields.
-
StructType
Constructor.- Parameters:
fields
- the struct fields.
-
StructType
Creates an instance of aStructType
record class.
-
-
Method Details
-
of
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
Return the i-th field.- Parameters:
i
- the field index.- Returns:
- the field.
-
field
Return the field of given name.- Parameters:
name
- the field name.- Returns:
- the field.
-
apply
Return the i-th field. This is an alias tofield
for Scala's convenience.- Parameters:
i
- the field index.- Returns:
- the field.
-
apply
Return the field of given name. This is an alias tofield
for Scala's convenience.- Parameters:
name
- the field name.- Returns:
- the field.
-
set
Sets a field.- Parameters:
i
- the field index.field
- the new field.
-
update
Sets a field. This is an alias toset
for Scala's convenience.- Parameters:
i
- the field index.field
- the new field.
-
rename
Renames a field.- Parameters:
name
- the field name.newName
- the new name.
-
add
Adds a field.- Parameters:
field
- a struct field.
-
indexOf
Returns the ordinal index of a field.- Parameters:
field
- the field name.- Returns:
- the index of field.
-
names
Returns the field names.- Returns:
- the field names.
-
dtypes
Returns the field data types.- Returns:
- the field data types.
-
measures
Returns the field's level of measurements.- Returns:
- the field's level of measurements.
-
parser
Returns the lambda functions that parse field values.- Returns:
- the lambda functions that parse field values.
-
name
Description copied from interface:DataType
Returns the type name used in external catalogs. DataType.of(name()) should return the same type. -
id
Description copied from interface:DataType
Returns the type ID enum. -
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. -
toString
Description copied from interface:DataType
Returns the string representation of a value of the type. -
valueOf
Description copied from interface:DataType
Returns the value from its string representation. -
equals
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 withObjects::equals(Object,Object)
. -
of
Returns the struct type of record or bean class.- Parameters:
clazz
- the class type of elements.- Returns:
- the struct type.
-
of
Returns the struct type of record or bean class properties.- Parameters:
props
- the record or bean class properties.- Returns:
- the struct type.
-
of
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
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. -
fields
Returns the value of thefields
record component.- Returns:
- the value of the
fields
record component
-
index
Returns the value of theindex
record component.- Returns:
- the value of the
index
record component
-