WindowFunction<V> class
abstract
A window function for sqlite3.
In addition to AggregateFunctions, which run over an entire query, window
functions can run over a subset of rows as defined in an OVER
clause.
This example defines a window function taking a single argument, which must be an int. The result of the window function is the sum of all arguments in the current window.
class _SumInt implements WindowFunction<int> {
@override
AggregateContext<int> createContext() => AggregateContext(0);
@override
Object? finalize(AggregateContext<int> context) {
// There's nothing to finalize, if our [createContext] had side-effects
// we'd have to undo them here.
return value(context);
}
int _argument(List<Object?> arguments) {
return arguments.single! as int;
}
@override
void inverse(List<Object?> arguments, AggregateContext<int> context) {
context.value -= _argument(arguments);
}
@override
void step(List<Object?> arguments, AggregateContext<int> context) {
context.value += _argument(arguments);
}
@override
Object? value(AggregateContext<int> context) => context.value;
}
- Implemented types
- Annotations
Constructors
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.
inherited
-
finalize(
AggregateContext< V> context) → Object? -
Computes the final value from a populated
context
.inherited -
inverse(
List< Object?> arguments, AggregateContext<V> context) → void -
Removes the row of
arguments
from this window. -
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.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
value(
AggregateContext< V> context) → Object? - Obtain the current aggregate in the window.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited