EntityGrouping

class EntityGrouping<E : Any, T : BaseTable<E>, K : Any>(val sequence: EntitySequence<E, T>, val keySelector: (T) -> ColumnDeclaring<K>)(source)

Wraps an EntitySequence with a keySelector function, which can be applied to each record to get its key, or used as the group by clause of the generated SQL.

An EntityGrouping structure serves as an intermediate step in group-and-fold operations: they group elements by their keys and then fold each group with some aggregation operation.

Entity groups are created by attaching keySelector: (T) -> ColumnDeclaring<K> function to an entity sequence. To get an instance of EntityGrouping, use the extension function EntitySequence.groupingBy.

For the list of group-and-fold operations available, see the extension functions below.

Constructors

Link copied to clipboard
constructor(sequence: EntitySequence<E, T>, keySelector: (T) -> ColumnDeclaring<K>)

Properties

Link copied to clipboard

a function used to extract the key of a record in the source table.

Link copied to clipboard

the source entity sequence of this grouping.

Functions

Link copied to clipboard
inline fun <E : Any, K : Any, R> EntityGrouping<E, *, K>.aggregate(operation: (key: K?, accumulator: R?, element: E, first: Boolean) -> R): Map<K?, R>

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map.

Link copied to clipboard
@JvmName(name = "_aggregateColumns2")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple2<ColumnDeclaring<C1>, ColumnDeclaring<C2>>): Map<K?, Tuple2<C1?, C2?>>
@JvmName(name = "_aggregateColumns3")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple3<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>>): Map<K?, Tuple3<C1?, C2?, C3?>>
@JvmName(name = "_aggregateColumns4")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple4<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>>): Map<K?, Tuple4<C1?, C2?, C3?, C4?>>
@JvmName(name = "_aggregateColumns5")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple5<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>>): Map<K?, Tuple5<C1?, C2?, C3?, C4?, C5?>>
@JvmName(name = "_aggregateColumns6")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple6<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>>): Map<K?, Tuple6<C1?, C2?, C3?, C4?, C5?, C6?>>
@JvmName(name = "_aggregateColumns7")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple7<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>>): Map<K?, Tuple7<C1?, C2?, C3?, C4?, C5?, C6?, C7?>>
@JvmName(name = "_aggregateColumns8")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple8<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>>): Map<K?, Tuple8<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?>>
@JvmName(name = "_aggregateColumns9")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, C9 : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> Tuple9<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>, ColumnDeclaring<C9>>): Map<K?, Tuple9<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?>>

Group elements from the source sequence by key and perform the given aggregations for elements in each group, then store the results in a new Map.

inline fun <E : Any, T : BaseTable<E>, K : Any, C : Any> EntityGrouping<E, T, K>.aggregateColumns(aggregationSelector: (T) -> ColumnDeclaring<C>): Map<K?, C?>

Group elements from the source sequence by key and perform the given aggregation for elements in each group, then store the results in a new Map.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Any, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> ColumnDeclaring<C>): M

Group elements from the source sequence by key and perform the given aggregation for elements in each group, then store the results in the destination map.

@JvmName(name = "_aggregateColumns2To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, M : MutableMap<in K?, in Tuple2<C1?, C2?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple2<ColumnDeclaring<C1>, ColumnDeclaring<C2>>): M
@JvmName(name = "_aggregateColumns3To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, M : MutableMap<in K?, in Tuple3<C1?, C2?, C3?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple3<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>>): M
@JvmName(name = "_aggregateColumns4To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, M : MutableMap<in K?, in Tuple4<C1?, C2?, C3?, C4?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple4<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>>): M
@JvmName(name = "_aggregateColumns5To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, M : MutableMap<in K?, in Tuple5<C1?, C2?, C3?, C4?, C5?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple5<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>>): M
@JvmName(name = "_aggregateColumns6To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, M : MutableMap<in K?, in Tuple6<C1?, C2?, C3?, C4?, C5?, C6?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple6<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>>): M
@JvmName(name = "_aggregateColumns7To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, M : MutableMap<in K?, in Tuple7<C1?, C2?, C3?, C4?, C5?, C6?, C7?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple7<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>>): M
@JvmName(name = "_aggregateColumns8To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, M : MutableMap<in K?, in Tuple8<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple8<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>>): M
@JvmName(name = "_aggregateColumns9To")
inline fun <E : Any, T : BaseTable<E>, K : Any, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, C9 : Any, M : MutableMap<in K?, in Tuple9<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?>>> EntityGrouping<E, T, K>.aggregateColumnsTo(destination: M, aggregationSelector: (T) -> Tuple9<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>, ColumnDeclaring<C9>>): M

Group elements from the source sequence by key and perform the given aggregations for elements in each group, then store the results in the destination map.

Link copied to clipboard
inline fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, *, K>.aggregateTo(destination: M, operation: (key: K?, accumulator: R?, element: E, first: Boolean) -> R): M

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map.

Link copied to clipboard

Create a kotlin.collections.Grouping instance that wraps this original entity grouping returning all the elements in the source sequence when being iterated.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any> EntityGrouping<E, T, K>.eachAverageBy(columnSelector: (T) -> ColumnDeclaring<out Number>): Map<K?, Double?>

Group elements from the source sequence by key and average the columns or expressions provided by the columnSelector function for elements in each group.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, M : MutableMap<in K?, in Double?>> EntityGrouping<E, T, K>.eachAverageByTo(destination: M, columnSelector: (T) -> ColumnDeclaring<out Number>): M

Group elements from the source sequence by key and average the columns or expressions provided by the columnSelector function for elements in each group, then store the results in the destination map.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>, K : Any> EntityGrouping<E, T, K>.eachCount(): Map<K?, Int>

Group elements from the source sequence by key and count elements in each group.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>, K : Any, M : MutableMap<in K?, Int>> EntityGrouping<E, T, K>.eachCountTo(destination: M): M

Group elements from the source sequence by key and count elements in each group, then store the results in the destination map.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>> EntityGrouping<E, T, K>.eachMaxBy(columnSelector: (T) -> ColumnDeclaring<C>): Map<K?, C?>

Group elements from the source sequence by key and get the max value of the columns or expressions provided by the columnSelector function for elements in each group.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.eachMaxByTo(destination: M, columnSelector: (T) -> ColumnDeclaring<C>): M

Group elements from the source sequence by key and get the max value of the columns or expressions provided by the columnSelector function for elements in each group, then store the results in the destination map.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>> EntityGrouping<E, T, K>.eachMinBy(columnSelector: (T) -> ColumnDeclaring<C>): Map<K?, C?>

Group elements from the source sequence by key and get the min value of the columns or expressions provided by the columnSelector function for elements in each group.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.eachMinByTo(destination: M, columnSelector: (T) -> ColumnDeclaring<C>): M

Group elements from the source sequence by key and get the min value of the columns or expressions provided by the columnSelector function for elements in each group, then store the results in the destination map.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Number> EntityGrouping<E, T, K>.eachSumBy(columnSelector: (T) -> ColumnDeclaring<C>): Map<K?, C?>

Group elements from the source sequence by key and sum the columns or expressions provided by the columnSelector function for elements in each group.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>, K : Any, C : Number, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.eachSumByTo(destination: M, columnSelector: (T) -> ColumnDeclaring<C>): M

Group elements from the source sequence by key and sum the columns or expressions provided by the columnSelector function for elements in each group, then store the results in the destination map.

Link copied to clipboard
inline fun <E : Any, K : Any, R> EntityGrouping<E, *, K>.fold(initialValue: R, operation: (accumulator: R, element: E) -> R): Map<K?, R>

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the same initialValue for each group.

inline fun <E : Any, K : Any, R> EntityGrouping<E, *, K>.fold(initialValueSelector: (key: K?, element: E) -> R, operation: (key: K?, accumulator: R, element: E) -> R): Map<K?, R>

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is provided by initialValueSelector function.

Link copied to clipboard
inline fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, *, K>.foldTo(destination: M, initialValue: R, operation: (accumulator: R, element: E) -> R): M

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map. An initial value of accumulator is the same initialValue for each group.

inline fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, *, K>.foldTo(destination: M, initialValueSelector: (key: K?, element: E) -> R, operation: (key: K?, accumulator: R, element: E) -> R): M

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map. An initial value of accumulator is provided by initialValueSelector function.

Link copied to clipboard
inline fun <E : Any, K : Any> EntityGrouping<E, *, K>.reduce(operation: (key: K?, accumulator: E, element: E) -> E): Map<K?, E>

Groups elements from the source sequence by key and applies the reducing operation to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the first element of the group.

Link copied to clipboard
inline fun <E : Any, K : Any, M : MutableMap<in K?, E>> EntityGrouping<E, *, K>.reduceTo(destination: M, operation: (key: K?, accumulator: E, element: E) -> E): M

Groups elements from the source sequence by key and applies the reducing operation to the elements of each group sequentially starting from the second element of the group, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map. An initial value of accumulator is the first element of the group.