Class WindowExpressions
- java.lang.Object
-
- dev.morphia.aggregation.expressions.WindowExpressions
-
public final class WindowExpressions extends Object
Provides window specific operations.- Since:
- 2.3
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ExpressioncovariancePop(Expression first, Expression second)Returns the population covariance of two numeric expressions that are evaluated using documents in the $setWindowFields stage window.static ExpressioncovarianceSamp(Expression first, Expression second)Returns the sample covariance of two numeric expressions that are evaluated using documents in the $setWindowFields stage window.static ExpressiondenseRank()Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.static CalculusExpressionderivative(Expression input)Returns the average rate of change within the specified window.static ExpressiondocumentNumber()Returns the position of a document (known as the document number) in the $setWindowFields stage partition.static ExpressionexpMovingAvg(Expression input, int n)Returns the exponential moving average of numeric expressions applied to documents in a partition defined in the $setWindowFields stage.static CalculusExpressionintegral(Expression input)Returns the approximation of the area under a curve, which is calculated using the trapezoidal rule where each set of adjacent documents form a trapezoid using the:static ExpressionlinearFill(Expression fillValue)Fills null and missing fields in a window using linear interpolation based on surrounding field values.static Expressionlocf(Expression fillValue)Last observation carried forward.static Expressionrank()Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.static ShiftExpressionshift(Expression output, long by, Expression defaultValue)Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition.static ExpressionstdDevPop(Expression value, Expression... additional)Returns the population standard deviation of the input values.static ExpressionstdDevSamp(Expression value, Expression... additional)Returns the sample standard deviation of the input values.
-
-
-
Method Detail
-
covariancePop
public static Expression covariancePop(Expression first, Expression second)
Returns the population covariance of two numeric expressions that are evaluated using documents in the $setWindowFields stage window.$covariancePop is only available in the $setWindowFields stage.
- Parameters:
first- the first expression to evaluatesecond- the second expression to evaluate- Returns:
- the new expression
- Since:
- 2.3
- See Also:
Aggregation.setWindowFields(SetWindowFields)- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $covariancePop
-
covarianceSamp
public static Expression covarianceSamp(Expression first, Expression second)
Returns the sample covariance of two numeric expressions that are evaluated using documents in the $setWindowFields stage window.$covarianceSamp is only available in the $setWindowFields stage.
- Parameters:
first- the first expression to evaluatesecond- the second expression to evaluate- Returns:
- the new expression
- Since:
- 2.3
- See Also:
Aggregation.setWindowFields(SetWindowFields)- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $covarianceSamp
-
denseRank
public static Expression denseRank()
Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.- Returns:
- the expression
- Since:
- 2.3
- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $denseRank
-
derivative
public static CalculusExpression derivative(Expression input)
Returns the average rate of change within the specified window.- Parameters:
input- Specifies the expression to evaluate. The expression must evaluate to a number.- Returns:
- the new expression
- Since:
- 2.3
- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $derivative
-
documentNumber
public static Expression documentNumber()
Returns the position of a document (known as the document number) in the $setWindowFields stage partition.- Returns:
- the new expression
- Since:
- 2.3
- See Also:
Aggregation.setWindowFields(SetWindowFields)- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $documentNumber
-
expMovingAvg
public static Expression expMovingAvg(Expression input, int n)
Returns the exponential moving average of numeric expressions applied to documents in a partition defined in the $setWindowFields stage.$expMovingAvg is only available in the $setWindowFields stage.
- Parameters:
input- Specifies the expression to evaluate. Non-numeric expressions are ignored.n- An integer that specifies the number of historical documents that have a significant mathematical weight in the exponential moving average calculation, with the most recent documents contributing the most weight.- Returns:
- the new expression
- Since:
- 2.3
- See Also:
Aggregation.setWindowFields(SetWindowFields)- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $expMovingAvg
-
integral
public static CalculusExpression integral(Expression input)
Returns the approximation of the area under a curve, which is calculated using the trapezoidal rule where each set of adjacent documents form a trapezoid using the:- Parameters:
input- Specifies the expression to evaluate. The expression must evaluate to a number.- Returns:
- the new expression
- Since:
- 2.3
- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $integral
-
linearFill
public static Expression linearFill(Expression fillValue)
Fills null and missing fields in a window using linear interpolation based on surrounding field values.$linearFill is only available in the $setWindowFields stage.
- Parameters:
fillValue- the expression to use when calculating fill values- Returns:
- the fill expression
- Since:
- 2.3
- Since server release
- 5.3
- MongoDB documentation
- Aggregration Expression: $linearFill
-
locf
public static Expression locf(Expression fillValue)
Last observation carried forward. Set values for null and missing fields in a window to the last non-null value for the field.- Parameters:
fillValue- the expression to use when calculating fill values- Returns:
- the fill expression
- Since:
- 2.3
- Since server release
- 5.2
- MongoDB documentation
- Aggregration Expression: $locf
-
rank
public static Expression rank()
Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.- Returns:
- the new expression
- Since:
- 2.3
- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $rank
-
shift
public static ShiftExpression shift(Expression output, long by, Expression defaultValue)
Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition.- Parameters:
output- Specifies an expression to evaluate and return in the output.by- Specifies an integer with a numeric document position relative to the current document in the output.defaultValue- Specifies an optional default expression to evaluate if the document position is outside of the implicit $setWindowFields stage window. The implicit window contains all the documents in the partition.- Returns:
- the expression
- Since:
- 2.3
- See Also:
Aggregation.setWindowFields(SetWindowFields)- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $shift
-
stdDevPop
public static Expression stdDevPop(Expression value, Expression... additional)
Returns the population standard deviation of the input values.- Parameters:
value- the valueadditional- any subsequent expressions to include in the expression- Returns:
- the new expression
- Since:
- 2.3
- MongoDB documentation
- Aggregration Expression: $stdDevPop
-
stdDevSamp
public static Expression stdDevSamp(Expression value, Expression... additional)
Returns the sample standard deviation of the input values.- Parameters:
value- the valueadditional- any subsequent expressions to include in the expression- Returns:
- the new expression
- Since:
- 2.3
- MongoDB documentation
- Aggregration Expression: $stdDevSamp
-
-