Class AccumulatorExpressions
- java.lang.Object
-
- dev.morphia.aggregation.experimental.expressions.AccumulatorExpressions
-
public final class AccumulatorExpressions extends Object
Defines helper methods for accumulator expressions- Since:
- 2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AccumulatorExpression
accumulator(String initFunction, String accumulateFunction, List<Expression> accumulateArgs, String mergeFunction)
Returns an array of unique expression values for each group.static Expression
addToSet(Expression value)
Returns an array of unique expression values for each group.static Expression
avg(Expression value, Expression... additional)
Returns an average of numerical values.static Expression
first(Expression value)
Returns a value from the first document for each group.static Expression
function(String body, Expression... args)
Defines a custom aggregation function or expression in JavaScript.static Expression
last(Expression value)
Returns a value from the last document for each group.static Expression
max(Expression value)
Returns the highest expression value for each group.static Expression
min(Expression value)
Returns the lowest expression value for each group.static Push
push()
Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.static Expression
push(Expression value)
Returns an array of expression values for each group.static Expression
stdDevPop(Expression value, Expression... additional)
Returns the population standard deviation of the input values.static Expression
stdDevSamp(Expression value, Expression... additional)
Returns the sample standard deviation of the input values.static Expression
sum(Expression first, Expression... additional)
Calculates and returns the sum of numeric values.
-
-
-
Method Detail
-
accumulator
public static AccumulatorExpression accumulator(String initFunction, String accumulateFunction, List<Expression> accumulateArgs, String mergeFunction)
Returns an array of unique expression values for each group. Order of the array elements is undefined.- Parameters:
initFunction
- used to initialize the state. The init function receives its arguments from the initArgs expression.accumulateFunction
- used to accumulate documents. The accumulate function receives its arguments from the current state and accumulateArgs array expression.accumulateArgs
- Arguments passed to the accumulate function.mergeFunction
- used to merge two internal states.- Returns:
- the new expression
- Since:
- 2.1
- MongoDB documentation
- Aggregration Expression: $accumulator
-
addToSet
public static Expression addToSet(Expression value)
Returns an array of unique expression values for each group. Order of the array elements is undefined.- Parameters:
value
- the value- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $addToSet
-
avg
public static Expression avg(Expression value, Expression... additional)
Returns an average of numerical values. Ignores non-numeric values.- Parameters:
value
- the valueadditional
- any subsequent expressions to include in the expression- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $avg
-
first
public static Expression first(Expression value)
Returns a value from the first document for each group. Order is only defined if the documents are in a defined order.- Parameters:
value
- the value- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $first
-
function
public static Expression function(String body, Expression... args)
Defines a custom aggregation function or expression in JavaScript.- Parameters:
body
- the function bodyargs
- the function arguments- Returns:
- the new expression
- Since:
- 2.1
- MongoDB documentation
- Aggregration Expression: $function
-
last
public static Expression last(Expression value)
Returns a value from the last document for each group. Order is only defined if the documents are in a defined order.- Parameters:
value
- the value- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $last
-
max
public static Expression max(Expression value)
Returns the highest expression value for each group.- Parameters:
value
- the value- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $max
-
min
public static Expression min(Expression value)
Returns the lowest expression value for each group.- Parameters:
value
- the value- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $min
-
push
public static Expression push(Expression value)
Returns an array of expression values for each group.- Parameters:
value
- the value- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $push
-
push
public static Push push()
Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.$push is only available in the $group stage.
- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $push
-
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
- 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
- MongoDB documentation
- Aggregration Expression: $stdDevSamp
-
sum
public static Expression sum(Expression first, Expression... additional)
Calculates and returns the sum of numeric values. $sum ignores non-numeric values.- Parameters:
first
- the first expression to sumadditional
- any subsequent expressions to include in the sum- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $sum
-
-