如何结合使用CombineFn和getKey

时间:2020-08-21 19:39:57

标签: java apache-beam

我有以下代码:

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可能在某处隐式地做某事。但是从错误消息中我不知道该如何解决此问题,更不用说是什么问题了。

1 个答案:

答案 0 :(得分:0)

更改为Callback即可进行编译。

相关问题