【Hudi数据湖应用】hudi 0.11编译异常之HoodieParquetDataBlock找不到合适的ByteArrayOutputStream构造器

最近hudi 0.11发布了,为了体验与应用新特征,我们编译升级到了 0.11。编译配适hadoop 3.1.0版本的hudi时报了个编译异常:FSDat
aOutputStream(java.io.ByteArrayOutputStream), 找不到合适的构造器。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project hudi-common: Compilation failur
e
[ERROR] /D:/Workspace/Apache/apache-hudi/hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieParquetDataBlock.java:[112,44] 对于FSDat
aOutputStream(java.io.ByteArrayOutputStream), 找不到合适的构造器
[ERROR]     构造器 org.apache.hadoop.fs.FSDataOutputStream.FSDataOutputStream(java.io.OutputStream,org.apache.hadoop.fs.FileSystem.Statistics)不适用    
[ERROR]       (实际参数列表和形式参数列表长度不同)
[ERROR]     构造器 org.apache.hadoop.fs.FSDataOutputStream.FSDataOutputStream(java.io.OutputStream,org.apache.hadoop.fs.FileSystem.Statistics,long)不适 
用]     构造器 org.apache.hadoop.fs.FSDataOutputStream.FSDataOutputStream(java.io.OutputStream,org.apache.hadoop.fs.FileSystem.Statistics,long)不适 
用
[ERROR]       (实际参数列表和形式参数列表长度不同)

问题代码是这样的。

    try (FSDataOutputStream outputStream = new FSDataOutputStream(baos)) {
      try (HoodieParquetStreamWriter<IndexedRecord> parquetWriter = new HoodieParquetStreamWriter<>(outputStream, avroParquetConfig)) {
        for (IndexedRecord record : records) {
          String recordKey = getRecordKey(record).orElse(null);
          parquetWriter.writeAvro(recordKey, record);
        }
        outputStream.flush();
      }
    }

查看FSDataOutputStream的代码,可以看到FSDataOutputStream只有2个构造器了。新的构造器加入了Statistics stats和long startPosition两个参数,用于进行输出流的io统计。

  public FSDataOutputStream(OutputStream out, Statistics stats) {
    this(out, stats, 0L);
  }

  public FSDataOutputStream(OutputStream out, Statistics stats, long startPosition) {
    super(new FSDataOutputStream.PositionCache(out, stats, startPosition));
    this.wrappedStream = out;
  }

需要激活统计的话,至少需要传入Statistics。Statistics有两个构造函数,一个是传入系统的schema,一个是传入另一个Statistics对象。第二个构造器是不可能了,那第一个可以吗?我们在hudi的HoodieParquetDataBlock可以拿到系统的schema吗?

    public Statistics(String scheme) {
      this.scheme = scheme;
      this.rootData = new FileSystem.Statistics.StatisticsData();
      this.threadData = new ThreadLocal();
      this.allData = new HashSet();
    }

    public Statistics(FileSystem.Statistics other) {
      this.scheme = other.scheme;
      this.rootData = new FileSystem.Statistics.StatisticsData();
      other.visitAll(new FileSystem.Statistics.StatisticsAggregator<Void>() {
        public void accept(FileSystem.Statistics.StatisticsData data) {
          Statistics.this.rootData.add(data);
        }

        public Void aggregate() {
          return null;
        }
      });
      this.threadData = new ThreadLocal();
      this.allData = new HashSet();
    }

撸了一遍代码,发现拿不到。所以只能传空了。
在这里插入图片描述
查看hudi的其他代码,传空是普遍现象哦。重新编译后,顺利编译通过,可以放心使用。
在这里插入图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值