Package org.h2.expression.aggregate
Class Percentile
java.lang.Object
org.h2.expression.aggregate.Percentile
PERCENTILE_CONT, PERCENTILE_DISC, and MEDIAN inverse distribution functions.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final BigDecimal
BigDecimal value of 0.5. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Index
getColumnIndex
(Database database, Expression on) Get the index (if any) for the column specified in the inverse distribution function.(package private) static Value
getFromIndex
(SessionLocal session, Expression expression, int dataType, ArrayList<QueryOrderBy> orderByList, BigDecimal percentile, boolean interpolate) Get the result from the index.(package private) static Value
getValue
(SessionLocal session, Value[] array, int dataType, ArrayList<QueryOrderBy> orderByList, BigDecimal percentile, boolean interpolate) Get the result from the array of values.private static Value
interpolate
(Value v0, Value v1, BigDecimal factor, int dataType, SessionLocal session, CompareMode compareMode) private static BigDecimal
interpolateDecimal
(BigDecimal d0, BigDecimal d1, BigDecimal factor) private static boolean
isNullsLast
(DefaultNullOrdering defaultNullOrdering, Index index) private static BigDecimal
timestampToDecimal
(long dateValue, long timeNanos)
-
Field Details
-
HALF
BigDecimal value of 0.5.
-
-
Constructor Details
-
Percentile
private Percentile()
-
-
Method Details
-
isNullsLast
-
getColumnIndex
Get the index (if any) for the column specified in the inverse distribution function.- Parameters:
database
- the databaseon
- 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 sessionarray
- array with valuesdataType
- the data typeorderByList
- ORDER BY listpercentile
- argument of percentile function, or 0.5d for medianinterpolate
- 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 sessionexpression
- the expressiondataType
- the data typeorderByList
- ORDER BY listpercentile
- argument of percentile function, or 0.5d for medianinterpolate
- 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
-
interpolateDecimal
-