TypedImperativeAggregate Expressions¶
TypedImperativeAggregate is an extension of the ImperativeAggregate abstraction for typed ImperativeAggregates.
Scala Definition
TypedImperativeAggregate[T] is a type constructor (Scala) with T type parameter.
Contract¶
Creating Aggregation Buffer¶
createAggregationBuffer(): T
Creates an empty aggregation buffer object (to initialize this TypedImperativeAggregate)
See:
Used when:
Collectis requested to deserializeTypedImperativeAggregateis requested to initialize
Deserializing¶
deserialize(
storageFormat: Array[Byte]): T
See:
Used when:
TypedImperativeAggregateis requested to merge
Interpreted Execution¶
eval(
buffer: T): Any
See:
Used when:
TypedImperativeAggregateis requested to execute (interpreted mode)
merge¶
merge(
buffer: T,
input: T): T
See:
Used when:
TypedImperativeAggregateis requested to merge and mergeBuffersObjects
Serializing Aggregate Buffer¶
serialize(
buffer: T): Array[Byte]
See:
Used when:
TypedImperativeAggregateis requested to serialize the aggregate buffer in-place
update¶
update(
buffer: T,
input: InternalRow): T
See:
Used when:
TypedImperativeAggregateis requested to update
Implementations¶
Interpreted Expression Evaluation¶
eval take the buffer object out of the given InternalRow and evaluates the result.
Aggregate Buffer Attributes¶
AggregateFunction
aggBufferAttributes: Seq[AttributeReference]
aggBufferAttributes is part of the AggregateFunction abstraction.
aggBufferAttributes is a single AttributeReference:
| Name | DataType |
|---|---|
buf | BinaryType |
Extracting Aggregate Buffer Object¶
getBufferObject(
bufferRow: InternalRow): T // (1)!
getBufferObject(
buffer: InternalRow,
offset: Int): T
- Uses the mutableAggBufferOffset as the
offset
getBufferObject requests the given InternalRow for the value (of type T) at the given offset that is of ObjectType type.
getBufferObject is used when:
TypedImperativeAggregateis requested to mergeBuffersObjects, update, merge, eval, serializeAggregateBufferInPlace
ObjectType¶
anyObjectType: ObjectType
When created, TypedImperativeAggregate creates an ObjectType of a value of Scala AnyRef type.
The ObjectType is used in getBufferObject.
Serializing Aggregate Buffer In-Place¶
serializeAggregateBufferInPlace(
buffer: InternalRow): Unit
Procedure
serializeAggregateBufferInPlace is a procedure (returns Unit) so whatever happens inside, stays inside (paraphrasing the former advertising slogan of Las Vegas, Nevada).
serializeAggregateBufferInPlace gets the aggregate buffer from the given buffer and serializes it.
In the end, serializeAggregateBufferInPlace stores the serialized aggregate buffer back to the given buffer at mutableAggBufferOffset.
serializeAggregateBufferInPlace is used when:
AggregatingAccumulatoris requested to withBufferSerializedAggregationIteratoris requested to generateResultProjectionObjectAggregationMapis requested to dumpToExternalSorter