attribute := expression : INDEPENDENT [(cluster [,LABEL(text)])];

attributeThe name of the Attribute.
expressionThe definition of the attribute.
clusterOptional. A string constant specifying the name of the Thor cluster on which execute. If omitted, the attribute is run on the currently executing cluster.
LABELOptional. 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.
textA 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.


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 });

  SELF.Ival := I;
  SELF.Gval := G;
  SELF.Aval := RANDOM();     //calculated each time used
  SELF := L;

P1 := PROJECT(ds,XF(left)) : PERSIST('~TEMP::PERSIST::IndependentVsGlobal1');
P2 := PROJECT(ds,XF(left)) : PERSIST('~TEMP::PERSIST::IndependentVsGlobal2');

OUTPUT(P2);  //this gets the same Ival values as P1, but the Gval value is different than P1

See Also: GLOBAL