簡體   English   中英

Apache Beam Dataflow SDK錯誤與示例

[英]Apache beam Dataflow SDK error with example

我正在嘗試谷歌數據流管道示例之一,但我碰到了有關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()));

例外之處在於它對方法的模棱兩可:

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 )中。

謝謝,

費爾南多

這似乎已在HEAD的代碼中修復。 具體來說, MapElements不再具有via兩個靜態版本。 短期,你可以從頭梁安裝或更新的例子使用ParDo直接通過使ParseTableRowJson一個DoFn而不是SimpleFunction

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM