AggregateFunction<V> class abstract

Interface for application-defined aggregate functions.

A subclass of AggregateFunction should hold no state across invocations. All its state needed during a computation should be stored in an instance of V.

As an example, take a look at the following Dart implementation of the count() aggregate. Recall that there are two versions of count(). With zero arguments, count() returns the number of rows. With one argument, count() returns the number of times that the argument was non-null.

class MyCount implements AggregateFunction<int> {
 @override
 AggregateContext<int> createContext() => AggregateContext(0);

 @override
 void step(List<Object> arguments, AggregateContext<int> context) {
   if (arguments.isEmpty || arguments.first != null) {
     context.value++;
   }
 }

 @override
 Object finalize(AggregateContext<int> context) {
   return context.value;
 }
}
Annotations
  • @immutable

Constructors

AggregateFunction()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createContext() AggregateContext<V>
Creates an initial context holding the initial value before step is called.
finalize(AggregateContext<V> context) Object?
Computes the final value from a populated context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
step(List<Object?> arguments, AggregateContext<V> context) → void
Adds a new row to the aggregate.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited