file()

Read(371) Label: file,

Here’s how to use file() function.

file( fn : cs )

Description:

Open a file with the specified name.

Syntax:

file( fn{:cs})

Note:

The function opens a file named fn.

Parameters:

fn

Name of the file to load. Both the absolute path and the relative path are acceptable. If using the relative path, then it is relative to the main path, which is the one configured on the option menu of esProc, and which by default is the current directory (the directory holding the dfx file )

cs

Character set, which supports jvm's built-in character set and which by default is the default value set by OS

Options:

@s

Search the file names on the non-absolute paths in a specified order: Class path -> Search path-> Main path. The search path is the one configured on the option menu of esProc, and the default main path is the current directory. With this option, the function returns the name of a read-only file.

@t

Generate a temporary file under the directory of fn file. Without the fn file, create the temporary file under a tempory directory (a temporary directory is relative to the main directory set in Tool -> Options -> Environment) in Tool -> Options -> Environment or in a relative path.

@a

Make the write action wait when sharing violation happens

Return value:

A file object.

Example:

file("D:/Area.txt":"UTF-8")

Load the Area.txt file from the directory "D:\"; character set is UTF-8.

file("Area.txt")

Load the Area.txt file under the main path.

file@s("data/ Area.txt")

Search the class path first; if not found, then search throughout the list of search paths; lastly, search the main path if not found in the search paths.

file@t("data/Area.txt")

Create a temporary file under the directory data/

file( fn,f )

Description:

Generate a new cluster file according to the distribution of an existing clusting file.

Syntax:

file(fn,f)

Note:

The function generates cluster file fn according to the distribution of cluster file f and save the new file on the same node.

Parameters:

fn/f

A cluster file

Return value:

A cluster file

Example:

 

A

 

1

=file("emp.ctx":[1,2],["192.168.0.104:8281","192.168.190.129:8281"])

 

2

=file("emp_1.ctx",A1)

Generate a new cluster file emp_1.ctx having same distribution as emp.ctx on the same node

file( fn:z )

Description:

Open a file stored in the specified zone.

Syntax:

file(fn:z)

Note:

The function opens file fn stored in zone z and returns a homo-name files group composed a series of zone files. Generally file fn is read-only.

Parameters:

fn

The file to be loaded, which can be represented by an absolute path or a relative path. The relative path is relative to the main directory. The main directory used in IDE is the one configured in esProc Options menu; default main directory is the working directory. The main directory used in a server is the value of mainPath in the configuration file raqsoftConfig.xml, which cannot be empty.

z

Zone name

Return value:

Homo-name files group

Example:

 

A

 

1

=file("emp1.ctx":0)

Load composite table file emp1.ctx from zone 0

2

=file("emp.ctx":[0,1,2])

Return a homo-name files group made up of emp.ctx stored in zone 0, zone 1, and zone 2

file( fn:z , h )

Description:

Open a file in a specified zone on a node.

Syntax:  

file(fn:z,h)

Note:  

The function searches for file fn in zone z on node h.

When parameter z is absent or when it is a single value, the function returns a remote file object; in this case parameter fn can’t be a composite file. When parameter z is a sequence, the function returns a cluster file object; in this case parameter fn can only be a composite file.

When parameter h is a single value, the function searches the only node and returns a writable remote file.

When parameter h isn’t a single value and when parameter z is absent or it is a single value, the function first searches for the target file locally – then it searches an idle node on the remote machine if it can’t find the target locally – and returns a read-only file.

When both parameters z and h are multi-member sequences, the function adopts a recursive searching method. It searches z(1) on h(1), and then same zone on h(2) if there isn’t the target file on h(1), and so on until the target is found. Next it searches z(2) on h(2), and then same zone on each of the rest of the nodes until the target is located. Then it searches the next zone by repeating the same process. The function returns null if it doesn’t search all eligible locations or it finds nothing.

Parameters:  

fn

Name of the file to be loaded. Both the absolute path and the relative path are acceptable. With a relative path, it is relative to the main path. The main path on the IDE is the one configured on the option menu of esProc, and by default it is the current directory. The main path on a server is the value of mainPath in the configuration file raqsoftConfig.xml; this value shouldn’t be null

Z

Zone name; use the main directoy when it is absent

h

A sequence of nodes

Options:

@t

Perform read and write operations in the temporary directoy on the target node, with z ignored.

@w

Generate a writable cluster file when the target file to be searched for isn’t specified

Return value:  

A remote file object/a cluster file object

Example:

l  Return a remote file

file("Scores.xls",["192.168.0.28:9282"])

 

file("Scores1.txt":2, ["192.168.0.20:9282"])

Load file "Scores1.txt" in zone 2 on node "192.168.0.20:9282"

file("Scores.txt",["192.168.0.11:9282","192.168.0.12:9282"])

First searches the local main directory for file "Scores.txt" to load; and searches the main directory on the node if the file cann’t be found

l  Return a cluster file

file("Scores1.ctx":[2], ["192.168.0.20:9282"])

 

file("emp.ctx":[1,2],["192.168.190.129:8281","192.168.0.104:8281"])

Search for the target file recursively

file@w("emp2.ctx":[1],["192.168.0.131:8281"])

Create cluster composite file emp2.ctx in zone 1 on node "192.168.0.131:8281"