我有一个 Hive UDF,它应该从 UA 字符串中提取设备。它使用 ua-parser 库: https://github.com/tobie/ua-parser
UDF 相当简单:
public class DeviceTypeExtractTest extends UDF{
private Text result = new Text();
private static final Parser uaParser;
static {
try {
uaParser = new Parser();
}
catch(IOException e) {
throw new RuntimeException("Could not instantiate User-Agent parser.");
}
}
public Text evaluate( Text uaField){
if (uaField == null ) {
return null;
}
try
{
String uaString = uaField.toString();
Client client = uaParser.parse(uaString);
result.set(client.device.family);
return result;
}
catch(Exception e)
{
return null;
}
}
}
而且在小型数据集上运行时效果很好。
create table categories(
cat string);
insert overwrite table categories select DEVICE_TYPE_EXTRACT(user_agent) from raw_logs;
但是,当在超过 1000 万行的更大数据集上对此进行测试时,我每次尝试都会收到此 LeaseExpiredException: http://pastebin.com/yK6Qmx6r
而且我的 map 和 reduce 进程在几个小时内一直停留在 0%。请注意,如果我取出此 udf 并使用一些内部 Hive UDF 仅用于测试,则不会发生此行为。
我正在使用 AMI 版本 2.4.5(Hive 0.11.0.2 和 Hadoop 1.0.3)的 Amazon EMR 集群上运行它。
我尝试通过部署更好的硬件来提高集群的性能,但我在任何硬件场景中都遇到了同样的问题。
有什么想法吗?
最佳答案
好吧,从头开始。似乎在升级我的实例之后,事情开始发生变化,但我只是等待映射的时间不够长。当我终止进程时,LeaseExpiredError 实际上是因为我的小问题而抛出的。
尽管如此,解析仍会花费大量时间,我希望得到一些进一步优化此 UDF 的建议。
关于hadoop - 在 Hive 中使用自定义 UDF 的 LeaseExpiredException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25786231/