callx()

Read(446) Label: callx,

Here’s how to use callx() function.

callx( dfx,...;;x )

Description:

Execute the local cellset file dfx through multithreaded processing and return all results as a sequence.

Syntax:

callx(dfx,…;;x)

Note:

The function uses multiple threads to execute the local cellset file dfx. The length of the sequence is the number of subtasks to be performed. The number of threads is equivalent to the preffered number of subtasks for the current machine. The extra subtasks will queue up waiting for execution.

Parameter x defines a reduce action. The function returns a sequence consitting of the result sets of the subtasks if x is absent. When x is present, the function calculates the reduce expression using ~, the result of each subtask, and ~~, the current reduce result, replaces ~~ with the result of x to go on calculating reduce and returns the final result of ~~, which is the sequence of all node results.

Parameters:

dfx

The cellset file dfx can be represented by an absolute path or a relative path. The relative path is the search path configured in Tools->Options ->Environment

x

reduce action that can be omitted

The parameter value(s) passed to the dfx file. The format is a sequence. The number of members in the sequence is that of the parameters to be passed in. The multithreaded processing will split the computing task into a number of subtasks according to the length of the sequence parameter, take each member as the parameter value for the dfx file and pass it to the corresponding subtask. If the parameter is a single value, just copy and pass it to every subtask.

Example:

test.dfx is a local file. Its content is as bellows:

 

A

B

1

=connect("demo").query("select * from SCORES  where SUBJECT=?",arg1)

2

return A1

return A1.(SCORE)

 

 

A

 

1

=callx("test.dfx",["English","Math","PE"];)

Local multithreaded processing that passes parameters to test.dfx and returns the query result as a sequence The cellset file is located in the search path configured in Tools->Options ->Environment

2

=callx("test.dfx",["English","Math","PE"];;~~|~)

Local multithreaded processing that passes parameters to test.dfx and executes the reduce action defined by aggregate expression ~~|~, which will concatenate each result returned by the nodes into a string, and returns a sequence of such strings

callx( dfx,...;h,s;x )

Description:

Compute cellset file dfx with parallel processing and return a sequence composed of result sets of the multiple subtasks.

Syntax:

callx(dfx,;h,s;x)

Note: 

The function distributes the computing task among the node process list h and executes script dfx. The length of the sequence is the number of subtasks to be performed. By default the function implements equi-allocation. In this case the number of subtasks to be performed must be equal to that of the nodes and parameters s and x will be ignored; if their numbers are different, task will fail.

A subtask that terminates due to abnormal termination will be given to another node to handle. It fails if there isn’t an available node. It is regarded as an abnormal termination if a subtask happens to be given to an unavailable node.

Parameter x defines a reduce action. The function returns a sequence consisting of the result sets of the subtasks if x is absent. When x is present, the function calculates the reduce expression using ~, the result of each subtask, and ~~, the current reduce result, replaces ~~ with the result of x to go on calculating reduce and returns the final result of ~~, which is the sequence of all node results.  

Parameters:

dfx

The cellset file, for which an absolute or a relative path can be set. The relative path is the Search Path under the Tool->Option-> [Environment] menu.

x

Reduce action; can be omitted

The parameter for passing value to dfx. It is usually in the form of a sequence. The number of parameters to be passed to dfx is the number of the sequences. The parallel algorithm will divide a computational task into multiple subtasks according to the length of the parameter sequence and pass each member of the sequence to the corresponding subtask as the parameter value of dfx. If a parameter is single-value, then it will be copied to every subtask.

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". By default, the servers will not be specified, and the computation will be distributed to multiple threads in the current process.

s

A sequence made up of integer sequences

Options:

  @a  Enable a random allocation that allocates subtasks randomly and evenly to nodes and where both parameter s and parameter x are ignored and computing capcity isnn’t taken into consideration. If a node happens to be invalid or returns an error, replace it with another.

@l

Enable a simple allocation that allocates subtasks to nodes according to computing capacity before starting nodes to compute and where both parameter s and parameter x are ignored and the number of subtasks is less than that of the nodes.

@m

Enable a heavy allocation where the number of subtasks is greater than that of the nodes.

Find the node(s) that have the largest computing capacity and allocate subtasks randomly to it/them until the number of the remaining subtasks is less than a certain threshold value. Then start nodes to compute. A node will ask for more subtasks after it finishes the current one(s). The whole task fails if any one of the subtask fails. An unavailable node (whose value is null in the server sequence h) won’t receive any job.

When parameter s is present, the corresponding data zone s(i) is needed to handle subtask i. So the subtask should be allocated to a node containing data zone s(i).

When parameter s is absent, allocate subtasks randomly among all available nodes.

Return a sequence consisting of the result sets of the subtasks if x is absent. When x is present, perform a certain reduce action on each node and return a sequence of all node results. An unavailable node will take a place in the returned sequence.

 

Example:

test.dfx is the deployment file for the remote node server. The node machines are respectively the [”192.168.0.204”,” 192.168.0.205”,” 192.168.0.206”], and the port number is 8081. The file contents are shown below:

1)  Single Parameter

 

A

B

1

=connect("demo").query("select * from SCORES where SUBJECT=?",arg1)

2

return A1

return A1.(SCORE)

 

 

A

 

1

=callx("test.dfx",["English","Math","PE"];["192.168.0.204:8081","192.168.0.205:8281","192.168.0.206:8081"])

Subtasks are allocated strictly in order as there are same number of servers 

2

=callx@a("test.dfx",["English","Math","PE"];["192.168.0.204:8081","192.168.0.205:8081"])

A random allocation that allocates subtask parameters randomly to nodes

3

=callx@l("test.dfx",["English"];["192.168.0.204:8081","192.168.0.205:8081"])

A simple allocation that allocates subtask parameters to nodes according to computing capacity

4

=callx@m("test.dfx",["English","Math","PE","Chinese"];["192.168.0.204:8081","192.168.0.205:8081","192.168.0.206:8081"])

A heavy allocation that allocates subtask parameters to nodes; since node 192.168.0.204:8081 is unavailable, it won’t receive any job

2)  Multiple Parameters

 

A

 

1

=connect("demo")

 

 

2

=A1.query("select * from EMPLOYEE where EID in (?)and GENDER=?",arg1,arg2)

 

 

3

=A1.close()

 

 

4

return A2

 

 

 

 

A

 

1

=callx("test.dfx",[[1,20,6,14,5]],"F";"192.168.0.204:8081")

Pass two parameters, which are string type and sequence type respectively, to one node machine.

2

=callx("test.dfx",[[1,20,6,14,5],[22,33,44]],"F";["192.168.0.204:8081","192.168.0.205:8081"])

Send multiple parameters to multiple node machines. For a parameter that has the same value, it can be passed in the form of single value.

3

=callx("test.dfx",[[1,20,6,14,5],[22,33,44]],["F","M"];["192.168.0.204:8081","192.168.0.205:8081"])

When multiple node machines receive the same parameter with different values, the parmeter should be passed in the form of a sequence.

4

=callx@l("test.dfx",[[1,20,6,14,5]],"M";["192.168.0.204:8081","192.168.0.205:8081"])

A simple allocation that allocates subtask parameters to nodes according to computing capacity

5

=callx@m("test.dfx",[[1,20,6,14,5],[5,89,100],[58,62,99]],"M";["192.168.0.204:8081","192.168.0.205:8081"])

A heavy allocation that allocates subtask parameters to nodes; both nodes contain zones 1,2,3, so the subtask 1 is given to zone 1 on node 192.168.0.204:8081, subtask 2 is given to zone 2 on node 192.168.0.205:8081, and subtask 3 is given to zone 3 on node 192.168.0.204:8081