- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在做一组操作,其中一个 reduce 任务运行的时间很长。以下是示例代码片段和问题描述,
inp =load 'input' using PigStorage('|') AS(f1,f2,f3,f4,f5);
grp_inp = GROUP inp BY (f1,f2) parallel 300;
由于数据存在偏差,即一个键的值太多,一个 reducer 运行了 4 小时。其余所有 reduce 任务在 1 分钟左右完成。
我能做些什么来解决这个问题,有什么替代方法吗?任何帮助将不胜感激。谢谢!
最佳答案
您可能需要检查几件事:-
1>过滤掉f1和f2都为NULL的记录(如果有的话)
2> 如果可能,尝试通过实现代数接口(interface)来使用 hadoop 组合器:-
https://www.safaribooksonline.com/library/view/programming-pig/9781449317881/ch10s02.html
3> 使用 Custom partitioner 使用另一个键在 reducer 中分发数据。
这是我用来在连接后对倾斜数据进行分区的示例代码(同样可以在组后使用):-
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.Partitioner;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.io.NullableTuple;
import org.apache.pig.impl.io.PigNullableWritable;
public class KeyPartitioner extends Partitioner<PigNullableWritable, Writable> {
/**
* Here key contains value of current key used for partitioning and Writable
* value conatins all fields from your tuple. I used my 5th field from tuple to do partitioning as I knew it has evenly distributed value.
**/
@Override
public int getPartition(PigNullableWritable key, Writable value, int numPartitions) {
Tuple valueTuple = (Tuple) ((NullableTuple) value).getValueAsPigType();
try {
if (valueTuple.size() > 5) {
Object hashObj = valueTuple.get(5);
Integer keyHash = Integer.parseInt(hashObj.toString());
int partitionNo = Math.abs(keyHash) % numPartitions;
return partitionNo;
} else {
if (valueTuple.size() > 0) {
return (Math.abs(valueTuple.get(1).hashCode())) % numPartitions;
}
}
} catch (NumberFormatException | ExecException ex) {
Logger.getLogger(KeyPartitioner.class.getName()).log(Level.SEVERE, null, ex);
}
return (Math.abs(key.hashCode())) % numPartitions;
}
}
关于hadoop - 在 pig 中分组时如何处理倾斜数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38567471/
我是初学者,我正在做一些练习来熟悉 CALayer ... 我只是想知道如何“倾斜”(或倾斜)CALayer 45° 角? 谢谢。 最佳答案 CALayers 有一个属性 affineTransfor
无法理解如何制作this trick或 this与CSS。我的意思是标题和标志。这条线不直。它们是倾斜的/倾斜的边界。能否请您举个例子或只是举例说明这是可行的? 最佳答案 看看https://jsfi
如何倾斜图像?例如,每个角都有一个 CGPoint,其坐标为 - p1、p2、p3、p4。然后,我需要设置 - p4.x+=50,p4.y+=30。因此这个角 (p4) 应该在 2D 透视中拉伸(st
我想弄清楚如何通过仅使用 css 来实现元素底部的跟随边框,并使其尽可能对跨浏览器友好 示例代码,带有标准边框 .object { width: 200px; height: 45p
我正在尝试使用 CSS transform 来倾斜 Bootstrap 导航 li,我可以做到这一点,但是当我尝试扭转内部链接上的倾斜时,li 倾斜也会反转回来。我不知道为什么。我试着做这里接受的答案
这个问题在这里已经有了答案: CSS: Set a background color which is 50% of the width of the window (14 个答案) 关闭 7 年前
我已经创建了一个预定的 div 来与我的导航栏一起使用,但是它弄乱了网站的其余格式。导航栏位于右上角,倾斜的 div 位于其下方,但它弄乱了网页上的所有其他内容。我一直在尝试一切都无济于事。 http
你好,我想像这里的附图一样对步骤菜单进行风格化。我该如何风格化这个?主要问题是菜单右侧的边框。 检查我的 JSFiddle URL https://jsfiddle.net/hcx1pv8x/ , 不
我正在尝试使用 HTML5 在 javascript 中倾斜 svg 元素,例如: 中的矩形元素是倾斜的,但 rect 元素也向右移动(不需要),我尝试手动设置位置使用 transform
目前我对应该倾斜的容器使用clip-path。 .box { height: 150px; line-height: 150px; text-align: center; backgr
我有一个相机从上方指向禅宗花园。然而,相机固定在侧面而不是直接在板的上方。结果,图像看起来像这样(注意矩形的倾斜形状): 有没有办法处理图像,使沙子区域看起来或多或少像一个完美的正方形? cap =
我正在尝试使用倾斜 350 度的 UIScrollview,我首先想到的是使用变换属性,滚动上的倾斜起作用了,但现在滚动上的所有内容看起来都不对,当我谈论所有内容时,我指的是位置和这个卷轴的所有 ch
我需要将我的应用程序升级到 Rails 3.2.16,当时我做了 bundle update rails它给了我以下错误。 Bundler could not find compatible vers
我正在尝试运行 rake db:migrate在本地,但我收到以下错误: Gem::LoadError: You have already activated rake 10.2.2, but you
很难用语言表达我想要完成的事情,所以请查看这张照片作为示例: 如您所见,我希望创建一个带有图案背景的倾斜 div(简单),但另一部分,即倾斜被半遮住的部分,也必须有背景图像。我想到了很多不同的想法,并
假设,我想将两个二维数组添加到第三个二维数组中。 我正在使用以下代码: cudaMallocPitch((void**)&device_a, &pitch, 2*sizeof(int),2); cud
很难用语言表达我想要完成的事情,所以请查看这张照片作为示例: 如您所见,我希望创建一个带有图案背景的倾斜 div(简单),但另一部分,即倾斜被半遮住的部分,也必须有背景图像。我想到了很多不同的想法,并
我刚刚遇到了这种附加字符串的变体,其中包含存储在变量中的值,这是我以前从未见过的。谁能帮我解释一下这是怎么回事? 这是我遇到的情况: var fruit = "banana"; $main = $('
假设,我想将两个二维数组添加到第三个二维数组中。 我正在使用以下代码: cudaMallocPitch((void**)&device_a, &pitch, 2*sizeof(int),2); cud
我正在尝试分析在 Windows 上运行的 Java UI 应用程序的 CPU 使用率。我将它连接到 VisualVM,但看起来 CPU 使用率最高的是 sum.rmi.transport.tcp.T
我是一名优秀的程序员,十分优秀!