Aggregate

interface Aggregate<ID : Any>

Models the minimal set of aggregate operations. Holds the localId of the device executing the aggregate program.

Types

Link copied to clipboard
object Companion

Contains the inlined version of the Aggregate, Aggregate.exchanging, Aggregate.neighboring functions.

Link copied to clipboard

Internal API for Collektive. This API is not intended to be used directly. Use the exchanging and neighboring functions directly instead.

Properties

Link copied to clipboard
abstract val inMemoryOnly: Boolean

Whether this context works only in memory. If false, this context is capable of serializing and deserializing messages.

Link copied to clipboard
abstract val localId: ID

The local ID of the device.

Functions

Link copied to clipboard

Serialization-aware version of the exchanging function.

Link copied to clipboard

Serialization-aware version of the neighboring function.

Link copied to clipboard
abstract fun align(pivot: Any?)

Pushes the pivot in the alignment stack.

Link copied to clipboard
abstract fun <R> alignedOn(pivot: Any?, body: () -> R): R

Alignment function, which pushes in the stack the pivot, executes the body and pop the last element of the stack after it is called. Returns the body's return element.

Link copied to clipboard

Inline access to the data serialization method of an Aggregate. This method is used to avoid building serializers for in-memory-only contexts.

Link copied to clipboard
abstract fun dealign()

Pops the last element of the alignment stack.

Link copied to clipboard
abstract fun <Stored> evolve(initial: Stored, transform: (Stored) -> Stored): Stored

Iteratively updates the value computing the transform expression at each device using the last computed value or the initial.

Link copied to clipboard
abstract fun <Stored, Returned> evolving(initial: Stored, transform: YieldingScope<Stored, Returned>): Returned

Iteratively updates the value computing the transform expression from a YieldingContext at each device using the last computed value or the initial.

Link copied to clipboard
inline fun <ID : Any, Shared> Aggregate<ID>.exchange(initial: Shared, noinline body: (Field<ID, Shared>) -> Field<ID, Shared>): Field<ID, Shared>

exchange implements anisotropic data sharing (namely, the field information looks different depending on the direction from which you are observing it).

Link copied to clipboard
inline fun <ID : Any, Shared, Returned> Aggregate<ID>.exchanging(initial: Shared, noinline body: YieldingScope<Field<ID, Shared>, Returned>): Returned

exchange implements anisotropic data sharing (the field information looks different depending on the direction from which you are observing it).

Link copied to clipboard
inline fun <ID : Any, T> Aggregate<ID>.mapNeighborhood(crossinline local: (ID) -> T): Field<ID, T>

Observes the value of an expression local across neighbors. Builds a Field with minimal communication, using only the minimal machinery required to verify the alignment state. This function is recommended over

Link copied to clipboard

builds a Field of aligned IDs with minimal communication.

Link copied to clipboard
inline fun <ID : Any, Shared> Aggregate<ID>.neighboring(local: Shared): Field<ID, Shared>

Observes the value of an expression local across neighbors.

Link copied to clipboard
fun <ID : Any, T> Aggregate<ID>.project(field: Field<ID, T>): Field<ID, T>

Projects the field into the current context, restricting the field to the current context.

Link copied to clipboard
inline fun <ID : Any, Shared> Aggregate<ID>.share(initial: Shared, noinline body: (Field<ID, Shared>) -> Shared): Shared

share implements efficient stateful data sharing.

Link copied to clipboard

sharing implements efficient stateful data sharing.