Apache beam Dataflow SDK错误示例

时间:2022-11-23 15:36:29

I'm trying one of the beam google dataflow pipeline examples, but i'm bumping into a exception regarding MapElements and methods SingleFunction / SerializableFunction calls. The code snippet is the following:

我正在尝试使用一个beam google数据流管道示例,但是我遇到了关于MapElements和方法SingleFunction / SerializableFunction调用的异常。代码段如下:

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()));

The exception in that its an ambiguous call to the methods:

例外情况是它对方法的模糊调用:

Ambiguous method call. Both
via (SimpleFunction<String, TableRow>) in MapElements and
via (SerializableFunction)             in MapElements match

Has someone else bumped into the same exception and got a way around it?

是否还有其他人遇到了同样的例外并绕过它?

The full example is in github (https://github.com/apache/beam/blob/master/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java).

完整示例位于github(https://github.com/apache/beam/blob/master/examples/java/src/main/java/org/apache/beam/examples/complete/TopWikipediaSessions.java)。

Thanks,

谢谢,

Fernando

费尔南多

1 个解决方案

#1


0  

This seems to have been fixed in the code at HEAD. Specifically, MapElements no longer has two static versions of via. Short-term, you can either install Beam from HEAD or update the example to use ParDo directly by making the ParseTableRowJson a DoFn instead of a SimpleFunction.

这似乎已在HEAD的代码中得到修复。具体来说,MapElements不再具有两个静态版本的via。短期来说,您既可以从HEAD安装Beam,也可以通过将ParseTableRowJson设置为DoFn而不是SimpleFunction来更新示例以直接使用ParDo。

#1


0  

This seems to have been fixed in the code at HEAD. Specifically, MapElements no longer has two static versions of via. Short-term, you can either install Beam from HEAD or update the example to use ParDo directly by making the ParseTableRowJson a DoFn instead of a SimpleFunction.

这似乎已在HEAD的代码中得到修复。具体来说,MapElements不再具有两个静态版本的via。短期来说,您既可以从HEAD安装Beam,也可以通过将ParseTableRowJson设置为DoFn而不是SimpleFunction来更新示例以直接使用ParDo。