Hadoop LongSumReducer(Hadoop LongSumReducer)
我正在使用hadoop“2.0.0-cdh4.1.1”,我尝试将
LongSumReducer
用于我的wordCount程序。job.setReducerClass((new LongSumReducer<Text>()).getClass());
但是有一个编译错误:
setReducerClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.Reducer>) in org.apache.hadoop.mapreduce.Job cannot be applied to (java.lang.Class<capture#402 of extends org.apache.hadoop.mapred.lib.LongSumReducer>)
I'm using hadoop "2.0.0-cdh4.1.1" and I try to use
LongSumReducer
for my wordCount program.job.setReducerClass((new LongSumReducer<Text>()).getClass());
However there's a compilation error:
setReducerClass(java.lang.Class<? extends org.apache.hadoop.mapreduce.Reducer>) in org.apache.hadoop.mapreduce.Job cannot be applied to (java.lang.Class<capture#402 of extends org.apache.hadoop.mapred.lib.LongSumReducer>)
原文:https://stackoverflow.com/questions/13462432
更新时间:2023-09-05 21:09
最满意答案
通过打印检查你的两个foreach变量在该函数是数组,我的意思是你的$ tax得到了行和$ tax得到了正确的序列化数据,你可以通过使用is_array()嵌入if条件来忽略该错误,这里是一个演示..
if (is_array($taxes)) { foreach ($taxes as $tax) { $tax = unserialize($tax); if(is_array($tax)){ foreach ($tax as $id => $tax_data) { $subtotal += !empty($tax_data['tax_subtotal']) ? $tax_data['tax_subtotal'] : 0; } } } }
check out by print your two foreach variable in that function is array, I mean your $taxes got rows and $tax got proper serialize data , you can ignore that error by embed an if condition with is_array(), here is a demonstration ..
if (is_array($taxes)) { foreach ($taxes as $tax) { $tax = unserialize($tax); if(is_array($tax)){ foreach ($tax as $id => $tax_data) { $subtotal += !empty($tax_data['tax_subtotal']) ? $tax_data['tax_subtotal'] : 0; } } } }
相关问答
更多-
通过打印检查你的两个foreach变量在该函数是数组,我的意思是你的$ tax得到了行和$ tax得到了正确的序列化数据,你可以通过使用is_array()嵌入if条件来忽略该错误,这里是一个演示.. if (is_array($taxes)) { foreach ($taxes as $tax) { $tax = unserialize($tax); if(is_array($tax)){ foreach ($tax as $id => $t ...
-
参数列表中的顺序错误: $this->updateActivation('users', $email, array('verified' => 1)); 电话 updateActivation($table, $fields = array(), $email = null) { 我想它应该是 $this->updateActivation('users', array('verified' => 1), $email); ?? You have wrong order in the paramet ...
-
$mileage_input可能不是一个数组,因此它不起作用。 $mileage_input is probably not an array, which is why it isn't working.
-
好吧,foreach只适用于数组和数组,但看起来你给它一个字符串。 你可以爆炸字符串和foreach: $subAdmins = explode(',', $request->input('subAdmin')); Well, a foreach only works on arrays and arrayables, but it looks like you're giving it a string. You can explode the string and foreach over that: ...
-
在使用foreach之前,如果它是数组,则测试$result 。 你的结果可能是false因为你的数据库查询失败,或者没有结果返回。 if (is_array($result)) { foreach($result as $row) { /* ... */ } } Test the $result if it is an array, before using foreach on it. Your result may be false since your da ...
-
由于glob()可能无法可靠地为空匹配返回一个空数组( 参见文档的Return部分中的“note”) ,因此您只需要一个if语句来保护循环,如下所示: $files = glob($tmpFolder . $fileTypes); if (is_array($files) && count($files) > 0) { foreach($files as $Filename) { // Read file creation time $FileCreationTime ...
-
尝试检查$result是否有值并使用 - 更新代码 - if($result != NULL && is_array($result)) { foreach ($result as $entry) { // your conditions } } Try to check if $result has values and update your code with - if($result != NULL && is_array($result)) { fore ...
-
$users未在您的控制器中定义,但$user是。 你试图@foreach一个字面上等于字符串'$users'的变量。 更改: $user = User::all(); 至: $users = User::all(); 并删除$users周围的单引号: return View::make('users.index', ['users' => $users]); $users is not defined in your controller, but $user is. You are trying ...
-
如果你是var_dump($rawData) ,你会看到它是一个整数(或0)并且只返回结果数。 这是因为你应该使用时使用$command->execute() : $command->queryAll(); 这将返回一个结果数组,您可以将其传递给CActiveDataProvider If you var_dump($rawData), you'll see that it's an integer (or 0) and is only returning the number of results. T ...
-
更改 $dbh = new PDO("mysql:host = $hostname; dbname = kzkcubcy_webDev", $username, $password); 至 $dbh = new PDO("mysql:host=$hostname;dbname=kzkcubcy_webDev", $username, $password); 我认为您不允许在DSN字段中包含空格。 change $dbh = new PDO("mysql:host = $hostname; dbname ...