Hadoop程序中Configured类的用途是什么?

编程入门 行业动态 更新时间:2024-10-25 12:27:58
本文介绍了Hadoop程序中Configured类的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大多数Hadoop MapReduce程序如下:

Most of Hadoop MapReduce programs are like this:

public class MyApp extends Configured Implements Tool { @Override public int run(String[] args) throws Exception { Job job = new Job(getConf()); /* process command line options */ return job.waitForCompletion(true) ? 0 : 1; } public static void main(String[] args) throws Exception { int exitCode = ToolRunner.run(new MyApp(), args); System.exit(exitCode); } }

Configured的用途是什么?由于Tool和Configured都具有getConf()和setConf()的共同点.它为我们的应用程序提供了什么?

What is the usage of Configured? As Tool and Configured both have getConf() and setConf() in common. What does it provide to our application?

推荐答案

Configured是接口Configurable的实现类. Configured是具有getConf()和setConf()的实现的基类.

Configured is an implementation class of the interface Configurable. Configured is the base class which has the implementations of getConf() and setConf().

仅扩展此基类,即可使用Configuration配置扩展此基类的类,并且Configuration有多个实现.

Merely extending this base class enables the class that extends this to be configured using a Configuration and there are more than one implementations for Configuration.

您的代码执行以下行时,

When your code executes the following line,

ToolRunner.run(new MyApp(), args);

内部将执行此操作

ToolRunner.run(tool.getConf(), tool, args);

在上述情况下,tool是MyApp类实例,它是Tool的实现,正如您所说的具有getConf(),但它只是作为接口.该实现来自Configured基类.如果您避免在上述代码中扩展Configured类,则必须自己执行getConf()和setConf()实现.

In the above case tool is the MyApp class instance which is an implementation of Tool which just as you said has getConf() but it is just as an interface. The implementation is coming from Configured base class. If you avoid extending Configured class in the above code, then you will have to do the getConf() and setConf() implementations on your own.

更多推荐

Hadoop程序中Configured类的用途是什么?

本文发布于:2023-11-05 04:03:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559846.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用途   程序   Hadoop   Configured

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!