file()

Read(299) 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([fni,…]:cs)

Description:

Open a specified filegroup.

Syntax:

file( [fni,…]:cs)

Note:

The function opens a filegroup with the specified name fni….

Parameters:

fni

 

A to-be-loaded filegroup, which can be specified by an absolute path or a relative path; multiple filegroups are allowed. A relative path is relative to the main directory configured in the Options window; the default main directory is the currently open one (the one holding the corresponding dfx file)

cs

Charaset, which is a default one your JVM is using; use one defined by the OS if the parameter is absent

Return value:

File object

Example:

=file(["D:/tmp2.txt","tmp.txt"]:"UTF-8")

Load the filegroup of tmp2.txt and tmp.txt under D:\ directory; the charaset is UTF-8

=file(["tmp2.txt","tmp.txt"]:"UTF-8")

Load the filegroup of tmp2.txt and tmp.txt under the main directory; the charaset is UTF-8

file( fn,h )

Description:

Generate a cluster file from a remote composite table file.

Syntax:

file(fn,h)

Note:

The function accesses a remote composite table file fn through a node/node sequence h and generates a cluster file according to fn. Return a remote file when no option is used and parameter h is the node sequence; in this case, it is equivalent to the file(fn:z,h) function.

Parameters:

fn

A composite table file

h

A node or a node sequence

Options:

@z

Get the fn file from partition 1 on h(1), partition 2 on h(2), and so on according to the node sequence to generate a distributed file

@w

Allow the absence of parameter fn; used to generate a writable distributed file

@n

Get the fn file directly by name, instead of searching partitions; the option generates a duplicate file, but generates a distributed file if @z option is also present

@0

Get the fn file from partition 0 to generate a duplicated file; generate a distributed file if @z option is also present

@t

Can retrieve data from one set of nodes to generate a temporary file; doesn’t support a file group

Return value:

A cluster file

Example:

 

A

 

1

=file@0("emp1.ctx",["192.168.0.116:8281","192.168.0.129:8281"])

Read the composite table file emp1.ctx from partition 0 on the node "192.168.0.116:8281","192.168.0.129:8281" to generate a duplicate cluster file

2

=file@z("emp1.ctx",["192.168.0.116:8281","192.168.0.129:8281"])

Read the composite table file emp1.ctx from partition 1 on node "192.168.0.116:8281" and partition 2 on node "192.168.0.129:8281" to generate a distributed cluster file

3

=file@n("emp1.ctx",["192.168.0.116:8281","192.168.0.129:8281"])

Read the composite table file emp1.ctx from the main directories of nodes "192.168.0.116:8281" and "192.168.0.129:8281" to generate a duplicate cluster file

4

=file@n("D:/file/emp2.ctx", ["192.168.0.116:8281","192.168.0.129:8281"])

Retrieve composite table file D:/file/emp2.ctx from nodes

"192.168.0.116:8281" and "192.168.0.129:8281" to generate a duplicate cluster file

5

=file@zw(“emp2.ctx”,[“192.168.0.131:8281”])

Create a writable distributed composite table file emp2.ctx in partition 1 on the node "192.168.0.131"

6

=file@t("emp1.ctx",["192.168.0.116:8281","192.168.0.129:8281"])

Retrieve composite table file emp1.ctx from nodes "192.168.0.116:8281" and "192.168.0.129:8281" to geneate a temporary file

file( fn:z , h )

Description:

Open a remote file with a specified name.

Syntax:  

file(fn:z,h)

Note:  

When parameter h is the sequence of the nodes’ main processes, the function finds file fn, which is read-only, in partition z on a certain node in h. The search will first performed on the local machine, and then on the idle remote machines if fn can’t be found locally. If h is a single value, find fn on h; the remote fn can be written. Find the file under the main directory on the node if parameter z is absent.

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

h

Partition name

A sequence of nodes

 

Options:

@t

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

Return value:  

File object.

Example:

file("D:\\Scores.txt","192.168.0.20:9282")

Load the file “Scores.txt” from the D:\ of the local machine; character set is UTF-8

file("Scores.txt","192.168.0.20:9282")

Firstly, load the Scores.txt file under the main path of the local machine

file("Scores1.txt":0, “192.168.0.20:9282”)

 

 

 

 

If Scores1.txt is not found locally, then load the file in partition 0 on server "192.168.0.20:9282"