Class JavaUserDefinedUntypedAggregation.MyAverage

  • All Implemented Interfaces:
    java.io.Serializable, scala.Serializable
    Enclosing class:
    JavaUserDefinedUntypedAggregation

    public static final class JavaUserDefinedUntypedAggregation.MyAverage
    extends org.apache.spark.sql.expressions.UserDefinedAggregateFunction
    MyAverage class.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      MyAverage()
      Public constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.spark.sql.types.StructType bufferSchema()
      Data types of values in the aggregation buffer.
      org.apache.spark.sql.types.DataType dataType()
      The data type of the returned value.
      boolean deterministic()
      Whether this function always returns the same output on the identical input.
      java.lang.Double evaluate​(org.apache.spark.sql.Row buffer)
      Calculates the final result.
      void initialize​(org.apache.spark.sql.expressions.MutableAggregationBuffer buffer)
      Initializes the given aggregation buffer.
      org.apache.spark.sql.types.StructType inputSchema()
      Data types of input arguments of this aggregate function.
      void merge​(org.apache.spark.sql.expressions.MutableAggregationBuffer buffer1, org.apache.spark.sql.Row buffer2)
      Merges two aggregation buffers and stores the updated buffer values back to `buffer1`.
      void update​(org.apache.spark.sql.expressions.MutableAggregationBuffer buffer, org.apache.spark.sql.Row input)
      Updates the given aggregation buffer `buffer` with new input data from `input`.
      • Methods inherited from class org.apache.spark.sql.expressions.UserDefinedAggregateFunction

        apply, apply, distinct, distinct
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MyAverage

        public MyAverage()
        Public constructor.
    • Method Detail

      • inputSchema

        public org.apache.spark.sql.types.StructType inputSchema()
        Data types of input arguments of this aggregate function.
        Specified by:
        inputSchema in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Returns:
        input schema.
      • bufferSchema

        public org.apache.spark.sql.types.StructType bufferSchema()
        Data types of values in the aggregation buffer.
        Specified by:
        bufferSchema in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Returns:
        buffer schema.
      • dataType

        public org.apache.spark.sql.types.DataType dataType()
        The data type of the returned value.
        Specified by:
        dataType in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Returns:
        double type.
      • deterministic

        public boolean deterministic()
        Whether this function always returns the same output on the identical input.
        Specified by:
        deterministic in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Returns:
        true.
      • initialize

        public void initialize​(org.apache.spark.sql.expressions.MutableAggregationBuffer buffer)
        Initializes the given aggregation buffer. The buffer itself is a `Row` that in addition to standard methods like retrieving a value at an index (e.g., get(), getBoolean()), provides the opportunity to update its values. Note that arrays and maps inside the buffer are still immutable.
        Specified by:
        initialize in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Parameters:
        buffer - buffer to initialize.
      • update

        public void update​(org.apache.spark.sql.expressions.MutableAggregationBuffer buffer,
                           org.apache.spark.sql.Row input)
        Updates the given aggregation buffer `buffer` with new input data from `input`.
        Specified by:
        update in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Parameters:
        buffer - buffer to update.
        input - input to update with.
      • merge

        public void merge​(org.apache.spark.sql.expressions.MutableAggregationBuffer buffer1,
                          org.apache.spark.sql.Row buffer2)
        Merges two aggregation buffers and stores the updated buffer values back to `buffer1`.
        Specified by:
        merge in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Parameters:
        buffer1 - first buffer.
        buffer2 - second buffer.
      • evaluate

        public java.lang.Double evaluate​(org.apache.spark.sql.Row buffer)
        Calculates the final result.
        Specified by:
        evaluate in class org.apache.spark.sql.expressions.UserDefinedAggregateFunction
        Parameters:
        buffer - buffer row.
        Returns:
        the result.