ArithmeticValueAccumulators¶
interface ArithmeticValueAccumulators<From : Any, Into : Any> : ValueAccumulators<From, Into>
Accumulators to perform arithmetic operations.
To learn more about accumulation operators, see AccumulationOperators.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract override val context: BsonContext
The strategy used when converting from KProperty1 to Field.
field¶
Converts a Kotlin property into a Field.
Functions¶
accept¶
Adds a new node as a child of this one.
acceptAll¶
Adds any number of nodes into this one.
average¶
Calculates and returns the collective average of numeric values. Non-numeric values are ignored.
If all elements are non-numeric, null is returned.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val totalBalance: Int,
)
users.aggregate()
.group {
Result::totalBalance average of(User::balance)
}
External resources¶
Calculates and returns the collective average of numeric values. Non-numeric values are ignored.
If all elements are non-numeric, null is returned.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val totalBalance: Int,
)
users.aggregate()
.group {
Result::totalBalance average of(User::balance)
}
External resources¶
div¶
Refers to field as a nested field of the current value.
Refers to field as a nested field of the current value.
Refers to child as a nested field of the current field.
Refers to child as a nested field of the current field.
Refers to child as a nested field of the current field.
freeze¶
@LowLevelApi
abstract override fun freeze()
Makes this expression immutable.
get¶
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
median¶
Returns an approximation of the median, the 50th percentile, as a scalar value.
The median is computed with the t-digest algorithm, which computes an approximation. The result may vary, even on the same dataset.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val medianBalance: Double,
)
users.aggregate()
.group {
Result::medianBalance median of(User::balance)
}
External resources¶
Returns an approximation of the median, the 50th percentile, as a scalar value.
The median is computed with the t-digest algorithm, which computes an approximation. The result may vary, even on the same dataset.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val medianBalance: Double,
)
users.aggregate()
.group {
Result::medianBalance median of(User::balance)
}
External resources¶
of¶
Refers to a Kotlin value within an aggregation value.
Refers to a field within an aggregation value.
Refers to a BsonType within an aggregation value.
Refers to a field within an aggregation value.
percentiles¶
Returns an approximation of the specified percentiles.
Each percentile is computed with the t-digest algorithm, which computes an approximation. The results may vary, even on the same dataset.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val percentiles: List<Double>,
)
users.aggregate()
.group {
Result::percentiles.percentiles(of(User::balance), 0.5, 0.75, 0.9, 0.95)
}
External resources¶
Returns an approximation of the specified percentiles.
Each percentile is computed with the t-digest algorithm, which computes an approximation. The results may vary, even on the same dataset.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val percentiles: List<Double>,
)
users.aggregate()
.group {
Result::percentiles.percentiles(of(User::balance), 0.5, 0.75, 0.9, 0.95)
}
External resources¶
simplify¶
Returns a simplified (but equivalent) expression to the current expression.
sum¶
Calculates and returns the collective sum of numeric values. Non-numeric values are ignored.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val totalBalance: Int,
)
users.aggregate()
.group {
Result::totalBalance sum of(User::balance)
}
External resources¶
Calculates and returns the collective sum of numeric values. Non-numeric values are ignored.
Example¶
class User(
val name: String,
val balance: Int,
)
class Result(
val totalBalance: Int,
)
users.aggregate()
.group {
Result::totalBalance sum of(User::balance)
}
External resources¶
toBson¶
Writes the result of simplifying to a new BSON document.
unsafe¶
Refers to a field child of the current field, with no compile-time safety.
open infix fun <Root, Child> KProperty1<Root, *>.unsafe(child: KProperty1<*, Child>): Field<Root, Child>
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, with no compile-time safety.
writeTo¶
@LowLevelApi
abstract override fun writeTo(writer: BsonFieldWriter)
Writes the result of simplifying this expression into writer.