zoukankan      html  css  js  c++  java
  • Hive解决 java.io.IOException:SerDeException:LazySimpleSerDe

    具体的出错信息是:

    Failed with exception java.io.IOException:org.apache.hadoop.hive.serde2.SerDeException: class org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe: expects either BytesWritable or Text object!

    出错原因:数据文件的field使用了LazySimpleSerDe不能解析的类型。

    报出此异常的代码为:

    public Object deserialize(Writable field) throws SerDeException {
        ......;
        if (field instanceof BytesWritable) {
          ......;
        } else if (field instanceof Text) {
          ......;
        } else {
          throw new SerDeException(getClass().toString()
              + ": expects either BytesWritable or Text object!");
        }
    

    可见LazySimpleSerDe能解析的类型:BytesWritable或Text 及其子类。

    MR job中常用类型LongWritable, IntWritable等不支持。

    在我的程序中,Reduce采用LongSumReducer, 输出SequenceFileOutputFormat,key 为Text,Value是LongWritable

    解决方法:不想只为改输出value的类型而重写Reduce, 于是只把输出文件类型改为TextOutputFormat,压缩算法等不需要改变。

  • 相关阅读:
    用户数据报协议---UDP
    斐波那契数列
    从尾到头打印链表
    Mybatis三种查询方式
    Mybatis配置
    字典的用法
    遍历列表、切片、定义元组
    与列表相关知识
    python一些方法总结
    计算机的容量
  • 原文地址:https://www.cnblogs.com/aprilrain/p/2956050.html
Copyright © 2011-2022 走看看