compute by message

processing is done in the emit operator. It requires that the emit operator’s input stream be sorted according to any order by requirements in the query. The processing is similar to what is done in the GroupSortedOp (aggregation mode) operator. Each row read from the child is checked to see if it starts a new group. If it does not, the aggregate functions are applied as appropriate to the query’s requested groups. If a new group is started, the current group and its aggregated values are returned to the user. A new group is then started and its aggregate values are initialized from the new row’s values. This example collects an ordered list of all cities and reports a count of the number of entries for each city after the city list.

1> select city
2>     from authors
3>     order by city
4>     compute count(city) by city
5> go

QUERY PLAN FOR STATEMENT 1 (at line 3).

2 operator(s) under root

The type of query is SELECT.
Emit with Compute semantics

ROOT:EMIT Operator

	|SORT Operator
	| Using Worktable1 for internal storage.
	|
	|   |SCAN Operator
	|   |  FROM TABLE
	|   |  authors
	|   |  Table Scan.
	|   |  Forward Scan.
	|   |  Positioning at start of table.
	|   |  Using I/O Size 2 Kbytes for data pages.
	|   |  With LRU Buffer Replacement Strategy for data pages.

In this example, the emit operator’s input stream is sorted on the city attribute. For each row, the compute by count value is incremented. When a new city value is fetched, the current city’s values and associated count value is returned to the user. The new city value becomes the new compute by grouping value and its count is initialized to one.