本文整理汇总了Java中org.apache.hadoop.mapred.Reducer.close方法的典型用法代码示例。如果您正苦于以下问题:Java Reducer.close方法的具体用法?Java Reducer.close怎么用?Java Reducer.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.mapred.Reducer
的用法示例。
在下文中一共展示了Reducer.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combineAndSpill
import org.apache.hadoop.mapred.Reducer; //导入方法依赖的package包/类
private void combineAndSpill(
RawKeyValueIterator kvIter,
Counters.Counter inCounter) throws IOException {
JobConf job = jobConf;
Reducer combiner = ReflectionUtils.newInstance(combinerClass, job);
Class<K> keyClass = (Class<K>) job.getMapOutputKeyClass();
Class<V> valClass = (Class<V>) job.getMapOutputValueClass();
RawComparator<K> comparator =
(RawComparator<K>)job.getCombinerKeyGroupingComparator();
try {
CombineValuesIterator values = new CombineValuesIterator(
kvIter, comparator, keyClass, valClass, job, Reporter.NULL,
inCounter);
while (values.more()) {
combiner.reduce(values.getKey(), values, combineCollector,
Reporter.NULL);
values.nextKey();
}
} finally {
combiner.close();
}
}
示例2: combineAndSpill
import org.apache.hadoop.mapred.Reducer; //导入方法依赖的package包/类
private void combineAndSpill(
RawKeyValueIterator kvIter,
Counters.Counter inCounter) throws IOException {
JobConf job = jobConf;
Reducer combiner = ReflectionUtils.newInstance(combinerClass, job);
Class<K> keyClass = (Class<K>) job.getMapOutputKeyClass();
Class<V> valClass = (Class<V>) job.getMapOutputValueClass();
RawComparator<K> comparator =
(RawComparator<K>)job.getOutputKeyComparator();
try {
CombineValuesIterator values = new CombineValuesIterator(
kvIter, comparator, keyClass, valClass, job, Reporter.NULL,
inCounter);
while (values.more()) {
combiner.reduce(values.getKey(), values, combineCollector,
Reporter.NULL);
values.nextKey();
}
} finally {
combiner.close();
}
}
示例3: runOldReducer
import org.apache.hadoop.mapred.Reducer; //导入方法依赖的package包/类
void runOldReducer(JobConf job,
final MRTaskReporter reporter,
KeyValuesReader input,
RawComparator comparator,
Class keyClass,
Class valueClass,
final KeyValueWriter output) throws IOException, InterruptedException {
Reducer reducer =
ReflectionUtils.newInstance(job.getReducerClass(), job);
// make output collector
OutputCollector collector =
new OutputCollector() {
public void collect(Object key, Object value)
throws IOException {
output.write(key, value);
}
};
// apply reduce function
try {
ReduceValuesIterator values =
new ReduceValuesIterator(
input, reporter, reduceInputValueCounter);
values.informReduceProgress();
while (values.more()) {
reduceInputKeyCounter.increment(1);
reducer.reduce(values.getKey(), values, collector, reporter);
values.informReduceProgress();
}
// Set progress to 1.0f if there was no exception,
reporter.setProgress(1.0f);
//Clean up: repeated in catch block below
reducer.close();
//End of clean up.
} catch (IOException ioe) {
try {
reducer.close();
} catch (IOException ignored) {
}
throw ioe;
}
}