ve0.13 rows loaded为空问题源码分析及fix
来源:互联网 发布:windows ce刷安卓教程 编辑:程序博客网 时间:2024/06/03 23:21
升级hive0.13之后发现job运行完成后Rows loaded的信息没有了。
rows loaded的信息在hive0.11中由HiveHistory类的printRowCount输出。HiveHistory类的主要用途是记录job运行的信息,包括task的counter等。默认的目录在/tmp/$user中。
hive0.11在SessionState 的start方法中会初始化HiveHistory的对象
if
(startSs. hiveHist ==
null
) {
startSs. hiveHist =
new
HiveHistory(startSs);
}
而在hive0.13中HiveHistory是一个抽象类,其具体的实现在HiveHistoryImpl类中,其中初始化HiveHistoryImpl对象时增加了一层判断,判断hive.session.history.enabled的设置(默认为false),导致不会实例化HiveHistoryImpl类
if
(startSs.hiveHist ==
null
){
if
(startSs.getConf().getBoolVar(HiveConf.ConfVars.HIVE_SESSION_HISTORY_ENABLED)) {
startSs.hiveHist =
new
HiveHistoryImpl (startSs);
}
else
{
//Hive history is disabled, create a no-op proxy
startSs.hiveHist = HiveHistoryProxyHandler .getNoOpHiveHistoryProxy();
}
}
在fix这个配置之后,仍然没有发现rows loaded的信息,通过分析源码
printRowCount方法的实现如下:
public
void
printRowCount(String queryId) {
QueryInfo ji = queryInfoMap.get(queryId);
if
(ji ==
null
) {
// 如果ji为空,则直接返回
return
;
}
for
(String tab : ji. rowCountMap.keySet()) {
console.printInfo(ji. rowCountMap.get(tab) +
" Rows loaded to "
+ tab);
// 从hashmap中获取数据
}
}
在hive0.13中,这里获取的ji对象是空值。
近一步发现,是由于counter中没有TABLE_ID_(\\d+)_ROWCOUNT,导致不能匹配ROW_COUNT_PATTERN的正则。就不能正常获取的row count的值。
其中获取tasker count的rows loaded信息的getRowCountTableName方法内容如下:
private
static
final
String ROW_COUNT_PATTERN =
"TABLE_ID_(\\d+)_ROWCOUNT"
;
private
static
final
Pattern rowCountPattern = Pattern.compile(ROW_COUNT_PATTERN);
......
String getRowCountTableName(String name) {
if
(idToTableMap ==
null
) {
return
null
;
}
Matcher m = rowCountPattern.matcher(name);
if
(m.find()) {
// //没有和TABLE_ID_xxxx match的counter导致,即counter没有打印出TABLE_ID_(\\d+)_ROWCOUNT导致。。
String tuple = m.group(
1
);
return
idToTableMap.get(tuple);
}
return
null
;
}
而TABLE_ID_(\\d+)_ROWCOUNT是由FileSinkOperator类负责写入的。hive0.11中相关的代码如下:
protected
void
initializeOp(Configuration hconf)
throws
HiveException {
..........
int
id = conf.getDestTableId();
if
((id !=
0
) && (id <= TableIdEnum. values().length)) {
String enumName =
"TABLE_ID_"
+ String.valueOf(id) +
"_ROWCOUNT"
;
tabIdEnum = TableIdEnum.valueOf(enumName);
row_count =
new
LongWritable();
statsMap.put( tabIdEnum, row_count );
}
而在hive0.13中这部分代码都被去掉了,找到了原因,fix也比较简单,把这个counter加回去就可了。
patch如下:
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
index 1dde78e..96860f7
100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
@@ -
68
,
13
+
68
,
16
@@
import
org.apache.hadoop.util.ReflectionUtils;
import
com.google.common.collect.Lists;
+
import
org.apache.commons.logging.Log;
+
import
org.apache.commons.logging.LogFactory;
+
/**
* File Sink operator implementation.
**/
public
class
FileSinkOperator
extends
TerminalOperator<FileSinkDesc>
implements
Serializable {
-
+
public
static
Log LOG = LogFactory.getLog(
"FileSinkOperator.class"
);
protected
transient
HashMap<String, FSPaths> valToPaths;
protected
transient
int
numDynParts;
protected
transient
List<String> dpColNames;
@@ -
214
,
6
+
217
,
7
@@
public
Stat getStat() {
protected
transient
FileSystem fs;
protected
transient
Serializer serializer;
protected
transient
LongWritable row_count;
+
protected
transient
TableIdEnum tabIdEnum =
null
;
private
transient
boolean
isNativeTable =
true
;
/**
@@ -
241
,
6
+
245
,
23
@@
public
Stat getStat() {
protected
transient
JobConf jc;
Class<?
extends
Writable> outputClass;
String taskId;
+
public
static
enum
TableIdEnum {
+ TABLE_ID_1_ROWCOUNT,
+ TABLE_ID_2_ROWCOUNT,
+ TABLE_ID_3_ROWCOUNT,
+ TABLE_ID_4_ROWCOUNT,
+ TABLE_ID_5_ROWCOUNT,
+ TABLE_ID_6_ROWCOUNT,
+ TABLE_ID_7_ROWCOUNT,
+ TABLE_ID_8_ROWCOUNT,
+ TABLE_ID_9_ROWCOUNT,
+ TABLE_ID_10_ROWCOUNT,
+ TABLE_ID_11_ROWCOUNT,
+ TABLE_ID_12_ROWCOUNT,
+ TABLE_ID_13_ROWCOUNT,
+ TABLE_ID_14_ROWCOUNT,
+ TABLE_ID_15_ROWCOUNT;
+ }
protected
boolean
filesCreated =
false
;
@@ -
317
,
7
+
338
,
15
@@
protected
void
initializeOp(Configuration hconf)
throws
HiveException {
prtner = (HivePartitioner<HiveKey, Object>) ReflectionUtils.newInstance(
jc.getPartitionerClass(),
null
);
}
- row_count =
new
LongWritable();
+
//row_count = new LongWritable();
+
int
id = conf.getDestTableId();
+
if
((id !=
0
) && (id <= TableIdEnum.values().length)) {
+ String enumName =
"TABLE_ID_"
+ String.valueOf(id) +
"_ROWCOUNT"
;
+ tabIdEnum = TableIdEnum.valueOf(enumName);
+ row_count =
new
LongWritable();
+ statsMap.put(tabIdEnum, row_count);
+ }
+
if
(dpCtx !=
null
) {
dpSetup();
- ve0.13 rows loaded为空问题源码分析及fix
- jquery datagrid报错:rows 不能为空
- 调用Camera返回为空的分析及处理方法
- 解决"var rows = $('#dg').datagrid('getSelections');" rows.length总是为1的问题
- Android 保存 Fragment 引用及 getActivity() 为空问题
- json_decode为空问题
- 分析函数用法及窗口子句 range/rows差别
- 分析函数用法及窗口子句 range/rows差别
- jQuery源码分析之jQuery.event.fix方法五问
- ViewPager.getChildAt()为空问题?
- ListView getChildAt()为空问题
- 关于Hibernate源码 org.hibernate.hql.antlr包为空的问题。
- sqlloader上传文件时出现 Rows not loaded
- QT出现Driver not loaded的问题及解决办法
- 【问题及解决】script_score the script could not be loaded
- XMLHttpReq.responseXML 为空! XMLHttpReq.responseText不为空 问题!
- RequiredFieldValidator控件验证不能为空时报错多种解决方法以及问题分析
- jquery的ajax处理php返回数组,及json_encode中文为空的问题
- 关于hive RegexSerDe的源码分析
- GRUB启动命令详解
- 税的取数SQL
- linux下创建用户
- 机房收费系统之什么是报表
- ve0.13 rows loaded为空问题源码分析及fix
- linux和adb调试机顶盒的一些命令
- CentOS下php安装mcrypt扩展
- 你好,C++(3)2.1 一个C++程序的自白
- 嵌入式启动之四:S5PV210 IROM & BL0启动
- 苹果App Store审核指南中文翻译(2014.9.1更新)
- spring防止F5重复提交相同表单通用代码
- HDOJ 题目1166敌兵布阵(树状数组)
- 轻量级的进程--线程