本文整理汇总了Java中org.apache.hadoop.mapreduce.lib.chain.Chain.ChainBlockingQueue类的典型用法代码示例。如果您正苦于以下问题:Java ChainBlockingQueue类的具体用法?Java ChainBlockingQueue怎么用?Java ChainBlockingQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChainBlockingQueue类属于org.apache.hadoop.mapreduce.lib.chain.Chain包,在下文中一共展示了ChainBlockingQueue类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.hadoop.mapreduce.lib.chain.Chain.ChainBlockingQueue; //导入依赖的package包/类
public void run(Context context) throws IOException, InterruptedException {
setup(context);
int numMappers = chain.getAllMappers().size();
if (numMappers == 0) {
return;
}
ChainBlockingQueue<Chain.KeyValuePair<?, ?>> inputqueue;
ChainBlockingQueue<Chain.KeyValuePair<?, ?>> outputqueue;
if (numMappers == 1) {
chain.runMapper(context, 0);
} else {
// add all the mappers with proper context
// add first mapper
outputqueue = chain.createBlockingQueue();
chain.addMapper(context, outputqueue, 0);
// add other mappers
for (int i = 1; i < numMappers - 1; i++) {
inputqueue = outputqueue;
outputqueue = chain.createBlockingQueue();
chain.addMapper(inputqueue, outputqueue, context, i);
}
// add last mapper
chain.addMapper(outputqueue, context, numMappers - 1);
}
// start all threads
chain.startAllThreads();
// wait for all threads
chain.joinAllThreads();
}
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:ChainMapper.java
示例2: run
import org.apache.hadoop.mapreduce.lib.chain.Chain.ChainBlockingQueue; //导入依赖的package包/类
public void run(Context context) throws IOException, InterruptedException {
setup(context);
// if no reducer is set, just do nothing
if (chain.getReducer() == null) {
return;
}
int numMappers = chain.getAllMappers().size();
// if there are no mappers in chain, run the reducer
if (numMappers == 0) {
chain.runReducer(context);
return;
}
// add reducer and all mappers with proper context
ChainBlockingQueue<Chain.KeyValuePair<?, ?>> inputqueue;
ChainBlockingQueue<Chain.KeyValuePair<?, ?>> outputqueue;
// add reducer
outputqueue = chain.createBlockingQueue();
chain.addReducer(context, outputqueue);
// add all mappers except last one
for (int i = 0; i < numMappers - 1; i++) {
inputqueue = outputqueue;
outputqueue = chain.createBlockingQueue();
chain.addMapper(inputqueue, outputqueue, context, i);
}
// add last mapper
chain.addMapper(outputqueue, context, numMappers - 1);
// start all threads
chain.startAllThreads();
// wait for all threads
chain.joinAllThreads();
}
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:ChainReducer.java
注:本文中的org.apache.hadoop.mapreduce.lib.chain.Chain.ChainBlockingQueue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论