Class StructType

    • Constructor Detail

      • StructType

        public StructType​(StructType other)
        Clones the given StructType object.
        Parameters:
        other - A StructType object
        Since:
        0.9.0
      • StructType

        public StructType​(StructField[] fields)
        Creates a StructType object based on the given Array of StructField.
        Parameters:
        fields - An Array of StructField
        Since:
        0.9.0
    • Method Detail

      • create

        public static StructType create​(StructField... fields)
        Creates a StructType object based on the given StructField
        Parameters:
        fields - A list of StructFields
        Returns:
        A new StructType object
        Since:
        0.9.0
      • names

        public String[] names()
        Retrieves the names of StructField.
        Returns:
        An array of String representing the names of StructFields
        Since:
        0.9.0
      • size

        public int size()
        Counts the number of StructFields in this StructType object.
        Returns:
        An int number
        Since:
        0.9.0
      • get

        public StructField get​(int index)
        Retrieves the StructField object from the given index.
        Parameters:
        index - An int number representing the index of StructField
        Returns:
        The StructField object at the given index.
        Since:
        0.9.0
      • toString

        public String toString()
        Generates a String value to represent this StructType.
        Overrides:
        toString in class DataType
        Returns:
        A String value in the format of "StructType[StructField('name', 'data type', 'nullable')...]"
        Since:
        0.9.0
      • add

        public StructType add​(StructField field)
        Creates new StructType by appending the given StructField to the end of this StructType. This function doesn't modify this StructType object, but create and return a new one.
        Parameters:
        field - The StructField object being appended.
        Returns:
        A new StructType object
        Since:
        0.9.0
      • add

        public StructType add​(String name,
                              DataType dataType,
                              boolean nullable)
        Creates new StructType by appending a new StructField with the given info to the end of this StructType. This function doesn't modify this StructType object, but create or return a new one.
        Parameters:
        name - The name of the StructField object being appended.
        dataType - The data type of the StructField object being appended.
        nullable - Whether the new StructField is nullable or not
        Returns:
        A new StructType object
        Since:
        0.9.0
      • add

        public StructType add​(String name,
                              DataType dataType)
        Creates new StructType by appending a new StructField with the given info to the end of this StructType. The new StructField is nullable. This function doesn't modify this StructType object, but create and return a new one.
        Parameters:
        name - The name of the StructField object being appended.
        dataType - The data type of the StructField object being appended.
        Returns:
        A new StructType object
        Since:
        0.9.0
      • nameToField

        public Optional<StructField> nameToField​(String name)
        Retrieves the corresponding StructField object of the given name.
        Parameters:
        name - The name of StructField
        Returns:
        An Optional StructField object.
        Since:
        0.9.0
      • equals

        public boolean equals​(Object other)
        Verifies if a StructType equals to this one.
        Overrides:
        equals in class DataType
        Parameters:
        other - A StructType object
        Returns:
        true if these data types are equivalent, false for otherwise.
        Since:
        0.9.0
      • hashCode

        public int hashCode()
        Calculates the hash code of this StructType Object.
        Overrides:
        hashCode in class DataType
        Returns:
        An int number representing the hash code value
        Since:
        0.9.0
      • printTreeString

        public void printTreeString()
        Prints the schema StructType content in a tree structure diagram.
        Since:
        0.9.0