我能够正确地重命名我的reducer输出文件,但是r-00000仍然存在。我在减速机课上用过多次输出。这是细节。不知道我还缺什么或者我还得做什么?
public class MyReducer extends Reducer<NullWritable, Text, NullWritable, Text> {
private Logger logger = Logger.getLogger(MyReducer.class);
private MultipleOutputs<NullWritable, Text> multipleOutputs;
String strName = "";
public void setup(Context context) {
logger.info("Inside Reducer.");
multipleOutputs = new MultipleOutputs<NullWritable, Text>(context);
}
@Override
public void reduce(NullWritable Key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
for (Text value : values) {
final String valueStr = value.toString();
StringBuilder sb = new StringBuilder();
sb.append(strArrvalueStr[0] + "|!|");
multipleOutputs.write(NullWritable.get(), new Text(sb.toString()),strName);
}
}
public void cleanup(Context context) throws IOException,
InterruptedException {
multipleOutputs.close();
}
}
2条答案
按热度按时间dwbf0jvd1#
我能够在我的工作完成后明确地做这件事,这对我来说没关系。工作没有延误
yv5phkfx2#
解决这个问题的一个更合适的方法是改变输出格式。
例如:-如果您使用的是textoutputformatclass,只需获取textoutputformat类的源代码,并修改下面的方法以获得正确的文件名(不带r-00000)。然后我们需要在驱动程序中设置修改后的输出格式。
因此,无论通过多个输出传递什么名称,都将根据它创建文件名。