DATASET from TRANSFORM

DATASET( count, transform [, DISTRIBUTED | LOCAL ] )

This form uses the transform to create the records. The result type of the transform function determines the structure. The integer COUNTER can be used to number each iteration of the transform function.

LOCAL executes separately and independently on each node.

Example:

IMPORT STD;
msg(UNSIGNED c) := 'Rec ' + (STRING)c + ' on node ' + (STRING)(STD.system.Thorlib.Node()+1);

// DISTRIBUTED example
DS := DATASET(CLUSTERSIZE * 2,
              TRANSFORM({STRING line}, 
                        SELF.line := msg(COUNTER)), 
              DISTRIBUTED);
OUTPUT(DS);
/* creates a result like this:
   Rec 1 on node 1
   Rec 2 on node 1
   Rec 3 on node 2
   Rec 4 on node 2
   Rec 5 on node 3
   Rec 6 on node 3 
*/

// LOCAL example

DS2 := DATASET(2,
              TRANSFORM({STRING line},
                        SELF.line := msg(COUNTER)),
              LOCAL);
OUTPUT(DS2);

/* An alternative (and clearer) way
creates a result like this:
   Rec 1 on node 1
   Rec 2 on node 1
   Rec 1 on node 2
   Rec 2 on node 2
   Rec 1 on node 3
   Rec 2 on node 3
*/

See Also: RECORD Structure, TRANSFORM Structure