Skip to main content


GRAPH( recordset , iterations , processor [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

recordsetThe initial set of records to process.
iterationsThe number of times to call the processor function.
processorThe function attribute to process the input. This function may use the following as arguments:
ROWSET(LEFT)   Specifies the set of input datasets, which may be indexed 
                                  to specify the result set from any specific iteration -- 
                                  ROWSET(LEFT)[0] indicates the initial input recordset while
                                  ROWSET(LEFT)[1] indicates the result set from the first 
                                  iteration. This may also be used as the first parameter 
                                  to the RANGE function to specify a set of datasets 
                                  (allowing the graph to efficiently process N-ary merge/join 

COUNTER             Specifies an INTEGER parameter for the graph iteration number.
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:GRAPH returns the record set result of the last of the iterations.

The GRAPH function is similar to the LOOP function, but it executes as though all the iterations of the processor call were expanded out, removing any branches that can't be executed, and then joined together. The resulting graph is as efficient as if the graph had been expanded out by hand.


namesRec := RECORD
  STRING20 lname;
  STRING10 fname;
  UNSIGNED2 age := 25;
  UNSIGNED2 ctr := 0;
namesTable2 := DATASET([{'Flintstone','Fred',35},
    {'Mr. T','Z-man'}], namesRec);

loopBody(SET OF DATASET(namesRec) ds, UNSIGNED4 c) :=
      PROJECT(ds[c-1],    //ds[0]=original input
    SELF.age := LEFT.age+c; //c is graph COUNTER
    SELF := LEFT));

g1 := GRAPH(namesTable2,10,loopBody(ROWSET(LEFT),COUNTER));