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

    Modifier and Type
    Method
    Description
    static Expression
    covariancePop(Object first, Object second)
    Returns the population covariance of two numeric expressions that are evaluated using documents in the $setWindowFields stage window.
    static Expression
    covarianceSamp(Object first, Object second)
    Returns the sample covariance of two numeric expressions that are evaluated using documents in the $setWindowFields stage window.
    static Expression
    Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.
    Returns the average rate of change within the specified window.
    static Expression
    Returns the position of a document (known as the document number) in the $setWindowFields stage partition.
    static Expression
    expMovingAvg(Object input, double alpha)
    Returns the exponential moving average of numeric expressions applied to documents in a partition defined in the $setWindowFields stage.
    static Expression
    expMovingAvg(Object input, int n)
    Returns the exponential moving average of numeric expressions applied to documents in a partition defined in the $setWindowFields stage.
    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 Expression
    linearFill(Object fillValue)
    Fills null and missing fields in a window using linear interpolation based on surrounding field values.
    static Expression
    locf(Object fillValue)
    Last observation carried forward.
    static Expression
    Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition.
    static Expression
    shift(Object output, long by, Object 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 Expression
    stdDevPop(Object value, Object... additional)
    Returns the population standard deviation of the input values.
    static Expression
    stdDevSamp(Object value, Object... additional)
    Returns the sample standard deviation of the input values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • covariancePop

      public static Expression covariancePop(Object first, Object 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 value to evaluate
      second - the second value to evaluate
      Returns:
      the new expression
      Since:
      2.3
      See Also:
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $covariancePop
    • covarianceSamp

      public static Expression covarianceSamp(Object first, Object 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 value to evaluate
      second - the second value to evaluate
      Returns:
      the new expression
      Since:
      2.3
      See Also:
      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(Object input)
      Returns the average rate of change within the specified window.
      Parameters:
      input - Specifies the value to evaluate. If an expression, it 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:
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $documentNumber
    • expMovingAvg

      public static Expression expMovingAvg(Object 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 value 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:
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $expMovingAvg
    • expMovingAvg

      public static Expression expMovingAvg(Object input, double alpha)
      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.
      alpha - A double that specifies the exponential decay value to use in the exponential moving average calculation. A higher alpha value assigns a lower mathematical significance to previous results from the calculation.
      Returns:
      the new expression
      Since:
      2.3
      See Also:
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $expMovingAvg
    • integral

      public static CalculusExpression integral(Object 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 value to evaluate. If an expression, it 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(Object 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(Object 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 Expression shift(Object output, long by, Object 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:
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $shift
    • stdDevPop

      public static Expression stdDevPop(Object value, Object... additional)
      Returns the population standard deviation of the input values.
      Parameters:
      value - the value
      additional - any subsequent expressions to include in the expression
      Returns:
      the new expression
      Since:
      2.3
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $stdDevPop
    • stdDevSamp

      public static Expression stdDevSamp(Object value, Object... additional)
      Returns the sample standard deviation of the input values.
      Parameters:
      value - the value
      additional - any subsequent expressions to include in the expression
      Returns:
      the new expression
      Since:
      2.3
      Since server release
      5.0
      MongoDB documentation
      Aggregration Expression: $stdDevSamp