hdfsfile()

阅读(412) 标签: hdfs文件流, 外部库函数,

描述:

返回HDFS文件流

语法:

hdfsfile(url:cs,xml:xml:...)

备注:

外部库函数,返回HDFS文件流,由扩展名决定压缩方式,只能流式写出生成不分段文件,读没有限制,支持加载指定的xml配置文件。

参数:

url

加载 hadoop 文件的 url格式

cs

字符集,支持的字符集是jvm自带的字符集。缺省则为虚拟机默认值。

xml

Hadoop 的配置xml文件,如hdfs-site.xml, core-site.xmlmapred-site.xmlyarn-site.xml等,目前仅支持绝对路径,参数可省略。

返回值:

文件流

示例:

hdfsfile("hdfs://192.168.0.204:9000/user/root/student.txt":"GBK")

加载hadoop文件student.txt,字符集为GBK

hdfsfile("hdfs://192.168.0.204:9000/user/root/dept.txt":"GBK","D: \core-site.xml":"D:\hdfs-site.xml")

加载hadoop文件
dept.txt
,字符集为GBK;并加载配置文件core-site.xmlhdfs-site.xml

hdfsfile("hdfs://192.168.0.76:9000/orders.txt":"GBK").import()

读取hadoop文件系统中的orders.txt从文件对象中读出内容作为记录形成序表返回