Class Percentile

java.lang.Object
org.h2.expression.aggregate.Percentile

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

    • HALF

      static final BigDecimal HALF
      BigDecimal value of 0.5.
  • Constructor Details

    • Percentile

      private Percentile()
  • Method Details

    • isNullsLast

      private static boolean isNullsLast(DefaultNullOrdering defaultNullOrdering, Index index)
    • 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, ArrayList<QueryOrderBy> orderByList, 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, ArrayList<QueryOrderBy> orderByList, 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
    • interpolate

      private static Value interpolate(Value v0, Value v1, BigDecimal factor, int dataType, SessionLocal session, CompareMode compareMode)
    • timestampToDecimal

      private static BigDecimal timestampToDecimal(long dateValue, long timeNanos)
    • interpolateDecimal

      private static BigDecimal interpolateDecimal(BigDecimal d0, BigDecimal d1, BigDecimal factor)