Description:
Implement an operation on file data, such as download and upload.
Syntax:
webhdfs(url,localFile)
Note:
The external library function implements any operations within HDFS and WebHDFS.
Parameter:
url |
URL of the target file |
localFile |
The target file; can be omitted |
Return value:
Operation successful or failed
Example:
|
A |
|
1 |
=webhdfs("http://localhost:50070/webhdfs/v1/test/z1.zip?op=CREATE&user.name=root","D:/z1.zip") |
Upload folder D:/z1.zip |
2 |
=webhdfs("http://localhost:50070/webhdfs/v1/test/f2.png?op=CREATE&user.name=root&overwrite=true"," D:/f2.png") |
Upload folder D:/f2.png, and force an overwriting when a namesake folder already exists |
3 |
=webhdfs("http://localhost:50070/webhdfs/v1/test/f3.txt?op=APPEND&user.name=root","D:/f4.txt") |
Append data in D:/f4.txt to f3.txt |
4 |
=webhdfs("http://localhost:50070/webhdfs/v1/test/f5.xlsx?op=OPEN&user.name=root","D:/f5.xlsx") |
Download f5.xlsx |
5 |
=webhdfs("http://localhost:50070/webhdfs/v1/test/?op=LISTSTATUS&user.name=root") |
Get a list of files under /test/ directory and return result as a JSON string |
6 |
=json(A5) |
Convert A5’s JSON string into a multilevel, nested table sequence |
7 |
=A6.FileStatuses.FileStatus |
List detailed information of the files |
Description:
Implement file read and write.
Syntax:
webhdfs_file(fileUrl,params)
Note:
The external library function implements file read and write using the HTTP request.
Parameter:
fileUrl |
URL of the target file |
params |
Parameter in the file URL |
Return value:
URL of the target file
Example:
|
A |
|
1 |
=webhdfs_file("http://localhost:50070/webhdfs/v1/test/orders.txt":"UTF-8","user.name=root") |
Connect to WebHDFS |
2 |
=A1.read() |
Read data from A1’s text file as a string |
3 |
=A1.import@t() |
Read content of the text file as records to form a table sequence to return |
4 |
=A1.cursor().fetch () |
Create cursor for A1’s text file, and fetch records from the cursor |
5 |
=webhdfs_file("http://localhost:50070/webhdfs/v1/test/orders.btx","user.name=root")
|
|
6 |
=A5.import@b() |
Read content of A5’s bin file as records to form a table sequence to return |
7 |
=A5.cursor@b().fetch() |
Create cursor for A5’s bin file, and fetch records from the cursor |