2011-05-23 67 views

回答

5

绝对:)你可以使用Hadoop的流媒体这样的:

创建映射器和/或减速的Lua脚本,从标准输入读取:

#!/usr/bin/env lua 
while true do 
    local line = io.read() 
    if line == nil then break end 

    # Do something with the incoming row 

end 

,然后运行您的工作,如:

$HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/hadoop-streaming.jar \ 
    -input myInputDirs \ 
    -output myOutputDir \ 
    -mapper myMapper.lua \ 
    -reducer myReducer.lua \ 
    -file /local/path/to/myMapper.lua 
    -file /local/path/to/myReducer.lua 

在这里,您使用-mapper-reducer指定您的映射器和reducer脚本,并将这两个脚本与-file您的分布式缓存,所有任务跟踪器都可以访问它。

当流运行,你需要确保lua适用于所有运行任务服务器的机器。

前一段时间,我们尝试使用luajit(这是可怕的快)从猪流。如果您使用的猪,你可以这样做:

OP = stream IP through `/local/path/to/script`; 

这是不一样的使用Lua作为一个映射或减速,但根据您的操作情况,请从映射器或减速机的输出通过流剧本。

相关问题