ann*_*ist 7 python hadoop mapreduce utf-8 hadoop-streaming
我知道该选项卡是字段的默认输入分隔符:
stream.map.output.field.separator
stream.reduce.input.field.separator
stream.reduce.output.field.separator
mapreduce.textoutputformat.separator
Run Code Online (Sandbox Code Playgroud)
但如果我尝试编写通用解析器选项:
stream.map.output.field.separator=\t (or)
stream.map.output.field.separator="\t"
Run Code Online (Sandbox Code Playgroud)
测试hadoop如何在用作分隔符时解析像"\ t,\n,\ f"这样的空格字符.我观察到hadoop将其视为\ t字符而不是" " tab space itself. I checked it by printing each line in reducer (python) as it reads using :
sys.stdout.write(str(line))
Run Code Online (Sandbox Code Playgroud)
My mapper emits key/value pairs as : key value1 value2
使用print (key,value1,value2,sep='\t',end='\n')命令.
所以我希望我的减速器读取每一行:key value1 value2也是,但是sys.stdout.write(str(line))打印:
key value1 value2 \\with trailing space
从Hadoop流 - 从reducer输出中删除尾随选项卡,我理解尾随空间是由于mapreduce.textoutputformat.separator未设置并保留为默认值.
所以,这证实了我的假设,即hadoop考虑了我的总地图输出:
key value1 value2
作为空文本对象的键和值,因为它从stream.map.output.field.separator=\t"\ t"字符而不是" "制表符空间本身读取分隔符.
请帮助我理解这种行为,如果我愿意,如何使用\ t作为分隔符.
| 归档时间: |
|
| 查看次数: |
1276 次 |
| 最近记录: |