com.lightningkite.lightningdb.aggregateExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-core Show documentation
Show all versions of server-core Show documentation
A set of tools to fill in/replace what Ktor is lacking in.
The newest version!
package com.lightningkite.lightningdb
import com.lightningkite.khrysalis.IsHashable
/**
* Runs an aggregation directly on the system.
* Used for testing and aggregating in the RAM test database.
*/
fun Sequence>.aggregate(aggregate: Aggregate): Map {
val aggregators = HashMap()
for (entry in this) {
aggregators.getOrPut(entry.first) { aggregate.aggregator() }.consume(entry.second)
}
return aggregators.mapValues { it.value.complete() }
}