【发布时间】:2017-10-31 13:56:47
【问题描述】:
我正在尝试其中一个梁谷歌数据流管道示例,但我遇到了关于 MapElements 和方法 SingleFunction / SerializableFunction 调用的异常。代码sn-p如下:
static class ParseTableRowJson extends SimpleFunction<String, TableRow> {
@Override
public TableRow apply(String input) {
try {
return Transport.getJsonFactory().fromString(input, TableRow.class);
} catch (IOException e) {
throw new RuntimeException("Failed parsing table row json", e);
}
}
}
......
p.apply(TextIO.read().from(options.getInput()))
.apply(MapElements.via(new ParseTableRowJson()))
.apply(new ComputeTopSessions(samplingThreshold))
.apply("Write",
TextIO.write().withoutSharding().to(options.getOutput()));
例外是它对方法的调用不明确:
Ambiguous method call. Both
via (SimpleFunction<String, TableRow>) in MapElements and
via (SerializableFunction) in MapElements match
是否有其他人遇到了同样的异常并找到了解决办法?
完整示例在 github (https://github.com/apache/beam/blob/master/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java) 中。
谢谢,
费尔南多
【问题讨论】:
标签: java google-cloud-dataflow apache-beam