Class Percentile


  • final class Percentile
    extends java.lang.Object
    PERCENTILE_CONT, PERCENTILE_DISC, and MEDIAN inverse distribution functions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.math.BigDecimal HALF
      BigDecimal value of 0.5.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Percentile()  
    • Field Detail

      • HALF

        static final java.math.BigDecimal HALF
        BigDecimal value of 0.5.
    • Constructor Detail

      • Percentile

        private Percentile()
    • Method Detail

      • getColumnIndex

        static Index getColumnIndex​(Database database,
                                    Expression on)
        Get the index (if any) for the column specified in the inverse distribution function.
        Parameters:
        database - the database
        on - the expression (usually a column expression)
        Returns:
        the index, or null
      • getValue

        static Value getValue​(SessionLocal session,
                              Value[] array,
                              int dataType,
                              java.util.ArrayList<QueryOrderBy> orderByList,
                              java.math.BigDecimal percentile,
                              boolean interpolate)
        Get the result from the array of values.
        Parameters:
        session - the session
        array - array with values
        dataType - the data type
        orderByList - ORDER BY list
        percentile - argument of percentile function, or 0.5d for median
        interpolate - whether value should be interpolated
        Returns:
        the result
      • getFromIndex

        static Value getFromIndex​(SessionLocal session,
                                  Expression expression,
                                  int dataType,
                                  java.util.ArrayList<QueryOrderBy> orderByList,
                                  java.math.BigDecimal percentile,
                                  boolean interpolate)
        Get the result from the index.
        Parameters:
        session - the session
        expression - the expression
        dataType - the data type
        orderByList - ORDER BY list
        percentile - argument of percentile function, or 0.5d for median
        interpolate - whether value should be interpolated
        Returns:
        the result
      • timestampToDecimal

        private static java.math.BigDecimal timestampToDecimal​(long dateValue,
                                                               long timeNanos)
      • interpolateDecimal

        private static java.math.BigDecimal interpolateDecimal​(java.math.BigDecimal d0,
                                                               java.math.BigDecimal d1,
                                                               java.math.BigDecimal factor)