Skip to content

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:

Deserializing

deserialize(
  storageFormat: Array[Byte]): T

See:

Used when:

  • TypedImperativeAggregate is requested to merge

Interpreted Execution

eval(
  buffer: T): Any

See:

Used when:

merge

merge(
  buffer: T,
  input: T): T

See:

Used when:

Serializing Aggregate Buffer

serialize(
  buffer: T): Array[Byte]

See:

Used when:

update

update(
  buffer: T,
  input: InternalRow): T

See:

Used when:

  • TypedImperativeAggregate is requested to update

Implementations

Interpreted Expression Evaluation

Expression
eval(
  buffer: InternalRow): Any

eval is part of the Expression abstraction.

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
  1. 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:

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: