MapReduce与Hadoop:类型不匹配(MapReduce with Hadoop: Type mismatch)
我正在运行一个简单的hadoop程序,我收到以下错误:
java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.Text, recieved org.apache.hadoop.io.LongWritable
制图员:
public static class myMapper extends Mapper<LongWritable, Text, Text, Text> public void map(LongWritable key, Text line,OutputCollector<Text,Text> output, Reporter reporter) throws IOException, InterruptedException
减速器:
public static class triangleCounterReducer extends Reducer<Text, Text, Text, Text> public void reduce(Text key,Iterable<Text> line,OutputCollector<Text,Text> output,Reporter reporter) throws IOException, InterruptedException
主要:
... job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Text.class); ...
我怎样才能解决这个问题????
I'm running a simple hadoop program, and I get the following error:
java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.Text, recieved org.apache.hadoop.io.LongWritable
Mapper:
public static class myMapper extends Mapper<LongWritable, Text, Text, Text> public void map(LongWritable key, Text line,OutputCollector<Text,Text> output, Reporter reporter) throws IOException, InterruptedException
Reducer:
public static class triangleCounterReducer extends Reducer<Text, Text, Text, Text> public void reduce(Text key,Iterable<Text> line,OutputCollector<Text,Text> output,Reporter reporter) throws IOException, InterruptedException
Main:
... job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Text.class); ...
How can i fix this????
原文:https://stackoverflow.com/questions/14665711
最满意答案
尝试在
{
之前但在{
之前删除分号。改变这个:
for(int x = 1; x <= 20; x++); {
对此:
for(int x = 1; x <= 20; x++) {
的
;
结束for
循环。 你在代码中所做的是有一个完整的for
循环,后跟一个不相关的代码块。x
仅在for
循环的范围内可见,这意味着该错误的分号。Try removing the semicolon after
for
but before the{
.Change this:
for(int x = 1; x <= 20; x++); {
to this:
for(int x = 1; x <= 20; x++) {
The
;
ends thefor
loop. What you have done in your code is have a completefor
loop followed by an unrelated block of code. Thex
is only visible within the scope of thefor
loop, which means up to that errant semicolon.
相关问答
更多-
PHP比较效率($ var ==($ var1 || $ var2))(PHP Comparing Efficiency ($var == ($var1 || $var2)))[2023-06-05]
如果我们假设您将'效率'视为运行时间 (与其他措施,例如击键次数,例如),那么您最初拥有的效率就像它获得的那样高效: if($var == $var1 || $var == $var2) 条件运算符|| 和&& 短路时它们可以,这意味着如果$var恰好等于$var1 ,那么与$var2的比较将永远不会发生。 如果你开始有很多条件,你只是想保持你的代码干净,你可以将所有可能的值存储在一个数组中,并检查$var是否在数组中: $possibleVals = array( 1, 2, 3 ); $var = 1 ... -
ruby编译器非常清楚这个,它没有想到你的孤独:在第4行的author.rb 。它显然不是有效的ruby,你应该按照validates_presence_of的文档 。 这条线应该简单地说 validates_presence_of :first_name, :last_name The ruby compiler is exceptionally clear on this one, it did not expect your solitary : in author.rb on line 4. It ...
-
这在功能上等同于您的代码在一行中: msgbox % var ~= "^(abc|def|ghi)$" ? "Yes" : "No" This is functionally equivalent to your code in one line: msgbox % var ~= "^(abc|def|ghi)$" ? "Yes" : "No"
-
C不承认var - 我必须忽略一些简单的东西。(C doesn't recognize var - I must be overlooking something simple. [closed])[2022-08-29]
尝试在{之前但在{之前删除分号。 改变这个: for(int x = 1; x <= 20; x++); { 对此: for(int x = 1; x <= 20; x++) { 的; 结束for循环。 你在代码中所做的是有一个完整的for循环,后跟一个不相关的代码块。 x仅在for循环的范围内可见,这意味着该错误的分号。 Try removing the semicolon after for but before the {. Change this: for(int x = 1; x <= 20; x ... -
使用var真的很糟糕吗? 我应该在我的库中转换响应,以便他可以在他的应用程序中明确键入它吗? 在我看来,我宁愿使用var并节省一些时间然后花40分钟尝试去明确。 在C#中, var只是一个编译器“技巧”。 没有涉及动态类型,编译的代码完全相同。 将鼠标悬停在变量上时,IDE将告诉您使用的“真实”类型。 无论他使用var还是实际的返回类型,在创建库的方面都不重要。 如果您的图书馆不必要地返回dynamic ,这可能是一个不同的问题,并且用户可能有有效的投诉。 与var (仅仅是编译时技巧)不同, dynami ...
-
代替: var result; 使用db.Jobs.FindAll返回的实际类型: IEnumerable
result; Instead of: var result; Use the actual type returned by db.Jobs.FindAll: IEnumerable result; -
你的代码片段看起来更像是一个错误,而不是代码风格的例子。 我会假设你的意思是: $('.element').each(function () { var $this = $(this); ... }); 是的,这是完全可以接受的。 正如你可以在这里看到的 : 变量名称必须以字母开头 变量名称也可以以$和_(1)开头(但我们不会使用它) 现在,就目标而言:这是一个可读性问题 - 许多使用jQuery的人发现,使用$name前缀他们的jQuery对象变量更容易阅读。 例如,这使得更容易一眼看出什么是j ...
-
!var等价于var==NULL 。 因此,您的第一个测试检查if (var == NULL) 。 你的第二个测试检查与此相反的结果,所以给出了相反的结果。 这种行为! 运算符在C11中描述6.5.3.3一元算术运算符 p5 逻辑否定运算符的结果! 如果其操作数的值不等于0,则为0;如果操作数的值等于0,则为1。 !var is equivalent to var==NULL. Your first test therefore checks if (var == NULL). Your second te ...
-
您希望使用Popen进行communicate ,如文档中所述: >>> from subprocess import * >>> Popen(['echo', 'Hi'], stdout=PIPE).communicate()[0] 'Hi\n' You want to use Popen with communicate, as described in the docs: >>> from subprocess import * >>> Popen(['echo', 'Hi'], stdout=PI ...
-
var locations = locations对我的对象做了什么?(What does var locations = locations do to my object? [closed])[2021-09-10]
Fordi der er en typo i din kode。 var locations = locations; 本来应该的 var locations = location; Þegarþúskilgreinirstaðsetningarsemvarstaðsetningar var locations = locations; ,首先评估右侧页面,它是undefined (因为它尚未初始化)。 因此, undefined将分配给locations 。 调用Object.keys , locat ...