attribute := expression : INDEPENDENT [(cluster [,LABEL(text)])];
attribute | The name of the Attribute. |
expression | The definition of the attribute. |
cluster | Optional. A string constant specifying the name of the Thor cluster on which execute. If omitted, the attribute is run on the currently executing cluster. |
LABEL | Optional. Defines the Text to display for the workflow item in the Graph for the workunit. If omitted, the code generator will deduce a label from the identifier being defined. |
text | A string constant containing the text to display. |
The INDEPENDENT service causes the attribute to be evaluated at a global scope and forces the attribute evaluation into a separate workflow item. The new workflow item is evaluated before the first workflow item that uses that attribute. It executes independently from other workflow items, and is only executed once (including inside SEQUENTIAL where it should be executed the first time it is used). It will not share any code with any other workflow items.
One use would be to provide a mechanism to common up code that is shared between different arguments to a SEQUENTIAL action--normally they are evaluated completely independently.
Example:
I := RANDOM() : INDEPENDENT(LABEL('CalcRandom')); //calculated once, period
G := RANDOM() : GLOBAL; //calculated once in each graph
ds :=
DATASET([{1,0,0,0},{2,0,0,0}],{UNSIGNED1 rec,UNSIGNED Ival, UNSIGNED Gval , UNSIGNED Aval });
RECORDOF(ds) XF(ds L) := TRANSFORM
SELF.Ival := I;
SELF.Gval := G;
SELF.Aval := RANDOM(); //calculated each time used
SELF := L;
END;
P1 := PROJECT(ds,XF(left)) : PERSIST('~TEMP::PERSIST::IndependentVsGlobal1');
P2 := PROJECT(ds,XF(left)) : PERSIST('~TEMP::PERSIST::IndependentVsGlobal2');
OUTPUT(P1);
OUTPUT(P2); //this gets the same Ival values as P1, but the Gval value is different than P1
See Also: GLOBAL