HybridAggregationHandler

internal class HybridAggregationHandler<in Value : Any, out Return>(val reducer: Reducer<Value, Return>, val indexOfResult: IndexOfResult<Value>, val getReturnType: CalculateReturnType) : AggregatorAggregationHandler<Value, Return>

Implementation of AggregatorAggregationHandler which functions like a selector ánd reducer: it takes a sequence of values and returns a single value, which is likely part of the input, but not necessarily.

In practice, this means the handler implements both indexOfAggregationResultSingleSequence (meaning it can give an index of the result in the input), and aggregateSequence with a return type that is potentially different from the input. The return value of aggregateSequence and the value at the index retrieved from indexOfAggregationResultSingleSequence may differ.

Parameters

reducer

This function actually does the selection/reduction. Before it is called, nulls are filtered out. The type of the values is passed as KType to the selector.

indexOfResult

This function must be supplied to give the index of the result in the input values.

getReturnType

This function must be supplied to give the return type of reducer given some input type and whether the input is empty. When selecting, the return type is always typeOf<Value>() or typeOf<Value?>(), when reducing it can be anything.

See also

Constructors

Link copied to clipboard
constructor(reducer: Reducer<Value, Return>, indexOfResult: IndexOfResult<Value>, getReturnType: CalculateReturnType)

Properties

Link copied to clipboard
open override var aggregator: Aggregator<Value, Return>?

Reference to the aggregator instance.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun aggregateSequence(values: Sequence<Value?>, valueType: ValueType): Return

Base function of Aggregator.

Link copied to clipboard

Aggregates the data in the given column and computes a single resulting value. Calls aggregateSequence. It tries to exploit a cache for statistics which can be accessed by ValueColumnInternal

Link copied to clipboard
open override fun calculateReturnType(valueType: KType, emptyInput: Boolean): KType

Give the return type of reducer given some input type and whether the input is empty. Calls the supplied getReturnType.

Link copied to clipboard
open override fun indexOfAggregationResultSingleSequence(values: Sequence<Value?>, valueType: ValueType): Int

Function that can give the index of the aggregation result in the input values. Calls the supplied indexOfResult after preprocessing the input.

Link copied to clipboard
open fun init(aggregator: Aggregator<Value, Return>)