fork ....;h,s reduce

Description:

Execute a code block with multiple threads on multiple nodes.

Syntax:

fork  ….;h,s  reduce

Note:

…. is a parameter sequence, whose length determines the number of parallel threads. The statement makes multiple duplicates of the current cellset and its context to execute them respectively using multiple threads running on multiple nodes listed in sequence h. A sequence parameter will be separated to have its members respectively used as the value of current cell for the execution of each thread on the nodes; and a single-value parameter will be duplicated to be distributed to each thread. The result of return statement in the code block will be used in the form of a sequence as the cell value of the main program to call the subroutine. Executing a code block with multiple threads on multiple nodes is functionally equivalent to callx() function without deploying a dfx file on each node. You can’t reference cells and variables other than the parameters of the fork statement in the code block. A referenced cellset variable (which includes cell names) will also be distributed to the cellset on each node.

Parameters:

 

….

A parameter sequence, whose members will be distributed among servers; the distribution will stop when the number of subtasks on every server reaches its maximum and will resume as soon as there is an available server. The subtasks on a server will be reassigned if it fails.

 

 

h

The server sequence in which each server is represented by a string in the form of "address:port number", like "192. 168. 0. 86: 4001".

 

s

A sequence consisting of integer sequences; can be omitted

reduce

The reduce action; ~~ represents the current result of performing reduce and ~ represents the result returned by the current task; can be omitted

Example:

1)  Single parameter

 

A

B

1

fork [[1,20,6,14,5],[32,8],23];["192.168.1.100:8989","192.168.1.100:8282","192.168.1.100:8283"]

// return results of executing result statement of multithreads on multinodes

2

 

=connect("demo")

3

 

=B2.query("select * from EMPLOYEE where EID in (?) ",A1)

4

 

=B2.close()

5

 

return B3

 

 

A

B

1

[192.168.0.116:8281,192.168.0.129:8281]

 

2

[English,Math,PE]

 

3

[[1],[2,3]]

 

4

fork  A2;A1,A3

 

5

 

=connect("demo")

6

 

=B5.query("select * from SCORES  where SUBJECT=?",A4)

7

reduce

~~|~

 

2)  Multiple parameters

 

A

B

1

fork [[1,20,6,14,5],[32,8],[3,4],23,12,89,56,90,231,333,111,231],"F";["192

.168.1.100:8989","192.168.1.100:8282","192.168.1.100:8283"]

// return results of executing result statement of multithreads on multinodes

2

 

=connect("demo")

3

 

=B2.query("select * from EMPLOYEE where EID in (?) and GENDER=?",A1(1),A1(2))

4

 

=B2.close()

5

 

return B3

Related functions:

  callx()

  fork Ai,...