hdfs_file()

Description:

Open a specified directory and return an HDFS file flow.

Syntax:

hdfs_file(HdfsClient,file:cs )

Note:

The function returns an HDFS file flow. The file extension determines the compression method; support writing data in a stream style into a non-segmental file, but there is no such a restriction on reading data in.

Parameters:

HdfsClient

An HDFS Client object

file

The name of the to-be-loaded Hadoop file

cs

The charset embedded in JVM; by default it is the default value for a virtual machine

Return value:

A file object

Example:

 

A

 

1

=hdfs_client(;"hdfs://192.168.0.8:9000")

Connect to the HDFS file system

2

=hdfs_file(A1,"/user/stu.txt":"GBK")

Read the HDFS file and return a file object

3

=A2.read@n()

Read the content of the file object as a string and return it

4

=A2.import@t()

Read the content of the file object as the records to form a table sequence and return it

 

5

=A2.cursor().fetch ()

Create a cursor based on a file object and fetch records from the cursor

6

=hdfs_close(A1)

Close the HDFS connection