我具有以下拓扑,无法为最后一步创建编码器,KV[K, CoCombinedResult]
,JLong
和JDouble
指的是java.lang.Long
和{{1} } 分别。我不确定从哪里开始调试。单步执行时,合并结果似乎缺少类型信息。
java.lang.Double
更新:
为合并步骤明确设置编码器将引发异常class SF[T] extends SimpleFunction[T, T] {
override def apply(t: T): T = t
}
class TestPCollectionAssertion extends JUnitSuite {
@(Rule@getter)
val pipeline: TestPipeline = TestPipeline.create()
@Test
def testCombiner(): Unit = {
val tag2 = new TupleTag[JLong](){}
val tag3 = new TupleTag[JDouble](){}
val combiner: GlobalCombineFn[JLong, _, CombineFns.CoCombineResult] = CombineFns
.compose()
.`with`(new SF[JLong](), Count.combineFn[JLong](), tag2)
.`with`(new SF[JLong](), Mean.of[JLong](), tag3)
val result = pipeline
.apply(Create.of(KV.of("Hello", 1L.asInstanceOf[JLong]), KV.of("World", 1L.asInstanceOf[JLong])))
.apply(Combine.perKey[String, JLong, CoCombineResult](combiner))
.apply(ParDo.of(new ExtractTags(tag2, tag3)))
}
}
Cannot infer coder for type parameter OutputT