首页 \ 问答 \ Mapper类如何将SequenceFile标识为hadoop中的输入文件?(How does Mapper class identify the SequenceFile as inputfile in hadoop?)

Mapper类如何将SequenceFile标识为hadoop中的输入文件?(How does Mapper class identify the SequenceFile as inputfile in hadoop?)

在我的一个MapReduce任务中,我将BytesWritable重写为KeyBytesWritable,并将ByteWritable重写为ValueBytesWritable。 然后我使用SequenceFileOutputFormat输出结果。

我的问题是当我开始下一个MapReduce任务时,我想使用这个SequenceFile作为输入文件。 那么我怎样才能设置工作类,以及Mapper类如何识别我之前被覆盖的SequenceFile中的键和值?

我明白我可以使用SequenceFile.Reader来读取关键字和值。

Configuration config = new Configuration();
Path path = new Path(PATH_TO_YOUR_FILE);
SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
WritableComparable key = (WritableComparable) reader.getKeyClass().newInstance();
Writable value = (Writable) reader.getValueClass().newInstance();
while (reader.next(key, value))

但是我不知道如何使用这个Reader将键和值作为参数传递给Mapper类。 我怎样才能将Conf.setInputFormat设置为SequenceFileInputFormat,然后让Mapper获得关键字和值?

谢谢


In my one MapReduce task, I override the BytesWritable as KeyBytesWritable, and override the ByteWritable as ValueBytesWritable. Then I output the result using SequenceFileOutputFormat.

My question is when I start the next MapReduce task, I want to use this SequenceFile as inputfile. So how could I set the jobclass, and how the Mapper class could identify the key and value in the SequenceFile which I overrided before?

I understand that I could SequenceFile.Reader to read the key and value.

Configuration config = new Configuration();
Path path = new Path(PATH_TO_YOUR_FILE);
SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
WritableComparable key = (WritableComparable) reader.getKeyClass().newInstance();
Writable value = (Writable) reader.getValueClass().newInstance();
while (reader.next(key, value))

But I don't know how to use this Reader to pass the key and value into Mapper class as Parameters. How could I set conf.setInputFormat to SequenceFileInputFormat and then let Mapper get the key and values?

Thanks


原文:https://stackoverflow.com/questions/15179456
更新时间:2024-05-08 12:05

最满意答案

您可以调用Type.GetType方法来获取具有给定(程序集限定)名称的Type对象。

您可以调用Activator.CreateInstance方法来创建类型的实例。 (假设该类型具有公共默认构造函数,或者您知道它采用的构造函数参数)。

例如:

Activator.CreateInstance(Type.GetType(name));

You can call the Type.GetType method to get a Type object with the given (assembly-qualified) name.

You can call the Activator.CreateInstance method to create an instance of a type. (assuming that the type has a public default constructor, or that you know what constructor arguments it takes).

For example:

Activator.CreateInstance(Type.GetType(name));

相关问答

更多
  • 要回答您的问题,请考虑以下代码: void Main() { string strMain = "main"; DoSomething(strMain); Console.Write(strMain); // What gets printed? } void DoSomething(string strLocal) { strLocal = "local"; } 你需要知道三件事来预测这里会发生什么,并了解它为什么会这样做。 字符串是C#中的引用类型。 但这只是图片的一部 ...
  • 您想在.NET平台内运行这些语言的程序吗? 你需要IronPython或IronRuby(我觉得像IronPerl这样的东西不存在)。 如果你想运行“普通”Python / Ruby / Perl / Java程序,那么是的,你需要安装Python解释器,Ruby解释器,Perl解释器和Java VM。 Do you want to run programs in these languages inside the .NET platform? You'd need IronPython or IronR ...
  • 您可以调用Type.GetType方法来获取具有给定(程序集限定)名称的Type对象。 您可以调用Activator.CreateInstance方法来创建类型的实例。 (假设该类型具有公共默认构造函数,或者您知道它采用的构造函数参数)。 例如: Activator.CreateInstance(Type.GetType(name)); You can call the Type.GetType method to get a Type object with the given (assembly-qu ...
  • 在有关向Windows发送消息的主题中查看我的帖子 。 通过使用此类API函数,您可以轻松控制或更改其他窗口。 常见的例子是最大化另一个窗口,最小化另一个窗口,从视图中隐藏另一个窗口,抓住另一个窗口并将其放置在您自己的窗口(设置其父窗口)中,改变另一个窗口的标题,改变另一个窗口的文本框中的文本(等等, )将键击和鼠标点击发送到窗口(或其中一个按钮),在另一个窗口中运行菜单等。 See my post in a thread about sending messages to windows. With th ...
  • 您可以使用DataBinder.Eval动态计算路径表达式(尽管这将意味着向System.Web添加依赖项): http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx C#示例: using System; using System.Web.UI; namespace DataBinderEval { internal class Program { private static void Main() { ...
  • 这是司机的问题。 通过删除延迟调用并检查数组边界来修复它。 This was a issue with the driver. Fixed it by removing the defer call & checking the array bounds.
  • 使用lookahead和lookbehind断言有另一种正则表达式方法来实现这一点: Regex regex = new Regex("(?<=Args\\(\").*?(?=\"\\))"); string input = "Args(\"token1\") + Args(\"token2\")"; MatchCollection matches = regex.Matches(input); foreach (var match in matches) { ...
  • WCF(Windows Communication Foundation)就是你想要的。 WCF (Windows Communication Foundation) is what you want.
  • 正如cnicutar所说使用net.ParseCIDR 。 这是一个关于如何实际使用它的工作示例。 http://play.golang.org/p/Wtqy56LS2Y package main import ( "fmt" "net" ) func main() { ipList := []string{"192.168.1.1/24", "fd04:3e42:4a4e:3381::/64"} for i := 0; i < len(ipList); i += 1 { ...
  • 创建一个能够存储所有可能的数字格式的自定义类: class ParsedNumber { NumberType Type; //Integer, FloatingPoint, Decimal BigInteger Integer; double FolatingPoint; decimal Decimal; } 该类应该可以实现相等和比较运算符。 您可以将每个单元格解析为此类的实例。 该类应该抽象不同的格式,以便您可以将其视为一个数字。 您还可以将此结构化为保存堆分配。 Create a cust ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)