Class SparkRowTuple

java.lang.Object
smile.spark.SparkRowTuple
All Implemented Interfaces:
Serializable, Tuple

public class SparkRowTuple extends Object implements Tuple
An adapter wrapping an Apache Spark Row as a SMILE Tuple.
See Also:
  • Constructor Details

    • SparkRowTuple

      public SparkRowTuple(StructType schema, org.apache.spark.sql.Row row)
      Constructor.
      Parameters:
      schema - the SMILE schema.
      row - the Spark row.
  • Method Details

    • schema

      public StructType schema()
      Description copied from interface: Tuple
      Returns the schema of tuple.
      Specified by:
      schema in interface Tuple
      Returns:
      the schema of tuple.
    • length

      public int length()
      Description copied from interface: Tuple
      Returns the number of elements in the Tuple.
      Specified by:
      length in interface Tuple
      Returns:
      the number of elements in the Tuple.
    • indexOf

      public int indexOf(String name)
      Description copied from interface: Tuple
      Returns the index of a given field name.
      Specified by:
      indexOf in interface Tuple
      Parameters:
      name - the name of field.
      Returns:
      the field index.
    • isNullAt

      public boolean isNullAt(int i)
      Description copied from interface: Tuple
      Checks whether the value at the given position is null.
      Specified by:
      isNullAt in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      true if the field value is null.
    • get

      public Object get(int i)
      Description copied from interface: Tuple
      Returns the value at position i. The value may be null.
      Specified by:
      get in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getBoolean

      public boolean getBoolean(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive boolean.
      Specified by:
      getBoolean in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getByte

      public byte getByte(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive byte.
      Specified by:
      getByte in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getShort

      public short getShort(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive short.
      Specified by:
      getShort in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getInt

      public int getInt(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive int.
      Specified by:
      getInt in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getLong

      public long getLong(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive long.
      Specified by:
      getLong in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getFloat

      public float getFloat(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive float. Throws an exception if the type mismatches or if the value is null.
      Specified by:
      getFloat in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getDouble

      public double getDouble(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a primitive double.
      Specified by:
      getDouble in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getDecimal

      public BigDecimal getDecimal(int i)
      Description copied from interface: Tuple
      Returns the value at position i of decimal type as java.math.BigDecimal.
      Specified by:
      getDecimal in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getString

      public String getString(int i)
      Description copied from interface: Tuple
      Returns the value at position i as a String object.
      Specified by:
      getString in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getDate

      public LocalDate getDate(int i)
      Description copied from interface: Tuple
      Returns the value at position i of date type as java.time.LocalDate.
      Specified by:
      getDate in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getDateTime

      public LocalDateTime getDateTime(int i)
      Description copied from interface: Tuple
      Returns the value at position i of date type as java.time.LocalDateTime.
      Specified by:
      getDateTime in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getTime

      public LocalTime getTime(int i)
      Description copied from interface: Tuple
      Returns the value at position i of date type as java.time.LocalTime.
      Specified by:
      getTime in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getStruct

      public Tuple getStruct(int i)
      Description copied from interface: Tuple
      Returns the value at position i of struct type.
      Specified by:
      getStruct in interface Tuple
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • getArray

      public <T> T[] getArray(int i)
      Description copied from interface: Tuple
      Returns the value at position i of array type.
      Specified by:
      getArray in interface Tuple
      Type Parameters:
      T - the data type of array elements.
      Parameters:
      i - the index of field.
      Returns:
      the field value.
    • row

      public org.apache.spark.sql.Row row()
      Returns the underlying Spark Row.
      Returns:
      the Spark row.