【问题标题】:How to use CombineFn with getKey如何将 CombineFn 与 getKey 一起使用
【发布时间】:2020-08-21 19:39:57
【问题描述】:

我有以下代码:

PCollection<KV<String, Cell>> first = ...;

PCollection<String> lines = first
  .apply("Build lines", Combine.<String, Cell, String>perKey(new MergeCellsFn()))
;

Cell 看起来像:

public class Cell {
   public final int index;
   public final String value; 

   public Cell(int i, String value) {
      index = i;
      this.value = value;
   }
}

还有MergeCellsFn

public class MergeCellsFn extends Combine.CombineFn<Cell, MergeCellsFn.Merger, String>

现在,当我尝试在上面的 apply 上编译时失败:

incompatible types: inference variable OutputT has incompatible bounds
     equality constraints: org.apache.beam.sdk.values.PCollection<org.apache.beam.sdk.values.KV<java.lang.String,java.lang.String>>
     lower bounds: org.apache.beam.sdk.values.PCollection<java.lang.String>,org.apache.beam.sdk.values.POutput

我在网上只能找到一些 lambda 可能会隐式执行某些操作的地方。但是从错误消息中我不知道是什么以及如何解决这个问题,更不用说是什么问题了。

【问题讨论】:

    标签: java apache-beam


    【解决方案1】:

    更改为 PCollection&lt;KV&lt;String, String&gt;&gt; lines = 会编译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-02
      • 1970-01-01
      • 2023-03-13
      • 2014-09-25
      • 2016-01-30
      • 2015-12-13
      • 2020-09-15
      • 2020-06-03
      相关资源
      最近更新 更多