GRAPH( recordset , iterations , processor [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )
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.
Example:
namesRec := RECORD STRING20 lname; STRING10 fname; UNSIGNED2 age := 25; UNSIGNED2 ctr := 0; END; namesTable2 := DATASET([{'Flintstone','Fred',35}, {'Flintstone','Wilma',33}, {'Jetson','Georgie',10}, {'Mr. T','Z-man'}], namesRec); loopBody(SET OF DATASET(namesRec) ds, UNSIGNED4 c) := PROJECT(ds[c-1], //ds[0]=original input TRANSFORM(namesRec, SELF.age := LEFT.age+c; //c is graph COUNTER SELF.ctr := COUNTER; //PROJECT's COUNTER SELF := LEFT)); g1 := GRAPH(namesTable2,10,loopBody(ROWSET(LEFT),COUNTER)); OUTPUT(g1);