1
我想在hadoop上實現一個parallel-for。基本上是並行的 - 接收一個子框架(它可以是一個像map()這樣的函數)和一個整數作爲參數。子骨架將執行整數參數指定的次數。一次調用子骨架的結果將作爲參數傳遞給以下子骨架調用。最後,將最後一個子骨架的結果作爲並行結果提供。 Scandium庫(http://skandium.niclabs.cl/)上的實現示例如下,我希望在hadoop上移植此實現。在hadoop中實現parallel-for
* @param <P> The input and result type of the {@link Skeleton}.
* */
public class For<P> extends AbstractSkeleton<P,P> {
Skeleton<P,P> subskel;
int times;
/**
* The constructor.
*
* @param skeleton The skeleton pattern to execute.
* @param times The number of times to execute the skeleton.
*/
public For(Skeleton<P,P> skeleton, int times){
this.subskel=skeleton;
this.times = times;
}
/**
* The constructor.
*
* @param execute The skeleton pattern to execute.
* @param times The number of times to execute the {@link Muscle}.
*/
public For(Execute<P,P> execute, int times){
this(new Seq<P,P>(execute), times);
}
/**
* {@inheritDoc}
*/
public void accept(SkeletonVisitor visitor) {
visitor.visit(this);
}
}
對不起,我不記得你的問題。你想運行一個函數f()一個固定的次數,每次將前一次運行的結果傳遞給當前運行?什麼部分應該是平行的?你能更具體地瞭解你的總體目標是什麼嗎?可能有一個簡單的現有工具可以幫助你。 –
在hadoop中,輸入被分割到不同的工作站,並且同一個功能同時應用於所有工作站。這是它的平行部分。我唯一需要擔心的是以順序方式實現該功能。算法框架框架處理複雜性的平行。 MapReduce(Hadoop)是框架之一。 – asembereng
要將一個Map函數的結果傳遞給一個新的Map函數,你必須鏈接Mappers ......聽起來像可能工作的是在mapper中有一個循環來處理,然後組合/完成結果在減速機中? – Nija