AGGREGATE

AGGREGATE( recordset, resultrec,maintransform [ , mergetransform (RIGHT1,RIGHT2) | groupingfields ] [, LOCAL | FEW | MANY] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

recordsetThe set of records to process.
resultrecThe RECORD structure of the result record set.
maintransformThe TRANSFORM function to call for each matching pair of records in the recordset. This is implicitly a local operation on each node.
mergetransformOptional. The TRANSFORM function to call to globally merge the result records from the maintransform. If omitted, the compiler will attempt to deduce the merge from the maintransform.
groupingfieldsOptional. A comma-delimited list of fields in the recordset to group by. Each field must be prefaced with the keyword LEFT. If omitted, then all records match.
LOCALOptional. Specifies the operation is performed on each supercomputer node independently, without requiring interaction with all other nodes to acquire data; the operation maintains the distribution of any previous DISTRIBUTE. Valid only if the mergetransform is omitted.
FEWOptional. Indicates that the expression will result in fewer than 10,000 records. This allows optimization to produce a significantly faster result.
MANYOptional. Indicates that the expression will result in more than 10,000 records.
UNORDEREDOptional. Specifies the output record order is not significant.
ORDEREDSpecifies the significance of the output record order.
boolWhen False, specifies the output record order is not significant. When True, specifies the default output record order.
STABLEOptional. Specifies the input record order is significant.
UNSTABLEOptional. Specifies the input record order is not significant.
PARALLELOptional. Try to evaluate this activity in parallel.
numthreadsOptional. Try to evaluate this activity using numthreads threads.
ALGORITHMOptional. Override the algorithm used for this activity.
nameThe algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options.
Return:AGGREGATE returns a record set.

The AGGREGATE function is similar to ROLLUP except its output format does not need to match the input format. It also has similarity to TABLE in that the groupingfields (if present) determine the matching records such that you will get one result for each unique value of the groupingfields. The input recordset does not need to have been sorted by the groupingfields.

The operation is implicitly local, in that the maintransform is called to process records locally on each node, and the result records on each node are then merged to produce the global result.

TRANSFORM Function Requirements - AGGREGATE

The maintransform must take at least two parameters: a LEFT record of the same format as the input recordset and a RIGHT record of the same format as the resultrec. The format of the resulting record set must be the resultrec. LEFT refers to the next input record and RIGHT the result of the previous transform.

The mergetransform must take at least two parameters: RIGHT1 and RIGHT2 records of the same format as the resultrec. The format of the resulting record set must be the resultrec. RIGHT1 refers to the result of the maintransform on one node and RIGHT2 the result of the maintransform on another.

The mergetransform is generated for expressions of the form:

  SELF.x := <RIGHT.x <op> f(LEFT)
  SELF.x := f(LEFT)  <op> RIGHT.x

where the <op> is: MAX, MIN, SUM, +, &, |, ^, *