fork A i ,…

Description:

Use multithreads to execute the code block in a cellset.

Syntax:

fork  Ai,

Note:

Ai is a sequence parameter, 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. A sequence parameter will be separated to have its members respectively used as the value of current cell for the execution of each thread; 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.

Parameters:

Ai

A sequence

Example:

1)  Single parameter

 

A

B

1

fork [[1,20,6,14,5],[32,8]]

//return the result of executing result statement of multithreads

2

 

=connect("demo")

3

 

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

4

 

=B2.close()

5

 

return B3

 

2)  Multiple parameters

 

A

B

1

fork [[1,20,6,14,5],[32,8]],"F"

//return the results of executing result statement of multithreads

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()

call()

 

fork cs

Description:

Perform parallel computation over a multicursor.

Syntax:

fork cs

Note:

The function performs parallel computation over a multicursor. Within a parallel computing code block, the referenced cell represents the current thread of cursor.

Parameters:

cs

A multicursor

Example:

 

A

B

 

1

=file("employee.txt")

=A1.cursor@mt()

Create a multicursor based on employee.txt and return it

2

fork B1

 

Perform parallel computation over the multicursor

3

 

=A2.select().fetch()

Get records from each thread of cursor by loop

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,...

fork … fork …

Description:

Execute multiple code blocks in parallel.

Syntax:

fork

fork

Note:

The function executes multiple code blocks in parallel and assigns the result of executing each code block to the corresponding fork cell.

Example:

 

A

B

1

fork [[1,20,6,14,5],[32,8]]

//fork

2

 

=connect("demo")

3

 

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

4

fork [[1,20,6,14,5],[32,8]],"F"

//fork

5

 

=connect("demo")

6

 

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

format()

Description:

Generate a formatted string in Java.

Syntax:

format (s,…)

Note:

The function converts data of any type into a formatted string in Java; parameter is the parameter of string s.

Parameters:

s

A string

 

The format parameter of the specified string

Example:

format("my name is %s","wind")

my name is wind

format("this is %f",9552.21) 

this is 9552.210000

format("this is %d",-2)

this is -2

Return value:

A string

Format specifiers in Java:

 

Format Specifier

Conversion Applied

 

%s

String

 

%c

Character

 

%b

Boolean

 

%d

Decimal integer

 

%x

Integer hexadecimal

 

%o

Octal integer

 

%f

Decimal floating-point

 

%a

Floating-point hexadecimal

 

%e

Scientific notation

 

%g

Causes Formatter to use either %f or %e, whichever is shorter

 

%h

Hash code

 

%%

Inserts a percent sign

 

%n

Inserts a newline character

 

%tx

Datetime (x is a suffix to describe the portion and precise format of the time or date desired)