Qfile()

Read(1580) Label: cloud storage, storage bucket,

Description:

Retrieve file(s)/homo-name files group from storage bucket in the remote storage.

Syntax:

Qfile(fd:z)

Qfile(fd:cs)

Note:

The function gets file fd from the storage bucket in the remote storage and returns it as a file object.

 

Supported file types include SPL script file, composite file, homo-name files group, bin file, txt and xls. The return file object supports operations such as exists(), name(), size(), date(), read() and import(), but does not support write right now.

 

The returned buffer file object is stored incache directory/store Type/.

 

When QVS users service mode, the buffer directory here is QVM’s cache directory; when QVS users debug mode, it is QVS’s own cache directory. If no cloud storage information is configured in the QVS application configuration file, configureRemote Services –> Storage Service Settingsin esProc IDE and connect the target remote storage service before using the function directly in esProc IDE .

 

Will be parsed as file() function when no cloud storage information is configured.

Parameter:

fd

File(s) on the remote storage; its written format is “storagebucketName/fileobjectName

z

Specify this parameter when parameter fd is a homo-name files group, this parameter is zone table number or a sequence of zone table numbers

cs

Character set; support JVM’s built-in character sets; default is the one in the OS

Option:

@c

Force to cache all cache blocks to the cache directory; by default, only cache certain cache blocks containing data to be retrieved to the directory according to their positions

Return value:

File object

Example:

Get data file:

 

A

 

1

=Qfile("qtc01/cities.txt")

Open cities.txt in storage bucket qtc01.

2

=A1.exists()

Check whether the file exists or not.

3

=A1.name()

Return the file name as [esProc installation directory]\esProc\q-server\webapps\qvs\WEB-INF\home\cache\s3\qtc01\cities.txt.

4

=A1.import@t()

Return file data as a table sequence.

 

Get a composite table file:

 

A

 

1

=Qfile("qtc01/emp.ctx")

get composite table file object in storage bucket qtc01.

2

=A1.open()

Open the composite table’s base table.

3

=A2.cursor().fetch()

Fetch data from the base table.

 

Get homo-name files group:

 

A

 

1

=Qfile("qtc01/emp.ctx":[1,2])

Get homo-name files group 1.emp.ctx and 2.emp.ctx in storage bucket qtc01.

2

=A1.open()

Open the homo-name files group.

3

=A2.import()

Import data from the homo-name files group.

 

When no cloud storage is configured:

 

A

 

1

=Qfile("order.ctx")

Get the composite table file object in esProc main directory.

2

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

Get the homo-names files group in esProc main directory.