Class SetEvaluator

java.lang.Object
io.trino.operator.window.pattern.SetEvaluator

public class SetEvaluator extends Object
This class returns a set of positions to aggregate over for an aggregate function in row pattern matching context. Aggregations in row pattern matching context have RUNNING or FINAL semantics, and they apply only to rows matched with certain pattern variables. For example, for a match "A B A A B", the aggregation `sum(B.x)` only applies to the second and the last position.

This evaluator is stateful. It requires a reset for every new match. The method `resolveNewPositions()` returns a portion of positions corresponding to the new portion of the match since the last call. It is thus assumed that a sequence of calls since the instance creation or `reset()` applies to the same match (i.e. the `matchedLabels` passed as an argument to one call is prefix of `matchedLabels` passed in the next call).

Also, a full list of positions for a current match is kept, and it can be obtained via the `getAllPositions()` method. This is for the purpose comparing pattern matching threads in ThreadEquivalence.